Platform SDK: Active Directory, ADSI, and Directory Services

The GetInfo Method

Call GetInfo to refresh all of an ADSI object's cached properties from the underlying directory service. To refresh specific properties, use GetInfoEx.

ADSI invokes an implicit GetInfo if a Get is performed on a specific property in the property cache and no value is found. Once GetInfo has been called, an implicit call will not be repeated. If a value already exists in the property cache, however, calling Get without first calling GetInfo will retrieve the cached value rather than the most current value from the underlying directory. To obtain the most recent values for an object, always call GetInfo. Any changes you have made in the property cache will be replaced with the current values from the server. If you need to preserve your changes on the server, you should do a SetInfo to save your changes before you do a GetInfo.

Dim MyUser as IADsUser
'MyUser will be used to demonstrate an implicit GetInfo.
Dim MyUser2 as IADsUser
'Myuser2 will show the explicit GetInfo.
 
' Bind to a specific user object.
set MyUser = GetObject("LDAP://MyMachine/CN=JamesSmith,DC=Microsoft,DC=COM")
set MyUser2 = GetObject("LDAP://MyMachine/CN=JamesSmith2,DC=Microsoft,DC=COM");
 
'Code assumes that the property description has a single value in the directory.
'Note that this will IMPLICITLY call GetInfo because at the point this call is made GetInfo
'has not yet been called (implicitly or explicitly) on the MyUser object.
Debug.print "MyUser's description value is "; MyUser.Get("Description")
 
'Since GetInfo has already been called implicitly, this call is satisfied from
'the value in the cache.
Debug.print "MyUser's sAMAccountName is "; MyUser.Get("sAMAccountName")
 
' Refresh the cache explicitly to get the most current value
MyUser2.GetInfo
 
 
'Note that this call is satisfied from the cache because GetInfo has already been called
'explicitly for this object.
Debug.print "MyUser2 has the description set to "; MyUser.Get("Description")