Announcement

Collapse
No announcement yet.

Remaning user login name

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Remaning user login name

    Hi all,

    Is there a way to rename users login name in winddows 2003 domain.
    I have got a request from my management team to rename around 500 users login (sAMAccount name & pre windows 2000). I have both old login IDs & new Login IDs. I want to do this because I want to preserve group membership of the users otherwise it will be tedious to assign group membership manaually to 500 users.

    Regards
    W

  • #2
    Re: Remaning user login name

    Hi,

    You wrote that you have both 'old login' IDs & 'new Login' IDs.
    How is that information available, is it in a CSV-file? what value format.


    I think you want to change these attributes of each of the userobjects:
    1. "UserPrincipalName" (account Logon name + upnsuffix)
    2. "sAMAccount" (account Logon name pre windows 2000)
    3. "RDN" (Relative distinguished name = object name unique per OU)"

    example of a script, that uses a csv-file:
    Code:
    'note: Better to close ADUC (dsa.msc) before running this script!
    
    strParentDN = "ou=Users, ou=Test container, dc=Domain, dc=Local"
    
    Const FOR_READING = 1
    '----------------------------------------------------------------------
    strInputFile = "ChangeAccountNames.csv"
    
    '            csv format:
    '            OldAccountName, NewAccountName, DefaultUPN-Suffix
    '----------------------------------------------------------------------
    
    'On Error Resume Next
    
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objText = objFSO.OpenTextFile(strInputFile, FOR_READING)
    
    Do while objText.AtEndofStream <> True
    
       rline = objText.readline
       arrUser = Split(rline,",")
    
       strOldAccountName   = Trim(arrUser(0))
       strNewAccountName   = Trim(arrUser(1))
       strDefaultUPNSuffix = Trim(arrUser(2))
    
       set objCont = GetObject("LDAP://" & strParentDN)
       objCont.MoveHere "LDAP://cn=" & strOldAccountName & "," & strParentDN, _
                        "cn=" & strNewAccountName
    
       set objUser = GetObject("LDAP://cn=" & strNewAccountName & "," & strParentDN)
    
       objUser.Put "sAMAccountName", strNewAccountName
       objUser.Put "UserPrincipalName", strNewAccountName & strDefaultUPNSuffix
    
       objUser.SetInfo
    
    Loop
    
    objText.Close
    
    WScript.Echo "Rename successful"
    WScript.Quit
    Test the script FIRST on test users in a test OU !


    \Rems

    This posting is provided "AS IS" with no warranties, and confers no rights.

    __________________

    ** Remember to give credit where credit's due **
    and leave Reputation Points for meaningful posts

    Comment

    Working...
    X