Mel wrote:
>
> How can I get the first value of a multi-valued string in VBS? I'm trying
> to get the first (and only) entry in the canonicalName property of an AD
> user object. I'm trying to do something like this:
>
>
>
> strSomeString = objADUser.canonicalName
>
You treat multi-valued attributes similar to arrays. However, an additional
factor is that canonicalName is constructed (also called operational). You
must use the GetInfoEx method to retrieve the values, then the GetEx method
to enumerate them. For example:
====
Set objUser = GetObject("LDAP://cn=Jim Smith,ou=West,dc=MyDomain,dc=com")
objUser.GetInfoEx Array("canonicalName"), 0
For Each strValue in objUser.GetEx("canonicalName")
Wscript.Echo strValue
Next
========
Note that there is no order to the values in a multi-valued attribute, so
you cannot say which is the first. Also, the above would raise an error on
the GetEx method if the array had no values. The code assumes that all user
objects have at least one value.
--
Richard Mueller
MVP Directory Services
Hilltop Lab -
http://www.rlmueller.net
--