Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Server > Scripting > Multi-valued strings

Reply
Thread Tools Display Modes

Multi-valued strings

 
 
Mel K
Guest
Posts: n/a

 
      08-28-2008
Hello:



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



Thanks.


--
Regards,
Mel K, MCSA: M


 
Reply With Quote
 
 
 
 
Richard Mueller [MVP]
Guest
Posts: n/a

 
      08-28-2008
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
--


 
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Strings vs. byte[] Richard Mueller [MVP] Active Directory 6 01-25-2008 02:00 PM
how to select from multi valued attribute in Active Directory Thijs Scripting 2 10-03-2007 06:49 AM
administrative limit exceeded for ADAM multi-valued attribute richwray Active Directory 4 08-09-2007 07:08 AM
Is there ~1000 value limit for multi-valued attributes is ADAM? Jayesh Naithani Active Directory 5 01-28-2006 01:59 AM
ADAM: Multi-valued (string) attributes: maximum number of values? Michael Herman \(Parallelspace\) Active Directory 6 11-29-2004 12:28 PM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59