how can I rename an active directory user account with vbscript?
Thanks
Rolf
> how can I rename an active directory user account with vbscript?
>
Hi,
To change the sAMAccountName or userPrincipalName attributes, you just
assign new values. However, to change the cn (common name) attribute you
need to use the MoveHere method of the container object. You must bind to
the parent container. For example:
Set objUser = GetObject("LDAP://cn=Testuser,ou=Sales,dc=MyDomain,dc=com")
Set objContainer = GetObject(objUser.Parent)
Set objNewUser = objContainer.MoveHere(objUser.AdsPath, "cn=NewName")
--
Richard
Microsoft MVP Scripting and ADSI
HilltopLab web site - http://www.rlmueller.net
--
Rename a User
Set dom = GetObject("WinNT://INDEPENDENCE")
Set usr = dom.MoveHere("WinNT://INDEPENDENCE/jsmith,user", "jjohnson")
usr.FullName = "Jane Johnson"
usr.SetInfo
Thanks,
Jian Shen
This posting is provided "AS IS" with no warranties, and confers no rights.