DotNetNuke Powered!
          
John Mitchell's (mostly DotNetNuke) Blog - Error: User Accounts is currently unavailable.
 Wednesday, June 07, 2006

This error is usually due to the aspnet_ membership tables being out of sync with the DotNetNuke Users table.

Here's a way to go about deleting those orphaned Users from the aspnet_* memberRole tables

There are a lot of Referential Integrity constraints on the aspnet_ membership tables that makes it kind of difficult to delete them directly.

This SQL will loop through them all and delete any that are not in the DNN Users table:

DECLARE @UserName varchar (50)

--get a cursor to hold all the orphaned users
--that are in aspnet_Users table that are not in the DNN Users table
DECLARE users_cursor CURSOR FOR
SELECT au.UserName FROM aspnet_Users au
LEFT OUTER JOIN Users u on au.UserName = U.UserName
WHERE U.UserName is null

OPEN users_cursor

-- Perform the first fetch.
FETCH NEXT FROM users_cursor INTO @UserName

-- Check @@FETCH_STATUS to see if there are any more rows to fetch.
WHILE @@FETCH_STATUS = 0
BEGIN
--delete the user from all the aspnet_* tables that it may be in
--one at a time to avoid referrential integrity constraints

delete aspnet_Membership where UserId =
(select am.UserId from aspnet_Membership am inner join aspnet_Users au on am.UserId = au.UserId
where au.Username =@UserName)

delete aspnet_Profile where UserId =
(select ap.UserId from aspnet_Profile ap inner join aspnet_Users au on ap.UserId = au.UserId
where au.Username =@UserName)
delete aspnet_UsersInRoles where UserId
in (select uir.UserId from aspnet_UsersInRoles uir inner join aspnet_Users au on uir.UserId = au.UserId
where au.Username =@UserName)

delete from aspnet_Users where Username =@UserName

FETCH NEXT FROM users_cursor INTO @UserName
END

CLOSE users_cursor
DEALLOCATE users_cursor
GO

6/7/2006 6:35:08 AM (Central Standard Time, UTC-06:00)  #    Comments [9]
9/4/2006 5:25:08 AM (Central Standard Time, UTC-06:00)
Your solution is excellent. Thank you.
11/22/2006 4:30:58 AM (Central Standard Time, UTC-06:00)
Unfortunately, it doesn't work for me. Running

select * from aspnet_Users au left outer join Users u on au.UserName = U.UserName where U.UserName is null

...does not return any results.

My problem has been caused by a third party module which apparently managed to get the tables out of sync.
MVB
11/22/2006 10:03:21 AM (Central Standard Time, UTC-06:00)
If that query does not return any results, then it means there are not any users out of sync. More specifically it means that all the users in the aspnet_Users table are also in the Users table.

The script was only designed to handle that one case because DNN was often creating the user in the aspnet table but erroring out before it got created in the other table.

If the third party module caused this error, then it may be better to get the developer of that module to help you fix it.

Otherwise, you are going to need someone who has a good understanding of how the membership tables relate to each other to look at your specific issue.
12/6/2006 9:35:06 AM (Central Standard Time, UTC-06:00)
Thank ypu very much! It worked perfectly!
12/6/2006 9:39:10 AM (Central Standard Time, UTC-06:00)

Great, I'm glad it helped.
1/8/2007 3:50:48 PM (Central Standard Time, UTC-06:00)
Hello,

thanks for your work. I encountered the same errormessage but your script didn't work.

It seemed in my case, that a missing firstname for one of my users caused this error. I noticed that only if I displayed all users at once or the users beginning with the same first character of this misconfigured user forced this error.
I entered a dummyname directly in the users table an the error was gone.

Maybe that helps others with this problem.

Greet Gordon
Gordon E
1/15/2007 12:25:14 PM (Central Standard Time, UTC-06:00)
Thank you so much for this! My user admin is now functional again.

George
George
1/30/2007 5:14:04 PM (Central Standard Time, UTC-06:00)
Thanks for the script!

However, it did not work in my case.

Similar to Gordon above, my problem was a missing lastname for a user.

Go figure...

Thanks, Gordon!
3/7/2007 2:11:32 AM (Central Standard Time, UTC-06:00)
oh my god you are a life safer you deserve a medal of honor...

no but for real i cant believe i found thsi page and then i never in my life ran ascript in sql on my site....lol first time ever today had my site 2-3 years....had no idea what i was doing but ran it with script went to my user accounts and wallah everything was there, back to normal, i had thousands of users so imagine if i didnt read your post....i was so worried...i am so glad you have this blog, and i appreciate you spending the time to write/have it.

Thank you thank you thank you !!!

email me anytime and if i can help you ever with anything it would be my pleasure.....

:))))
Name
E-mail
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):