Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

Making Explicit Calls by Using the GetInfoEx Method

Microsoft® Windows® 2000 Scripting Guide

Rather than download most attributes of an object, you can selectively load or refresh the local property cache with a specific attribute or set of attributes by using the GetInfoEx method. In addition, you must use this method to download operational attributes.

Using GetInfoEx is an ideal approach to working with attributes if you want to minimize the load placed on the domain controller servicing the request and the minimize network traffic that results from downloading attributes.

The syntax for this method is:



object.GetInfoEx Attributes, 0


The Attributes parameter of GetInfoEx is an array containing the lDAPDisplayName of each attribute. The second parameter (0) is reserved and must be specified when calling the GetInfoEx method.

You can initialize a variable with an array containing the lDAPDisplayName of one or more attributes and then use that variable in the GetInfoEx call. The script in Listing 5.22 downloads two attributes, description and dnsHostName, of a computer object named SEA-SQL-01.

  1. Bind to the SEA-SQL-01 computer in the Computers container of the na.fabrikam.com domain.

  2. Initialize a variable named arrAttributes with an array containing the lDAPDisplayName of two attributes, description and dnsHostName (line 3).

  3. Use the GetInfoEx method to explicitly download attributes specified in the arrAttributes variable into the local property cache (line 4).

    The attributes downloaded are the two specified in the arrAttributes variable in line 3.

Listing 5.22 Making an Explicit Call to GetInfoEx

  
1
2
3
4


Set objComputer = GetObject _
 ("LDAP://cn=SEA-SQL-01,cn=Computers,dc=NA,dc=fabrikam,dc=com")
arrAttributes = Array("description", "dnsHostName")
objComputer.GetInfoEx arrAttributes, 0

As with the GetInfo method, you must exercise caution when combining the GetInfoEx method with a script that modifies the attributes that GetInfoEx downloads. Modifications to attributes are lost if the SetInfo method is not called before the local property cache is refreshed with GetInfoEx.

For example, lines 3 and 4 of the following code write values to the description and dnsHostName attributes in the local property cache. However, the values are overwritten when these attributes are refreshed using the GetInfoEx method in line 7. When the SetInfo method is called in line 8, the values of the two attributes downloaded by GetInfoEx are written back to Active Directory instead of the values assigned in lines 3 and 4.

  
1
2
3
4
5
6
7
8


Set objComputer = GetObject _
 ("LDAP://cn=SEA-SQL-01,cn=Computers,dc=NA,dc=fabrikam,dc=com")
objComputer.Put "description", "SQL Computer 1"
objComputer.Put "dnsHostName", "sea-sql-01.na.fabrikam.com"

arrAttributes = Array("description", "dnsHostName")
objComputer.GetInfoEx arrAttributes, 0
objComputer.SetInfo

By moving line 8 (the SetInfo method call) up to line 5, the two attributes written to the local property cache by the Put method calls are committed to Active Directory. When GetInfoEx selectively refreshes the cache in line 7, the values match those previously written to the cache by the Put method calls.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.