hgs yükleme
My Cart (0)  |  My Orders  |  My Downloads  |  My Auction  |  My Account  |  Help


Login |Register        Search

Delete dnn users from core tables

                Print      Add To Favorite     Add To Watch List     Contact Author

Creator: host   8/27/2012 4:54:04 AM    Author: CHANDAN KUMAR   Source: http://www.mindfiresolutions.com/Customized-deletion-of-Users-from-core-tables-in-database-of-a-DNN-application-1291.php   Views: 9784    0    0  
Tags:
Dotnetnuke User account delete user

Customized deletion of  Users  from core database tables of a DNN application .

Core tables which contain dnn application user informations are :: aspnet_Membership,  aspnet_Users ,UserProfile ,UserPortals ,UserRoles ,Users .

Note:: This is needed in many cases such as database cleanup of all test users created .As it's quite hectic to delete each users one by one from userinterface, so in such case this query is a real saviour. 


Delete all users except some.
Here for example i choose not to delete Admin and Host with userid 1 and 2 respectively.
SQL query for the required result is as following ::

DECLARE  @rUser table (UserId int)
INSERT INTO  @rUser (UserId) values (2)
INSERT INTO  @rUser (UserId) values (1)


DELETE  FROM aspnet_Membership WHERE UserId IN
( SELECT au.UserId FROM  aspnet_Users au  JOIN users u ON au.username = u.username WHERE u.userid NOT IN(SELECT  *  FROM  @rUser) )

DELETE FROM aspnet_Users where UserId in
( SELECT au.UserId FROM aspnet_Users au join users u on au.username = u.username WHERE u.userid NOT IN(SELECT * FROM  @rUser) )

DELETE FROM UserProfile where UserID in
( SELECT UserId FROM users WHERE userid NOT IN(SELECT * FROM  @rUser) )


DELETE FROM UserPortals where UserID in
( SELECT UserId FROM users WHERE userid NOT IN(SELECT * FROM  @rUser) )


DELETE FROM UserRoles where UserID in
( SELECT UserId FROM users WHERE userid NOT IN(SELECT * FROM  @rUser) )


DELETE FROM users WHERE userid NOT IN(SELECT * FROM  @rUser)

Rating People: 13   Average Rating:     

     DnnModule.com is built to provide DNN quality modules and DNN skins, some of them are free, some not. We wish these stuffs (free or not ) can be useful to you.

     Besides that, we also provide a full range of professional services, ranging from web site build, seo, system management, administration, support, senior consultancy and security services. We act as if your development project or network was ours, with care and respect. We are not satisfied until it works the way you want it to, and we don't silently ignore found issues as somebody else's problem.