How To Migrate SharePoint Users to a New Domain or New UserName   Leave a comment

It happens, companies buy other companies, companies merge, reinvent and rename themselves. In addition, if you happened to have configured Active Directory accounts using actual names (not a best practice) you may wind up having to change it at some point.  People change their names and thus they want their login ids changed.  Best practice is NOT to associate a person’s name with their Login. Although each AD account get a unique GUID (Global Unique Identifier), most applications relying on Active Directory for authentication use the SAMAccount Name (Your Login ID)  SharePoint is one of these.

Therefore I needed to create an easy and  repeatable process to change either the User’s Domain, or the User’s Login ID.

How It Works:

1. I created a Comma Delimited File (.csv) to contain all of the users that need migrated.

2. I then executed a VB Script (.vbs) that will read this .csv file and execute the STSADM -o MigrateUsers commandlet to migrate the user.  One nice this about this script is that it will produce a log file containing the results of the MigrateUsers commandlet.

Here is the script which I named: SPMigrateUsersUtility.vbs  You will need to edit the first line to locate the Path and
name of the .csv input file.

‘*        Author: Paul D. Fox
‘*          Date: 08/02/2014
‘*           Description: Script to Migrate SharePoint Login ID (tp_LoginID from UserInfo Table)
‘*                                   from One Account to Another.
‘*       Purpose: This VBScript will Read a Comma Delimited Text File (.csv) containing the
‘*                        Old Login ID  (Column A) and the new Login ID (Column B) and then execute
‘*                        the SharePoint 3.0 (12-Hive)  stsadm -o MigrateUser.  When this script is
‘*                        executed, it will create a .log file containing the status of each user migration.
‘* Modifications: MM/DD/YYYY – Description
‘*     Execution: To run this script create a .csv file of the old and new login Ids.  Set the path
‘*                          in this script to point to the .csv file location and execute this .vbs from the
‘*                          “Run Command”.

Const ForReading = 1

Set objFSO = CreateObject(“Scripting.FileSystemObject”)

‘* Set the Path to the .CVS File
Set objTextFile = objFSO.OpenTextFile(“C:\Temp\Pre_Migrated_Users_Log.csv”, ForReading)

Do Until objTextFile.AtEndOfStream
strNextLine = objTextFile.Readline
arrSPUserList = Split(strNextLine , “,”)

‘Wscript.Echo “OldUserName: ” & arrSPUserList(0)

For i = 1 to Ubound(arrSPUserList)
‘Wscript.Echo “NewUserName: ” & arrSPUserList(i)
UpdateADUser arrSPUserList(0), arrSPUserList(i)
Function UpdateADUser( strOldID, strNewID )
‘WScript.Echo “Migrating: ” & strOldID, ” To: ” & strNewID
‘wscript.Echo “%comspec% /c “”C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\STSADM.exe”” -o MigrateUser –

OldLogin ” & strOldID & ” -NewLogin ” &  strNewID & ” -IgnoreSidHistory”

Dim wshShell
Set wshShell = WScript.CreateObject(“”)

wshShell.Run “%comspec% /c echo ” & strOldID & ” >>C:\Temp\SPUserMigration.log 2>&1″, 1, true
wshShell.Run “%comspec% /c “”C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\STSADM.exe”” -o MigrateUser –

OldLogin ” & strOldID & ” -NewLogin ” &  strNewID & ” -IgnoreSidHistory >>C:\Temp\SPUserMigration.log 2>&1″, 1, true

End Function


Here is a sample of the .csv Input File “Pre_Migrated_Users_Log.csv”


Happy SharePointing!

Posted August 18, 2014 by Bismarck in SharePoint 2007

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: