Export (0) Print
Expand All

Making Explicit Calls by Using the GetInfo Method

Microsoft® Windows® 2000 Scripting Guide

You can explicitly call the GetInfo method to load or refresh the local property cache. When called explicitly, this method retrieves all attributes (except for operational attributes) associated with an object from Active Directory and loads them into the local property cache. Call the GetInfo method if you need to be sure that the attribute values in the local property cache are the same as the attribute values of the corresponding Active Directory object.

The syntax for the GetInfo method is:



object.GetInfo


The script in Listing 5.21 downloads most attributes of a group object named Atl-Users.

  1. Bind to the Atl-Users group in the HR OU of the na.fabrikam.com domain.

  2. Use the GetInfo method to explicitly download most of the group's attributes into the local property cache.

Listing 5.21 Making an Explicit Call to GetInfo

  
1
2
3


Set objGroup = _
 GetObject("LDAP://cn=Atl-Users,ou=HR,dc=NA,dc=fabrikam,dc=com")
objGroup.GetInfo

Exercise caution when explicitly calling the GetInfo method because any modification made to attributes in the local property cache are lost if the SetInfo method is not called before the local property cache is refreshed with GetInfo. For example, line 2 of the following code writes the value Human Resources to the description attribute in the local property cache. Line 3 then commits the value to the description attribute of the HR OU in Active Directory.

  
1
2
3


Set objOU = GetObject("LDAP://ou=HR,dc=NA,dc=fabrikam,dc=com")
objOU.Put "description", "Human Resources"
objOU.SetInfo

However, you might add the GetInfo method in the following way:

  
1
2
3
4


Set objOU = GetObject("LDAP://ou=HR,dc=NA,dc=fabrikam,dc=com")
objOU.Put "description", "Human Resources"
objOU.GetInfo
objOU.SetInfo

Line 2 still writes the value Human Resources to the description attribute, but then line 3 refreshes the local property cache, thereby overwriting the value Human Resources in the cache. In contrast, if GetInfo is called implicitly (using Get or GetEx), attribute values already in the local property cache are not overwritten. The only exception to this is if you use Get or GetEx to download the specific attribute that you are modifying in the previous step. This, of course, defeats the purpose of modifying the attribute.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft