Richard
Mon Jul 28 14:08:03 CDT 2003
Rolf Rettinger wrote:
> 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
--