Platform SDK: Active Directory, ADSI, and Directory Services

Optimization Using GetInfoEx

GetInfoEx is called explicitly to refresh some of an ADSI object's cached properties from the underlying namespace. To refresh all the properties, use GetInfo.

GetInfoEx gets specific current values for the properties of an Active Directory object from the underlying directory store, refreshing the cached values.

Dim PropArray As Variant
Dim Prop As Variant
Dim DescList As Variant
Dim obj As IADs
 
Set obj = GetObject("LDAP://MyMachine")
 
' Initialize the array of properties to pass to GetInfoEx.
PropArray = Array("description", "distinguishedName")
 
' Make the array a single variant for passing to GetInfoEx.
Prop = PropArray
 
' Get just the description and DN properties.
obj.GetInfoEx Prop, 0
 
DescList = obj.Get("description")
 
' Enumerate the descriptions.
For Each Desc In DescList
    ' Print the descriptions.
    Debug.Print (Desc)
Next

Calling GetInfoEx after changing property values, but before calling SetInfo, results in losing those changed values. After this call, the cache reflects the property values in the underlying namespace directory store. However, the cache is only updated with the values specifically requested in the GetInfoEx call. Some servers will not return all properties of an object in response to a GetInfo call; you must do an explicit GetInfoEx call naming these "non-default" properties in order to get them into the cache.