Const ADS_SCOPE_SUBTREE = 2
Set objRootDSE = GetObject ("LDAP: // rootDSE ")
StrDomain = ObjRootDSE. Get ("defaultNamingContext ")
Set objConnection = CreateObject ("ADODB. Connection ")
Set objCommand = CreateObject ("ADODB. Command ")
ObjConnection. Provider = "ADsDSOObject"
ObjConnection. Open "Active Directory Provider"
Set objCommand. ActiveConnection = objConnection
Objectcommand. Properties ("Page Size") = 1000
ObjCommand. Properties ("Searchscope") = ADS_SCOPE_SUBTREE
ObjCommand. CommandText = "SELECT * from ldap: //" & strDomain & "WHERE objectCategory = computer"
Set objRecordSet = objCommand. Execute
ObjRecordSet. MoveFirst
Do Until objRecordSet. EOF
Wscript. Echo objRecordSet. Fields ("ADsPath"). Value
ObjRecordSet. MoveNext
Loop
Wscript. Echo ""
Wscript. Echo "Total Computer:" & objRecordSet. RecordCount
Displays the names and numbers of all users in the current domain.
Const ADS_SCOPE_SUBTREE = 2
Set objRootDSE = GetObject ("LDAP: // rootDSE ")
StrDomain = ObjRootDSE. Get ("defaultNamingContext ")
Set objConnection = CreateObject ("ADODB. Connection ")
Set objCommand = CreateObject ("ADODB. Command ")
ObjConnection. Provider = "ADsDSOObject"
ObjConnection. Open "Active Directory Provider"
Set objCommand. ActiveConnection = objConnection
Objectcommand. Properties ("Page Size") = 1000
ObjCommand. Properties ("Searchscope") = ADS_SCOPE_SUBTREE
ObjCommand. CommandText = "SELECT * from ldap: //" & strDomain & "WHERE objectCategory = user"
Set objRecordSet = objCommand. Execute
ObjRecordSet. MoveFirst
Do Until objRecordSet. EOF
Wscript. Echo objRecordSet. Fields ("ADsPath"). Value
ObjRecordSet. MoveNext
Loop
Wscript. Echo ""
Wscript. Echo "Total User:" & objRecordSet. RecordCount