Microsoft® Windows® 2000 Scripting Guide
« Previous | Next »
Because a multivalued attribute of an object can contain more than one value, you use the GetEx method to retrieve all values of the attribute. The information retrieved from GetEx is returned in the form of a variant array. An array is a data structure containing one or more values, and a variant is a data structure containing any data type, such as a string or an integer. Thus a variant array is a data structure containing one or more values of any type.
Important
To display the values in an array, you must add script code that is able to iterate through the array of values. Use the VBScript For Each statement to accomplish this task.
Even with the additional scripting code (that is, the For Each statement) that you must add to read a multivalued attribute, reading this type of attribute involves the same two steps outlined in "Reading Attributes of Directory Service Objects" earlier in this chapter:
The difference in this step is that you use the GetEx method instead of the Get method to complete the read operation and you use a For Each statement to display each value contained in the attribute.
The goal of the scripts in this section is to read and display the member attribute of the Atl-Users group and the url and otherTelephone attributes of the MyerKen user account. These attributes were modified in "Modifying Multivalued Attributes" earlier in this chapter.
The script in Listing 5.19 reads and displays the entries in the member attribute of the Atl-Users group. If you ran the scripts in the preceding section, the member attribute is now empty. Therefore, rerun the script in Listing 5.14 before running this script.
Listing 5.19 Reading the member Attribute of an OU
|
|
When this script runs in the na.fabrikam.com domain, it echoes the members of the Atl-Users group to the command window, as shown:
CN=LewJudy,OU=Sales,dc=NA,DC=fabrikam,DC=com CN=MyerKen,OU=HR,dc=NA,DC=fabrikam,DC=com
The script in Listing 5.20 reads and displays the entries in the url and otherTelephone attributes of the MyerKen user account.
Listing 5.20 Reading the url and otherTelephone Attributes of a User Account
|
|
When this script runs in the na.fabrikam.com domain, it echoes the url and otherTelephone attributes of the MyerKen user account to the command window, as shown:
http://www.contoso.com http://www.fabrikam.com/na http://www.microsoft.com 555-0183 555-0182 555-0180
Important observations about the scripts in this section are:
The GetEx method is similar to the Get method except that you must use a For Each statement to read and display an attribute s values.
Send us your feedback | « Previous | Next » |