I need to find a way (script?) to change several users in a especial
OU

[displayName] looks like "John Albert Taylor (OPER)"

need to get "only" first name from [displayName] and change the
[givenName] to "John"

need to get "only" middle and last name from [displayName] and change
the [sn] to "Albert Taylor"

can consider the first " (" end of name

can help me ?
thanks!

Re: script to change First Name and Last Name, based on Display Name by Corey

Corey
Thu Feb 28 15:15:38 CST 2008

The [givenName] property isn't already set to the first name?

If that's the case, and all the [displayName]'s are like [firstname]
[middlename] [lastname], then you could use split().
Then get the first element of the array (firstname) and do something
like this:


'=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
arrName =3D split( givenName, " " )


Const ADS_PROPERTY_UPDATE =3D 2
Set objUser =3D GetObject _
("LDAP://cn=3Dmyerken,ou=3Dmanagement,dc=3Dfabrikam,dc=3Dcom")

objUser.Put "givenName", arrName(0)
objUser.SetInfo

'=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

I would take that, wrap it into a sub by passing the ldap path of the
user and given name.
Then you need to loop through the users in that OU, and pass the info
to the sub for each user.

-Corey Thomas
MCSE/MCSA/MCDBA

On Feb 28, 3:06=A0pm, Joao <mendes.j...@gmail.com> wrote:
> I need to find a way (script?) to change several users in a especial
> OU
>
> [displayName] looks like "John Albert Taylor (OPER)"
>
> need to get "only" first name from [displayName] and change the
> [givenName] to "John"
>
> need to get "only" middle and last name from [displayName] and change
> the [sn] to "Albert Taylor"
>
> can consider the first " (" end of name
>
> can help me ?
> thanks!


Re: script to change First Name and Last Name, based on Display Name by Joao

Joao
Thu Feb 28 15:32:14 CST 2008

On 28 Fev, 21:15, Corey Thomas <coreytho...@gmail.com> wrote:
> The [givenName] property isn't already set to the first name?
>
> If that's the case, and all the [displayName]'s are like [firstname]
> [middlename] [lastname], then you could use split().
> Then get the first element of the array (firstname) and do something
> like this:
>
> '=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> arrName =3D split( givenName, " " )
>
> Const ADS_PROPERTY_UPDATE =3D 2
> Set objUser =3D GetObject _
> =A0 =A0("LDAP://cn=3Dmyerken,ou=3Dmanagement,dc=3Dfabrikam,dc=3Dcom")
>
> objUser.Put "givenName", arrName(0)
> objUser.SetInfo
>
> '=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>
> I would take that, wrap it into a sub by passing the ldap path of the
> user and given name.
> Then you need to loop through the users in that OU, and pass the info
> to the sub for each user.
>
> -Corey Thomas
> MCSE/MCSA/MCDBA
>
> On Feb 28, 3:06=A0pm, Joao <mendes.j...@gmail.com> wrote:
>
>
>
> > I need to find a way (script?) to change several users in a especial
> > OU
>
> > [displayName] looks like "John Albert Taylor (OPER)"
>
> > need to get "only" first name from [displayName] and change the
> > [givenName] to "John"
>
> > need to get "only" middle and last name from [displayName] and change
> > the [sn] to "Albert Taylor"
>
> > can consider the first " (" end of name
>
> > can help me ?
> > thanks!- Ocultar texto citado -
>
> - Mostrar texto citado -

only the [displayName] has the "good" name information, the
[givenName] & [sn] need be changed...

Re: script to change First Name and Last Name, based on Display Name by Corey

Corey
Thu Feb 28 16:47:00 CST 2008

To set the last name:

objUser.Put "sn", arrName(2) 'if the array includes first, middle,
last name

On Feb 28, 4:32=A0pm, Joao <mendes.j...@gmail.com> wrote:
> On 28 Fev, 21:15, Corey Thomas <coreytho...@gmail.com> wrote:
>
>
>
>
>
> > The [givenName] property isn't already set to the first name?
>
> > If that's the case, and all the [displayName]'s are like [firstname]
> > [middlename] [lastname], then you could use split().
> > Then get the first element of the array (firstname) and do something
> > like this:
>
> > '=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> > arrName =3D split( givenName, " " )
>
> > Const ADS_PROPERTY_UPDATE =3D 2
> > Set objUser =3D GetObject _
> > =A0 =A0("LDAP://cn=3Dmyerken,ou=3Dmanagement,dc=3Dfabrikam,dc=3Dcom")
>
> > objUser.Put "givenName", arrName(0)
> > objUser.SetInfo
>
> > '=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>
> > I would take that, wrap it into a sub by passing the ldap path of the
> > user and given name.
> > Then you need to loop through the users in that OU, and pass the info
> > to the sub for each user.
>
> > -Corey Thomas
> > MCSE/MCSA/MCDBA
>
> > On Feb 28, 3:06=A0pm, Joao <mendes.j...@gmail.com> wrote:
>
> > > I need to find a way (script?) to change several users in a especial
> > > OU
>
> > > [displayName] looks like "John Albert Taylor (OPER)"
>
> > > need to get "only" first name from [displayName] and change the
> > > [givenName] to "John"
>
> > > need to get "only" middle and last name from [displayName] and change
> > > the [sn] to "Albert Taylor"
>
> > > can consider the first " (" end of name
>
> > > can help me ?
> > > thanks!- Ocultar texto citado -
>
> > - Mostrar texto citado -
>
> only the [displayName] has the "good" name information, the
> [givenName] & [sn] need be changed...- Hide quoted text -
>
> - Show quoted text -


