Rename domain admin (VBScript)

This code can be found in Chapter 2 of Windows Server 2003 Security Cookbook

Purchase XP Cookbook or Networking Recipes for only $25 plus shipping! While supplies last.

Find out how to download all of the VBScript code from this site.

' This code renames the domain administrator account.
' ------ SCRIPT CONFIGURATION ------
strParentDN    = "<ParentDN>"    ' e.g. cn=Users,dc=rallencorp,dc=com
strUserOldName = "<OldUserName>" ' e.g. administrator
strUserNewName = "<NewUserName>" ' e.g. mike
' ------ END CONFIGURATION ---------

set objCont = GetObject("LDAP://" & strParentDN)
objCont.MoveHere "LDAP://cn=" & strUserOldName & "," & strParentDN, _
                 "cn=" & strUserNewName
set objUser = GetObject("LDAP://cn=" & strUserNewName & "," & strParentDN)
objUser.Put "sAMAccountName", strUserNewName
objUser.SetInfo
WScript.Echo "Rename successful"

This code has been viewed 1385 times.

New from the creators of TechTasks.com: StatSheet.com