Listing 2: ListDCs.vbs Dim RootDSE, ConfigNC, Connection, Command, RecordSet, DC ' BEGIN CALLOUT A Set RootDSE = GetObject("LDAP://rootDSE") ConfigNC = RootDSE.Get("configurationNamingContext") ' END CALLOUT A Set Connection = CreateObject("ADODB.Connection") Connection.Open("Provider=ADsDSOObject;") Set Command = CreateObject("ADODB.Command") Command.ActiveConnection = Connection ' BEGIN CALLOUT B Command.CommandText = ";(objectClass=nTDSDSA);AdsPath;subtree" ' END CALLOUT B Command.Properties("Cache Results") = False Command.Properties("Page Size") = 100 Command.Properties("Sort On") = "CN" Command.Properties("Timeout") = 30 Set RecordSet = Command.Execute() ' BEGIN CALLOUT C Do While Not RecordSet.EOF Set DC = GetObject(GetObject(RecordSet.Fields("AdsPath").Value).Parent) WScript.Echo DC.CN RecordSet.MoveNext() Loop ' END CALLOUT C Connection.Close()