Platform SDK: Active Directory, ADSI, and Directory Services

Example Code for Using GetInfo

[Visual Basic]

Dim MyUser as IADsUser
'MyUser will be used to demonstrate implicit GetInfo
Dim MyUser2 as IADsUser
'Myuser2 will show the explicit GetInfo
 
' Bind to a specific user object.
set MyUser = GetObject("LDAP://MyMachine/CN=JeffSmith,DC=Fabrikam,DC=COM")
set MyUser2 = GetObject("LDAP//MyMachine/CN=JeffSmith2,DC=Fabrikam,DC=COM");
 
'Perform some time consuming operations.
 
'Code assumes that the property description has a single value in the directory
' Note that this will IMPLICITLY call GetInfo as 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 the 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 so the most current value is available
MyUser2.GetInfo
 
'Perform time consuming operations
 
'Note that this call is satisfied from the cache has GetInfo has already been called
'explicitly for this object.
Debug.print "MyUser2 has the description set to "; MyUser.Get("Description")