From: Mark on
I am trying to write a script to manage leavers.

I can not find an attribute or method to modify the ?Name? field used to
display a users name in ADUC. The cn, distinguisedName and name attributes
are RDN?s and can not be directly modified.

In the ADUC GUI, it is possible to double click on the ?Name? of the user
object and modify it. You are subsequently prompted with a popup showing the
Last name, First name, Display name + other attributes. The one of interest
to me is the ?Full name? field. Once you confirm this popup, the cn, name and
distinguishedName attributes of the user object are modified.

I would like to programmatically append text eg. ??Leaver? to this field but
I am struggling to find out how.

You help would be much appreciated.

Mark

From: Richard Mueller on
Mark wrote:

>I am trying to write a script to manage leavers.
>
> I can not find an attribute or method to modify the ?Name? field used to
> display a users name in ADUC. The cn, distinguisedName and name attributes
> are RDN?s and can not be directly modified.
>
> In the ADUC GUI, it is possible to double click on the ?Name? of the user
> object and modify it. You are subsequently prompted with a popup showing
> the
> Last name, First name, Display name + other attributes. The one of
> interest
> to me is the ?Full name? field. Once you confirm this popup, the cn, name
> and
> distinguishedName attributes of the user object are modified.
>
> I would like to programmatically append text eg. ??Leaver? to this field
> but
> I am struggling to find out how.
>
> You help would be much appreciated.

Hi,

To modify the RDN of an object, bind to the parent container (the OU or
container the user is in) and invoke the MoveHere method. For example:

strUserDN = "cn=Joe User,ou=Sales,ou=West,dc=MyDomain,dc=com"
Set objUser = GetObject("LDAP://" & strUserDN)
Set objParent = GetObject(objUser.Parent)
objParent.MoveHere objUser.AdsPath, objUser.Name & "...Leaver"

which is equivalent to:

Set objParent = GetObject("LDAP://ou=Sales,ou=West,dc=MyDomain,dc=com")
objParent.MoveHere "LDAP://cn=Joe User,ou=Sales,ou=West,dc=MyDomain,dc=com",
"cn=Joe User...Leaver"

Note, in the above example:
RDN (Relative Distinguished Name) is "cn=Joe User"
cn (Common Name) is "Joe User"
Distinguished Name (DN) is "cn=Joe User,ou=Sales,ou=West,dc=MyDomain,dc=com"
AdsPath is "LDAP://cn=Joe User,ou=Sales,ou=West,dc=MyDomain,dc=com"
Full Name in ADUC when you create or rename the user is cn "Joe User"
Display Name in ADUC, which is the same as "Full Name" exposed by the WinNT
provider, is the value of the displayName attribute, which is entirely
different.

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


From: Mark on
Thanks for the advice Richard.

I will try the MoveHere method in my testlab when i get back to the office
in the morning.

Based on the syntax provided, if my script contains the following extract.

objLeaverOU = getobject( "LDAP://ou=Leavers,ou,myusers,dc=MyDomain,dc=com")
for each colUser in objLeaverOU
strleaverDN = colUser.distinguishedName
objUser= getobject ("LDAP://" & strLeaverDN)
objLeaverOU.MoveHere objUser.ADsPath, objUser.Name & "...Leaver.." & date
Next

This should append leaver and the processed date to the cn for each user in
the Leavers OU and the resulting display in the ADUC Name column would look
like "Blogs, Joe...Leaver..28/02/06" (UK date format)

Once again, thanks for the help.

And a thanks for the script sugestions on your site. I used yours as a
reference when I first started to write scripts.

Mark
"Richard Mueller" wrote:

> Mark wrote:
>
> >I am trying to write a script to manage leavers.
> >
> > I can not find an attribute or method to modify the ?Name? field used to
> > display a users name in ADUC. The cn, distinguisedName and name attributes
> > are RDN?s and can not be directly modified.
> >
> > In the ADUC GUI, it is possible to double click on the ?Name? of the user
> > object and modify it. You are subsequently prompted with a popup showing
> > the
> > Last name, First name, Display name + other attributes. The one of
> > interest
> > to me is the ?Full name? field. Once you confirm this popup, the cn, name
> > and
> > distinguishedName attributes of the user object are modified.
> >
> > I would like to programmatically append text eg. ??Leaver? to this field
> > but
> > I am struggling to find out how.
> >
> > You help would be much appreciated.
>
> Hi,
>
> To modify the RDN of an object, bind to the parent container (the OU or
> container the user is in) and invoke the MoveHere method. For example:
>
> strUserDN = "cn=Joe User,ou=Sales,ou=West,dc=MyDomain,dc=com"
> Set objUser = GetObject("LDAP://" & strUserDN)
> Set objParent = GetObject(objUser.Parent)
> objParent.MoveHere objUser.AdsPath, objUser.Name & "...Leaver"
>
> which is equivalent to:
>
> Set objParent = GetObject("LDAP://ou=Sales,ou=West,dc=MyDomain,dc=com")
> objParent.MoveHere "LDAP://cn=Joe User,ou=Sales,ou=West,dc=MyDomain,dc=com",
> "cn=Joe User...Leaver"
>
> Note, in the above example:
> RDN (Relative Distinguished Name) is "cn=Joe User"
> cn (Common Name) is "Joe User"
> Distinguished Name (DN) is "cn=Joe User,ou=Sales,ou=West,dc=MyDomain,dc=com"
> AdsPath is "LDAP://cn=Joe User,ou=Sales,ou=West,dc=MyDomain,dc=com"
> Full Name in ADUC when you create or rename the user is cn "Joe User"
> Display Name in ADUC, which is the same as "Full Name" exposed by the WinNT
> provider, is the value of the displayName attribute, which is entirely
> different.
>
> --
> Richard
> Microsoft MVP Scripting and ADSI
> Hilltop Lab - http://www.rlmueller.net
>
>
>
From: Richard Mueller on
Mark,

