LDAP issue: AD username changed when married or divorced - lost user profile data

I recently ran across an issue with the LDAP module. When a username changes, the profile data is no longer associated with the new username. The scenario is fairly common for women as when they get married or divorced a lot of the time their last name is changed. At my company we don't just change the underlying data to reflect the name, but we change the username as well. This presented a problem as an employee complained that their profile data (all custom profile fields) was no longer populated. Luckily the profile data is still stored in the database, however the connection to an active user no longer exists which means you can't get access to the data via Sitecore's user manager.

I'm not sure if many have taken a look at the underlying .NET Membership tables that Sitecore uses for storing profile data, but the profile data is serialized so that one can't simply query the database and see the field values. This makes it a little tricky to recover the profile data from the various fields.

The table: aspnet_Profile  
The fields: PropertyNames

So here is what you need to do:
1) Query aspnet_Users for the UserId - both the new id and the old id.

select * from [YourCoreDatabase].[dbo].[aspnet_Users]
where LoweredUserName = 'domain\lower-case-username'

2) Verify that the profile data actual exists

SELECT * FROM [YourCoreDatabase].[dbo].[aspnet_Profile] WHERE [UserId] = 'new-GUID'

SELECT * FROM [YourCoreDatabase].[dbo].[aspnet_Profile] WHERE [UserId] = 'old-GUID'

3) Update the new user's profile fields with the values from the old user profile
UPDATE [YourCoreDatabase].[dbo].[aspnet_Profile] 
SET [PropertyNames] = 
         (select [PropertyNames] from [YourCoreDatabase].[dbo].[aspnet_Profile] where [UserId] = 'OLDID'), 
       [PropertyValuesBinary] = 
         (select [PropertyValuesBinary] from [YourCoreDatabase].[dbo].[aspnet_Profile] where [UserId] = 'OLDID') 
WHERE [UserId] = 'NEWID' 

Problem solved! Hope this helps anyone who comes across this issue!


  1. Would the use of Sitecore PowerShell Extensions (SPE) also meet the need? I came up with this gist to demonstrate.



Post a Comment