' Listing 1: Code to Customize Const ADS_SCOPE_SUBTREE = 2 Const xlGuess = 0 Const xlAscending = 1 Const xlHeader = 1 Const ForWriting = 2 ' ******* BEGIN CALLOUT A ******* ' Specify the number of days to search back. x = 31 ' ******* END CALLOUT A ******* txtname = Cstr(Date()) '& " " & Cstr(Time()) txtname = Replace(txtname,"/","-",1,-1,1) txtname = Replace(txtname,":","-",1,-1,1) Set objNet = CreateObject("WScript.NetWork") Domain = objNet.UserDomain TEMPFILE = "c:\temp\" & domain & txtname & ".TXT" Set fso = CreateObject("Scripting.FileSystemObject") Set txt = fso.OpenTextFile(TEMPFILE,ForWriting,True) On Error Resume Next Set XL = CreateObject("Excel.Application") XL.Workbooks.Add XL.Visible = TRUE row = 1 Set AllGroupList = CreateObject("Scripting.Dictionary") DNC = GetObject("LDAP://RootDSE").Get("defaultNamingContext") Set objConnection = CreateObject("ADODB.Connection") Set objCommand = CreateObject("ADODB.Command") objConnection.Provider = "ADsDSOObject" objConnection.Open "Active Directory Provider" Set objCommand.ActiveConnection = objConnection objCommand.Properties("Page Size") = 100 objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE ' ******* BEGIN CALLOUT B ******* condit = "(cn='Enterprise Admins'" & _ " OR cn='Schema Admins'" & _ " OR cn='Domain Admins'" & _ " OR cn='Backup Operators'" & _ " OR cn='Account Operators'" & _ " OR cn='Administrators' " & _ " OR cn='Replicator'" & _ " OR cn='Server Operators')" ' ******* END CALLOUT B ******* ' ******* BEGIN CALLOUT C ******* objCommand.CommandText = "SELECT ADsPath,cn FROM 'LDAP://" & _ DNC & "' WHERE objectclass = 'group' AND " & condit ' ******* END CALLOUT C *******