Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

rename active directory user account

349 views
Skip to first unread message

Rolf Rettinger

unread,
Jul 28, 2003, 2:34:18 PM7/28/03
to
Hi,

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

Thanks

Rolf


Richard Mueller [MVP]

unread,
Jul 28, 2003, 3:08:03 PM7/28/03
to
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
--


Jian-Shen Lin[MS]

unread,
Jul 29, 2003, 4:29:57 AM7/29/03
to
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.

0 new messages