G:\>adfind -gc -b -f objectclass=computer -stats+only
Directory: Windows Server 2003
=================================
Elapsed Time: 411 (ms)
Returned 26 entries of 9818 visited - (0.26%)
(objectClass=computer)
DNT_index:8757:N
Analysis
---------------------------------
Hit Rate of 0.26% is Inefficient
Record Count: 8757 (estimate)
Index Type : Normal Attribute Index
Filter Breakdown:
G:\>adfind -gc -b -f objectcategory=computer -stats+only
Directory: Windows Server 2003
=================================
Elapsed Time: 20 (ms)
Returned 26 entries of 26 visited - (100.00%)
(objectCategory=CN=Computer,CN=Schema,CN=Configuration,DC=joe,DC=com)
idx_objectCategory:26:N
Analysis
---------------------------------
Hit Rate of 100.00% is Efficient
Record Count: 26 (estimate)
Index Type : Normal Attribute Index
Filter Breakdown:
Vbscript
strBase =
"dc=joe,dc=com"
strFilter =
"(&(objectcategory=person)(objectclass=user))"
strAttrs =
"distinguishedName,displayName,memberOf"
strScope = "subtree"
set
objConn = CreateObject("ADODB.Connection")
objConn.Provider
= "ADsDSOObject"
objConn.Open
"Active Directory Provider"
set
objComm = CreateObject("ADODB.Command")
objComm.ActiveConnection
= objConn
objComm.Properties("Page
Size") = 1000
objComm.CommandText
= "<LDAP://" & strBase & ">;" & strFilter & ";"
_
& strAttrs & ";" & strScope
set
objRS = objComm.Execute
objRS.MoveFirst
on
error resume next
while
Not objRS.EOF
wscript.Echo "DN: " &
objRS.Fields(0).Value
wscript.echo "Display Name:
" & objRS.Fields(1).Value
wscript.echo "Group
memberships"
for each group in
objrs.fields(2).value
wscript.echo
" > " &
group
next
wscript.echo
objRS.MoveNext
wend
on
error goto 0
Perl
use
Win32::OLE;
use
Win32::OLE::Enum;
use
Win32::OLE 'in';
my
$strBase =
"dc=joe,dc=com";
my
$strFilter =
"(&(objectcategory=person)(objectclass=user))";
my
$strAttrs =
"distinguishedName,displayName,memberOf";
my
$strScope =
"subtree";
my
$objConn =
Win32::OLE->CreateObject("ADODB.Connection");
$objConn->{Provider}
= "ADsDSOObject";
$objConn->Open("Active
Directory Provider");
my
$objComm = Win32::OLE->CreateObject("ADODB.Command");
$objComm->{ActiveConnection}
= $objConn;
$objComm->{Properties}{"Page
Size"} = 1000;
$objComm->{CommandText}
=
"<LDAP://$strBase>;$strFilter;$strAttrs;$strScope";
my
$objRS = $objComm->Execute();
$objRS->MoveFirst;
while
(!$objRS->EOF())
{
print "DN:
".$objRS->Fields(0)->Value."\n";
print "Display Name:
".$objRS->Fields(1)->Value."\n";
foreach $group (in
$objRS->Fields(2)->Value)
{
print " > $group\n";
}
print "\n";
$objRS->MoveNext();
}
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Fuller, Stuart
Sent: Monday, November 22, 2004 11:46 AM
To: [EMAIL PROTECTED]
Subject: [ActiveDir] Slightly OT: AD Scripting question - ADO query and "description" field
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCOmmand.ActiveConnection = objConnection
objCommand.CommandText = _
"Select Name, distinguishedName, description, operatingSystem, operatingSystemServicePack, operatingSystemVersion from 'LDAP://ou=SomeOU,dc=ChildDomain,dc=RootDomain,dc=Root' " _
& "where objectClass='computer'"
objCommand.Properties("Page Size") = 2000
objCommand.Properties("Timeout") = 60
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.Properties("Cache Results") = False
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
strName = objRecordSet.Fields("Name").Value
strDescrip = objRecordSet.Fields("description").Value
strOS = objRecordSet.Fields("operatingSystem").Value
strOSV = objRecordSet.Fields("operatingSystemVersion").Value
strOSSP = objRecordSet.Fields("operatingSystemServicePack").Value
strLocation = objRecordSet.Fields("distinguishedName").Value
fileTxt.WriteLine(strName & "," & strDescrip & "," & strOS & "," & strOSV & "," & strOSSP & "," & strLocation)
objRecordSet.MoveNext
Loop
strName = objRecordSet.Fields("Name").Value
==> strADSPath = objRecordSet.Fields("ADSPath").Value
==>' Go get multi-valued description attribute from object using ADSpath
==> strDescrip = GetObject(strADSPath).description
strOS = objRecordSet.Fields("operatingSystem").Value
strOSV = objRecordSet.Fields("operatingSystemVersion").Value
strOSSP = objRecordSet.Fields("operatingSystemServicePack").Value
strLocation = objRecordSet.Fields("distinguishedName").Value
fileTxt.WriteLine(strName & "," & strDescrip & "," & strOS & "," & strOSV & "," & strOSSP & "," & strLocation)
objRecordSet.MoveNext
Loop