Microsoft® Windows® 2000 Scripting Guide
Although searching Active Directory is a useful administrative task in itself, it becomes even more powerful when the results of a search are combined with other administrative tasks. For example, you can search for all the user accounts in a domain and then use the results of the search to modify attributes that should be the same for all users, or verify that an Active Directory object does not already exist before attempting to create it.
The query technology available to VBScript is ActiveX® Data Objects (ADO). ADO uses the ADSI OLE DB provider to read information from Active Directory. OLE DB is a set of interfaces that provide access to all types of databases, including the Active Directory database. The information returned to ADO by the ADSI OLE DB provider is read-only. Thus, you cannot use ADO to modify the result set returned by a query. However, as the preceding paragraph explains, after the result set is returned, you can use ADSI methods to perform administrative tasks that go beyond returning a result set.
Returning a result set typically involves three ADO objects:
Connection. This object provides a link between the ADSI script and Active Directory by loading the ADSI OLE DB provider.
Command. This object enables the script to initiate a query against Active Directory and control various aspects of the search, such as the sort order.
RecordSet. This object receives the query results from the Command object.