| Platform SDK: Active Directory, ADSI, and Directory Services |
Some properties are returned with multiple values, that is, they can contain one or more values. For instance, a list of descriptions on a domain is a property with multiple values. You can retrieve a property with multiple values as an array using the IADs::GetEx function.
IADs::GetEx gets properties with single or multiple values in VARIANT structures from the property cache. Finding no value in the cache invokes an implicit IADs::GetInfoEx.
Dim obj As IADs
Dim objList As Variant
Set obj = GetObject("LDAP://MyMachine/CN=Administrator,CN=Users,DC=Microsoft,DC=com")
objList = obj.GetEx("description")
For Each Desc In objList
' Print the descriptions
Debug.Print (Desc)
Next
IADs::GetEx always returns a variant array of variants regardless of the number of values returned from the server. This is true when a multiple valued attribute contains single or multiple values.
' --- Multiple valued attribute ---
Set usr = GetObject("LDAP://CN=jsmith, OU=Sales, DC=Microsoft, DC=COM")
homePhones = usr.GetEx("otherHomePhone")
For each phone in homePhones
Debug.Print phone
Next
You can also use IADs::GetEx for an attribute with a single value.
Set usr = GetObject("LDAP://CN=jsmith, OU=Sales, DC=Microsoft, DC=COM")
sds = usr.GetEx("ntSecurityDescriptor")
For each sd in sds
Set acl = sd.DiscretionaryACL
Next