Making Explicit Calls by Using the GetInfo Method

Microsoft® Windows® 2000 Scripting Guide

microsoft windows 2000 scripting guide

« Previous | Next »   

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.


send us your feedback Send us your feedback « Previous | Next »   


Microsoft Windows 2000 Scripting Guide(c) Automating System Administration 2003
Microsoft Windows 2000 Scripting Guide(c) Automating System Administration 2003
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 635

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net