More info (From Steve @ Microsoft):
quote:
What you are finding is correct. The Computer class is based on the User class, so if you filter on 'User' in the IADsContainer::Filter, it will also display the Computers located in that container. The reason the opposite is not true, is that the User does not have an entry for 'Computer' in it's objectClass attribute.

Unfortunately, the filter only will filter on the objectClass rather than the objectCategory, so this filter will not distinguish between User and Computer objects. If you have containers that have both User and Computer objects in it, I would work around it using one of the following techniques:

1. When looping through the objects in the IADsContainer object, check the objectCategory value and ensure it is Person.
2. Use ADO with the ADsDSoObject and execute a one level search on that container, filtering on objectCategory='Person'.

I am attaching a sample script that I had lying around that shows querying on the objectCategory. For further information concerning using the ADSI OLE-DB provider with ADO, please see the information at the following MSDN link.

http://msdn.microsoft.com/library/en-us/netdir/adsi/searching_with_activex_data _objects_ado.asp


set oRoot = getobject("LDAP://rootdse")
strDefaultNameCont = oRoot.get("defaultNamingContext")
strDNSHost = oRoot.get("dnsHostName")
set oRoot = nothing


set oConn = createobject("adodb.connection")
oConn.provider = "adsdsoobject"
oConn.open "My GC Connection"

dim strQuery


strQuery = "select distinguishedName,objectClass from 'LDAP://" & strDNSHost & "/ou=TestOU," & strDefaultNameCont & "'" _
& " where objectCategory='Person'"


wscript.echo strQuery

set oCmd = createobject("adodb.command")
oCmd.ActiveConnection = oConn
oCmd.CommandText = strQuery

oCmd.Properties("Page Size") = 1000

set oRS = oCmd.execute()

if oRS.eof then
wscript.echo "No User"
end if
if oRS.recordcount=1 then
wscript.echo "One User Returned"
end if
Do While Not oRS.EOF
For i = 0 To oRS.Fields.Count - 1
wscript.echo oRS.Fields(i).Name
aEnt = oRS.Fields(i).Value
If IsArray(aEnt) Then
For m = 0 To UBound(aEnt)
wscript.echo aEnt(m)
Next
Else
wscript.echo aEnt
End If
Next
oRS.MoveNext
Loop


[ 17. May 2003, 19:04: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/