You can simplify your snippet a bit. colUser is already an object reference,
so there is no need to bind to the user object again.

objLeaverOU = getobject( "LDAP://ou=Leavers,ou,myusers,dc=MyDomain,dc=com")
for each colUser in objLeaverOU
objLeaverOU.MoveHere colUser.ADsPath, colUser.Name & "...Leaver.." &
CStr(date)
Next

--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
"Mark" <mark(a)nowhere.com> wrote in message
news:56E90BFA-15C9-46F2-84CA-09F24D9530F5(a)microsoft.com...
> Thanks for the advice Richard.
>
> I will try the MoveHere method in my testlab when i get back to the office
> in the morning.
>
> Based on the syntax provided, if my script contains the following extract.
>
> objLeaverOU = getobject(
> "LDAP://ou=Leavers,ou,myusers,dc=MyDomain,dc=com")
> for each colUser in objLeaverOU
> strleaverDN = colUser.distinguishedName
> objUser= getobject ("LDAP://" & strLeaverDN)
> objLeaverOU.MoveHere objUser.ADsPath, objUser.Name & "...Leaver.." &
> date
> Next
>
> This should append leaver and the processed date to the cn for each user
> in
> the Leavers OU and the resulting display in the ADUC Name column would
> look
> like "Blogs, Joe...Leaver..28/02/06" (UK date format)
>
> Once again, thanks for the help.
>
> And a thanks for the script sugestions on your site. I used yours as a
> reference when I first started to write scripts.
>
> Mark
> "Richard Mueller" wrote:
>
>> Mark wrote:
>>
>> >I am trying to write a script to manage leavers.
>> >
>> > I can not find an attribute or method to modify the ?Name? field used
>> > to
>> > display a users name in ADUC. The cn, distinguisedName and name
>> > attributes
>> > are RDN?s and can not be directly modified.
>> >
>> > In the ADUC GUI, it is possible to double click on the ?Name? of the
>> > user
>> > object and modify it. You are subsequently prompted with a popup
>> > showing
>> > the
>> > Last name, First name, Display name + other attributes. The one of
>> > interest
>> > to me is the ?Full name? field. Once you confirm this popup, the cn,
>> > name
>> > and
>> > distinguishedName attributes of the user object are modified.
>> >
>> > I would like to programmatically append text eg. ??Leaver? to this
>> > field
>> > but
>> > I am struggling to find out how.
>> >
>> > You help would be much appreciated.
>>
>> Hi,
>>
>> To modify the RDN of an object, bind to the parent container (the OU or
>> container the user is in) and invoke the MoveHere method. For example:
>>
>> strUserDN = "cn=Joe User,ou=Sales,ou=West,dc=MyDomain,dc=com"
>> Set objUser = GetObject("LDAP://" & strUserDN)
>> Set objParent = GetObject(objUser.Parent)
>> objParent.MoveHere objUser.AdsPath, objUser.Name & "...Leaver"
>>
>> which is equivalent to:
>>
>> Set objParent = GetObject("LDAP://ou=Sales,ou=West,dc=MyDomain,dc=com")
>> objParent.MoveHere "LDAP://cn=Joe
>> User,ou=Sales,ou=West,dc=MyDomain,dc=com",
>> "cn=Joe User...Leaver"
>>
>> Note, in the above example:
>> RDN (Relative Distinguished Name) is "cn=Joe User"
>> cn (Common Name) is "Joe User"
>> Distinguished Name (DN) is "cn=Joe
>> User,ou=Sales,ou=West,dc=MyDomain,dc=com"
>> AdsPath is "LDAP://cn=Joe User,ou=Sales,ou=West,dc=MyDomain,dc=com"
>> Full Name in ADUC when you create or rename the user is cn "Joe User"
>> Display Name in ADUC, which is the same as "Full Name" exposed by the
>> WinNT
>> provider, is the value of the displayName attribute, which is entirely
>> different.
>>
>> --
>> Richard
>> Microsoft MVP Scripting and ADSI
>> Hilltop Lab - http://www.rlmueller.net
>>
>>
>>


