Hi,

how can I rename an active directory user account with vbscript?

Thanks

Rolf

Re: rename active directory user account by Richard

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
--



RE: rename active directory user account by jslin

jslin
Tue Jul 29 03:29:57 CDT 2003

You can do this with the IADsContainer::MoveHere method on the WinNT
provider. Example scripts are on http://adsi.

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.