HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...Attention - Delete Portal bug - corrupts user accounts which are members of multiple portalsAttention - Delete Portal bug - corrupts user accounts which are members of multiple portals
Previous
 
Next
New Post
11/7/2006 2:11 PM
 

This was noted in DNN 4.3.5. It has been logged in Gemini as DNNP-4463

Suppose User1 is a Registered User on Portals A and B. If Portal B is deleted, this error appears in page after attempting login to Portal A:

Object Reference not set to instance of an object.

User1 is unable to use Portal A from here on. I have tracked the source of the error down to a missing record in aspnet_Membership. If the record is recreated, User1 is able to access Portal A as before.

Before the portal is deleted, User1 has records in the following tables:

  • User (1 record)
  • aspnet_Users (1 record)
  • UserPortals (1 record for Portal A,  1 record for Portal B)
  • aspnet_Membership (1 record for membership of 'DotNetNuke' application)
  • UserRoles (1 record for every role a member of in Portals A & B)

If Portal B is deleted, User1 now has the folowing records:

  • User (1 record)
  • aspnet_Users (1 record)
  • UserPortals (1 record for Portal A)
  • No records in aspnet_Membership *
  • UserRoles (1 record for every role a member of in Portal A)
  • * If the original record is recreated, access is restored.

    This problem seems to affect all users who have membership of Portal A as well as Portal B. Interestingly it does not affect the Host user, whose aspnet_Membership record does not get deleted.

     
    New Post
    11/13/2006 2:18 PM
     
    Hi Laurence,

    I appear to be stuffed here.  How did you recreate the aspnet_Membership record.  I've recreated portal B but I don't seem able to create a user with the same username that I had before? I'm getting the 'A User Already Exists For the Username Specified. Please Register Again Using A Different Username.' message :(

    Cheers

    Barry
     
    New Post
    11/14/2006 4:05 AM
     

    You are probably stuffed. You are getting that message because most of the user account exists, there is just 1 piece missing - the aspnet_Membership record. The trouble is that the aspnet_Membership record contains the user's password in encrypted format (amongst other things), so its not easy to recreate.

    The only reason I was able to recreate the record was that my DNN was version 4.3.5 upgraded from an early 3.x version. In early 3.x versions the aspnet_Membership table contained multiple records for each user, and many of these had been "left behind". In other words the aspnet_Membership record that DNN 4.3.5 needed was gone but there were many other almost identical ones still in the table that I could base my replacement record on.

    Run this SQL query to identify your corrupted user account(s) and also see if it has any old aspnet_Membership records that could be used to recreate the needed aspnet_Membership record:

    select u.*, am2.*
    from users u
    join aspnet_Users au on u.username = au.username
    cross join aspnet_Applications aa
    left join aspnet_Membership am on au.userid = am.userid and aa.applicationid = am.applicationid
    left join aspnet_Membership am2 on au.userid = am2.userid and aa.applicationid <> am2.applicationid
    where aa.applicationname = 'DotNetNuke'
    and am.userid is null

    The columns UserID-UpdatePassword should identify the corrupted user account. If there is data under the next columns (ApplicationID, UserID ......) then you have an old aspnet_Membership record. If so, try running this to use it to recreate the missing one:

    insert aspnet_Membership (ApplicationId,UserId,Password,PasswordFormat,PasswordSalt,MobilePIN,Email,LoweredEmail,PasswordQuestion,PasswordAnswer,IsApproved,IsLockedOut,CreateDate,LastLoginDate,LastPasswordChangedDate,LastLockoutDate,FailedPasswordAttemptCount,FailedPasswordAttemptWindowStart,FailedPasswordAnswerAttemptCount,FailedPasswordAnswerAttemptWindowStart,Comment)
    select distinct aa.ApplicationId,au.UserId,am2.Password,am2.PasswordFormat,am2.PasswordSalt,am2.MobilePIN,u.Email,lower(u.Email) as LoweredEmail,am2.PasswordQuestion,am2.PasswordAnswer,1 as IsApproved,0 as IsLockedOut,am2.CreateDate,am2.LastLoginDate,am2.LastPasswordChangedDate,am2.LastLockoutDate,am2.FailedPasswordAttemptCount,am2.FailedPasswordAttemptWindowStart,am2.FailedPasswordAnswerAttemptCount,am2.FailedPasswordAnswerAttemptWindowStart,am2.Comment
    from users u
    join aspnet_Users au on u.username = au.username
    cross join aspnet_Applications aa
    left join aspnet_Membership am on au.userid = am.userid and aa.applicationid = am.applicationid
    join aspnet_Membership am2 on au.userid = am2.userid and aa.applicationid <> am2.applicationid
    where aa.applicationname = 'DotNetNuke'
    and am.userid is null

    Note that this may restore the account with a password that it had in the past but not its most recent password.

     
    New Post
    11/14/2006 8:21 AM
     
    Hi Laurence, further investigation shows that I *do* have an aspnet_Membership record for that ID, so it appears that the problem that I have, may not be the that one you experienced.

    Thanks for trying to help.
     
    New Post
    11/14/2006 8:56 AM
     
    OK just check it is has an ApplicationID matching the ApplicationID of the record in aspnet_Applications where ApplicationName = 'DotNetNuke'. If it has an ApplicationID matching a different application in aspnet_Applications that is a hangover from an old version of DNN, and is not used in DNN 4.3.5
     
    Previous
     
    Next
    HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...Attention - Delete Portal bug - corrupts user accounts which are members of multiple portalsAttention - Delete Portal bug - corrupts user accounts which are members of multiple portals