'*****************************Script******************************
Const ADS_SCOPE_SUBTREE = 2
Sub enumerateTDGroups()
Set oRoot = GetObject("LDAP://Domain_new/RootDSE")
sDNSDomain = oRoot.Get("DefaultNamingContext")
msgbox sDNSDomain
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Properties("User ID") = "Domain_new\AdminAccount"
objConnection.Properties("Password") = "password123"
objConnection.Properties("Encrypt Password") = TRUE
objConnection.Properties("ADSI Flag") = 3
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 9999
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.CommandText = _
"SELECT adspath FROM 'LDAP://"& sDNSDomain &"' WHERE objectCategory='group'"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
Wscript.Echo objRecordSet.Fields("adspath").Value
objRecordSet.MoveNext
Loop
End Sub
|