Re: script to change First Name and Last Name, based on Display Name by Richard

Richard
Thu Feb 28 22:13:17 CST 2008

Joao wrote:

>I need to find a way (script?) to change several users in a especial
> OU
>
> [displayName] looks like "John Albert Taylor (OPER)"
>
> need to get "only" first name from [displayName] and change the
> [givenName] to "John"
>
> need to get "only" middle and last name from [displayName] and change
> the [sn] to "Albert Taylor"
>
> can consider the first " (" end of name
>
> can help me ?

Names can be very difficult to parse. You cannot assume that everyone has a
middle name. I have seen users with names like M. Elizabeth Johnson. Some
people may have Jr. or Sr. There are many forms. I might try code similar
to:
===========
' Bind to OU.
Set objOU = GetObject("LDAP://ou=Sales,ou=West,dc=MyDomain,dc=com")

' Enumerate all users in the OU.
objOU.Filter = Array("user")
For Each objUser In objOU
' Retrieve display name.
strDisplayName = objUser.displayName

' Parse full name.
intIndex = Instr(strDisplayName, " (")
strName = Left(strDisplayName, intIndex - 1)
arrNames = Split(strName, " ")
' Determine first and last names.
strFirst = arrNames(0)
strLast = ""
For k = 1 To UBound(arrNames)
If (k = 1) Then
strLast = arrNames(k)
Else
strLast = strLast & " " & arrNames(k)
End If
Next
' Assign first and last names.
objUser.givenName = strFirst
objUser.sn = strLast
objUser.SetInfo
Next

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



Re: script to change First Name and Last Name, based on Display Name by Joao

Joao
Fri Feb 29 07:46:58 CST 2008

On 29 fev, 04:13, "Richard Mueller [MVP]" <rlmueller-
nos...@ameritech.nospam.net> wrote:
> Joao wrote:
> >I need to find a way (script?) to change several users in a especial
> > OU
>
> > [displayName] looks like "John Albert Taylor (OPER)"
>
> > need to get "only" first name from [displayName] and change the
> > [givenName] to "John"
>
> > need to get "only" middle and last name from [displayName] and change
> > the [sn] to "Albert Taylor"
>
> > can consider the first " (" end of name
>
> > can help me ?
>
> Names can be very difficult to parse. You cannot assume that everyone has =
a
> middle name. I have seen users with names like M. Elizabeth Johnson. Some
> people may have Jr. or Sr. There are many forms. I might try code similar
> to:
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> ' Bind to OU.
> Set objOU =3D GetObject("LDAP://ou=3DSales,ou=3DWest,dc=3DMyDomain,dc=3Dco=
m")
>
> ' Enumerate all users in the OU.
> objOU.Filter =3D Array("user")
> For Each objUser In objOU
> =A0 =A0 ' Retrieve display name.
> =A0 =A0 strDisplayName =3D objUser.displayName
>
> =A0 =A0 ' Parse full name.
> =A0 =A0 intIndex =3D Instr(strDisplayName, " (")
> =A0 =A0 strName =3D Left(strDisplayName, intIndex - 1)
> =A0 =A0 arrNames =3D Split(strName, " ")
> =A0 =A0 ' Determine first and last names.
> =A0 =A0 strFirst =3D arrNames(0)
> =A0 =A0 strLast =3D ""
> =A0 =A0 For k =3D 1 To UBound(arrNames)
> =A0 =A0 =A0 =A0 If (k =3D 1) Then
> =A0 =A0 =A0 =A0 =A0 =A0 strLast =3D arrNames(k)
> =A0 =A0 =A0 =A0 Else
> =A0 =A0 =A0 =A0 =A0 =A0 strLast =3D strLast & " " & arrNames(k)
> =A0 =A0 =A0 =A0 End If
> =A0 =A0 Next
> =A0 =A0 ' Assign first and last names.
> =A0 =A0 objUser.givenName =3D strFirst
> =A0 =A0 objUser.sn =3D strLast
> =A0 =A0 objUser.SetInfo
> Next
>
> --
> Richard Mueller
> Microsoft MVP Scripting and ADSI
> Hilltop Lab -http://www.rlmueller.net
> --

many thanks!