IT Professionals
Lockergnome
Home
Author Avatar

An Array Of Attributes

Don Jones at MCPmag writes:

Simple attributes are old school; do more with multi-valued attributes in your scripts.

Ready for your Scripting Answers? This time, let me show you how to work with the complex, multi-valued attributes in Active Directory. Unlike nice, simple attributes like name, which contains one and only one value for each user, multi-valued attributes act like arrays, and can contain multiple values. Let’s take the otherHomePhone property as an example. Reading its values works like this:

Set objUser = GetObject _
(”LDAP://cn=donj,ou=Legal, dc=company,dc=com”)
strOtherPhone = objUser.GetEx(”otherHomePhone”)
For Each strValue In strOtherPhone
WScript.Echo strValue
Next

Notice the use of GetEx(), which returns an array of values that the For Each loop walks through one at a time. Need to add a new phone number? Do so as follows:

Const ADS_PROPERTY_APPEND = 3
Set objUser = GetObject _
(”LDAP://cn=donj,ou=Legal, dc=company,dc=com”)
objUser.PutEx ADS_PROPERTY_APPEND, _
“otherHomePhone”, Array(”(123) 555-1212″)
objUser.SetInfo

[Continue reading An Array Of Attributes]

What are your thoughts?

RSS feed for comments on this post · TrackBack URI

All Comments and Trackbacks are moderated (unless you're a registered user). Regardless, this page will refresh when your submission is entered.

*
To prove you're a person (not a spam script), type the security word shown in the picture.
Anti-Spam Image