From: Mark on
Thanks again Richard,

Thats another thing I didn't know. Thats what comes with self education. You
only know what you discover along the way. You usually miss the the useful
little nugets and get stuck in a rut not knowing the way out.


Mark

"Richard Mueller" wrote:

> Mark,
>
> You can simplify your snippet a bit. colUser is already an object reference,
> so there is no need to bind to the user object again.
>
> objLeaverOU = getobject( "LDAP://ou=Leavers,ou,myusers,dc=MyDomain,dc=com")
> for each colUser in objLeaverOU
> objLeaverOU.MoveHere colUser.ADsPath, colUser.Name & "...Leaver.." &
> CStr(date)
> Next
>
> --
> Richard
> Microsoft MVP Scripting and ADSI
> Hilltop Lab - http://www.rlmueller.net
> "Mark" <mark(a)nowhere.com> wrote in message
> news:56E90BFA-15C9-46F2-84CA-09F24D9530F5(a)microsoft.com...
> > Thanks for the advice Richard.
> >
> > I will try the MoveHere method in my testlab when i get back to the office
> > in the morning.
> >
> > Based on the syntax provided, if my script contains the following extract.
> >
> > objLeaverOU = getobject(
> > "LDAP://ou=Leavers,ou,myusers,dc=MyDomain,dc=com")
> > for each colUser in objLeaverOU
> > strleaverDN = colUser.distinguishedName
> > objUser= getobject ("LDAP://" & strLeaverDN)
> > objLeaverOU.MoveHere objUser.ADsPath, objUser.Name & "...Leaver.." &
> > date
> > Next
> >
> > This should append leaver and the processed date to the cn for each user
> > in
> > the Leavers OU and the resulting display in the ADUC Name column would
> > look
> > like "Blogs, Joe...Leaver..28/02/06" (UK date format)
> >
> > Once again, thanks for the help.
> >
> > And a thanks for the script sugestions on your site. I used yours as a
> > reference when I first started to write scripts.
> >
> > Mark
> > "Richard Mueller" wrote:
> >
> >> Mark wrote:
> >>
> >> >I am trying to write a script to manage leavers.
> >> >
> >> > I can not find an attribute or method to modify the ?Name? field used
> >> > to
> >> > display a users name in ADUC. The cn, distinguisedName and name
> >> > attributes
> >> > are RDN?s and can not be directly modified.
> >> >
> >> > In the ADUC GUI, it is possible to double click on the ?Name? of the
> >> > user
> >> > object and modify it. You are subsequently prompted with a popup
> >> > showing
> >> > the
> >> > Last name, First name, Display name + other attributes. The one of
> >> > interest
> >> > to me is the ?Full name? field. Once you confirm this popup, the cn,
> >> > name
> >> > and
> >> > distinguishedName attributes of the user object are modified.
> >> >
> >> > I would like to programmatically append text eg. ??Leaver? to this
> >> > field
> >> > but
> >> > I am struggling to find out how.
> >> >
> >> > You help would be much appreciated.
> >>
> >> Hi,
> >>
> >> To modify the RDN of an object, bind to the parent container (the OU or
> >> container the user is in) and invoke the MoveHere method. For example:
> >>
> >> strUserDN = "cn=Joe User,ou=Sales,ou=West,dc=MyDomain,dc=com"
> >> Set objUser = GetObject("LDAP://" & strUserDN)
> >> Set objParent = GetObject(objUser.Parent)
> >> objParent.MoveHere objUser.AdsPath, objUser.Name & "...Leaver"
> >>
> >> which is equivalent to:
> >>
> >> Set objParent = GetObject("LDAP://ou=Sales,ou=West,dc=MyDomain,dc=com")
> >> objParent.MoveHere "LDAP://cn=Joe
> >> User,ou=Sales,ou=West,dc=MyDomain,dc=com",
> >> "cn=Joe User...Leaver"
> >>
> >> Note, in the above example:
> >> RDN (Relative Distinguished Name) is "cn=Joe User"
> >> cn (Common Name) is "Joe User"
> >> Distinguished Name (DN) is "cn=Joe
> >> User,ou=Sales,ou=West,dc=MyDomain,dc=com"
> >> AdsPath is "LDAP://cn=Joe User,ou=Sales,ou=West,dc=MyDomain,dc=com"
> >> Full Name in ADUC when you create or rename the user is cn "Joe User"
> >> Display Name in ADUC, which is the same as "Full Name" exposed by the
> >> WinNT
> >> provider, is the value of the displayName attribute, which is entirely
> >> different.
> >>
> >> --
> >> Richard
> >> Microsoft MVP Scripting and ADSI
> >> Hilltop Lab - http://www.rlmueller.net
> >>
> >>
> >>
>
>
>