' ReplicatedAttr.vbs ' VBScript program to document the Active Directory attributes that are ' replicated. ' ' ---------------------------------------------------------------------- ' Copyright (c) 2002-2010 Richard L. Mueller ' Hilltop Lab web site - http://www.rlmueller.net ' Version 1.0 - November 10, 2002 ' Version 1.1 - February 19, 2003 - Standardize Hungarian notation. ' Version 1.2 - March 11, 2003 - Remove SearchScope property. ' Version 1.3 - September 9, 2010 - Fix bugs in query. ' Version 1.4 - November 6, 2010 - No need to set objects to Nothing. ' ' This program uses ADO to search Active Directory for all attributes in ' the schema that are replicated throughout the domain. This program is ' designed to be run at a command prompt with Cscript. The output can be ' redirected to a text file. ' ' You have a royalty-free right to use, modify, reproduce, and ' distribute this script file in any way you find useful, provided that ' you agree that the copyright owner above has no warranty, obligations, ' or liability for such use. Option Explicit Dim objRootDSE, strSchema, adoCommand, adoConnection Dim strQuery, adoRecordset, strBase, strFilter ' Determine the schema container from the RootDSE object. Set objRootDSE = GetObject("LDAP://RootDSE") strSchema = objRootDSE.Get("schemaNamingContext") ' Use ADO to search Active Directory of all replicated attributes. Set adoCommand = CreateObject("ADODB.Command") Set adoConnection = CreateObject("ADODB.Connection") adoConnection.Provider = "ADsDSOObject" adoConnection.Open "Active Directory Provider" adoCommand.ActiveConnection = adoConnection strBase = "" strFilter = "(&(objectCategory=attributeSchema)" _ & "(isMemberOfPartialAttributeSet=TRUE))" strQuery = strBase & ";" & strFilter & ";cn;subtree" adoCommand.CommandText = strQuery adoCommand.Properties("Page Size") = 100 adoCommand.Properties("Timeout") = 30 adoCommand.Properties("Cache Results") = False Set adoRecordset = adoCommand.Execute If (adoRecordset.EOF = True) Then Wscript.Echo "No attributes found" adoRecordset.Close adoConnection.Close Wscript.Quit End If ' Enumerate the replicated attributes. Do Until adoRecordset.EOF Wscript.Echo adoRecordset.Fields("cn").Value adoRecordset.MoveNext Loop adoRecordset.Close ' Clean up. adoConnection.Close