Re: AD user rename

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Toma¾ Kralj wrote:

> Hi,
>
> I found way to change cn and name.
>
>
> I added following code:
>
> vmoj=usr.get("name")
> Set newobj = oTargetOU.MoveHere("LDAP://cn="; & vmoj & ","& strTargetOU
> ,"cn=" & vFullname)
>
>
> It works. At the same time cn and name is changed.
>
> Just when script is done I get error:
> C:\chgupn-4.vbs(40, 7) (null): There is no such object on the server.

Hi,

Name is actually a property method that returns the Relative Distinguished
Name (RDN) of the object. For user objects, this is the "cn" (Common Name)
attribute, with "cn=" appended. Thus, it returns the first part of the
distinguishedName.

I believe your vmoj variable will be in the form "cn=jsmith", so "cn=" is
repeated. Try:

Set newobj = oTargetOU.MoveHere("LDAP://"; & vmoj & "," & strTargetOU, "cn="
& vFullName)

Or, you can use the distinguishedName attribute of the user object. For
example:

Set newobj = oTargetOU.MoveHere("LDAP://"; & usr.distinguishedName, "cn=" &
vFullName)

--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab web site - http://www.rlmueller.net
--


.



Relevant Pages

  • Re: Change display names of AD users
    ... oTargetOU.MoveHere(usr.AdsPath, "cn=" & vFullName) ... it happily changes the display name field within the ... and assuming that all users are in the container whose Distinguished ... > Note that the distinguishedName of the object includes the Relative ...
    (microsoft.public.windows.server.scripting)
  • Re: Querying AD with the LIKE operator
    ... Wildcards are not allowed when filtering/querying on distinguishedName. ... Richard ... Microsoft MVP Scripting and ADSI ... > If I change the query command to: ...
    (microsoft.public.scripting.vbscript)
  • Re: Question about .MoveHere method
    ... you should not be able to modify the distinguishedName attribute directly. ... > Hi Richard, ... > i think this should be done in .MoveHere method. ... >> Microsoft MVP Scripting and ADSI ...
    (microsoft.public.scripting.vbscript)