E-Mail:
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 Do You Think?

 


Anti-Spam Image

Want to Start a Blog Here for Free?

Are you an expert in one subject or another? If your goal is to help others and dispense hard-earned information back to the community, stake a claim on your very own Lockergnome blog today! You can write about anything - no matter the topic. Sign-up to start blogging!

Author Avatar
GnomeREPORT - Jul 18, 2008

It Is Windows Only Smaller

Author Avatar
Resources - Jul 10, 2008

Continuity Insights