You want to perform a forest-wide search using the global catalog.
From the menu, select Connection Connect.
For Server, enter the name of a global catalog server.
For Port, enter 3268.
From the menu, select Connection Bind.
Enter credentials of a user.
From the menu, select Browse Search.
For BaseDN, type the base distinguished name where to start the search.
For Scope, select the appropriate scope.
For Filter, enter an LDAP filter.
> dsquery * <BaseDN> -gc -scope <Scope> -filter "<Filter>" -attr "<AttrList>"
' This code searches the global catalog ' ------ SCRIPT CONFIGURATION ------ strBase = "<GC://<BaseDN>>;" strFilter = "<Filter>;" strAttrs = "<AttrList>;" strScope = "<Scope>" ' ------ END CONFIGURATION --------- set objConn = CreateObject("ADODB.Connection") objConn.Provider = "ADsDSOObject" objConn.Open "Active Directory Provider" set objRS = objConn.Execute(strBase & strFilter & strAttrs & strScope) objRS.MoveFirst while Not objRS.EOF Wscript.Echo objRS.Fields(0).Value objRS.MoveNext wend
The global catalog facilitates forest-wide searches. When you perform a normal LDAP search over port 389, you are searching against a particular partition in Active Directory, whether that is the Domain naming context, Configuration naming context, Schema naming context, or application partition. If you have multiple domains in your forest, this type of search will not search against all domains.
The global catalog contains all a subset of the attributes for all objects in the forest (excluding objects in application partitions). Think of it as a subset of all the naming contexts combined. All objects will be contained in the global catalog, except for objects in application partitions, but only some of the attributes will be available. For that reason, if you perform a global catalog search and do not get values for attributes you were expecting to, make sure those attributes are included in the global catalog, also known as the partial attribute set (PAS). See Recipe 10.14 for more information.
The only difference between this solution and Recipe 4.5 is that the "Port" has changed to 3268, which is the standard GC port.
The only difference between this solution and Recipe 4.5 is the addition of the -gc flag.
The only difference between this solution and Recipe 4.5 is that strBase variable changed to use the GC: progID:
strBase = "<GC://<BaseDN>>;"
Recipe 4.5 for searching for objects, and MSDN: Searching with ActiveX Data Objects (ADO)