How to get SharePoint back in sync when you change a user’s sAMAccountName

sharepointsharepoint-2010

I have observed on SharePoint 2010 that if you change the sAMAccountName of a user after the user has logged into a SharePoint site collection, the tp_Login field in the UserInfo table does not get updated. It still has the old user Id.

While the user can log into SharePoint under the new account, these new logins do not update the table. I have code that looks at the SPUser.LoginName and this value appears to be the tp_Login field value which is now old. The fact that this value is old causes my code to fail.

I suspect this behavior is identical in SharePoint 2007.

Is there any way to force SharePoint to recognize the new sAMAccountName? I suspect that profile synchronization might help, but I would like for my solution to work with WSS 3.0 and SharePoint 2010 Foundation.

I considered manually updating the database table, but I would like to stick with supported approaches.

Best Answer

This should solve it for you. It must be run as the sharepoint admin. In the past I have found that this doesn't work in every scenario and that occasionally the sharepoint dev team had to fix users manually.

stsadm.exe -o migrateuser -oldlogin -newlogin [-ignoresidhistory]

Related Topic