VB DirectorySearcher Filter - Computers AND users

16 views Asked by At

I am trying to create a directory filter that get Computers AND Users but fail.

I can get ALL the computer if i use this :

    Dim oSearcher As DirectorySearcher = New DirectorySearcher(oRoot)
    oSearcher.Filter = "(&" & "(objectClass=computer)" & ")"
    oSearcher.SearchScope = DirectoryServices.SearchScope.Subtree

I can get ALL the users and contact if i change the filter line :

Dim oSearcher As DirectorySearcher = New DirectorySearcher(oRoot)
oSearcher.Filter = "(&(objectCategory=User)(objectClass=person))"
oSearcher.SearchScope = DirectoryServices.SearchScope.Subtree

What i cannot do is to have a query that get either computers and users.

Tried also this :

oSearcher.Filter = "(&" & "(objectClass=computer)(objectCategory=User)(objectClass=person)" & ")" Please, any help will be appreciated Obtain ALL Computer and ALL users

0

There are 0 answers