tbaseflug
asked on
AD Query - Multiple Criteria
I am trying to query the department AD attribute but want to query for multiple filters - such as
department=TEST1 or department=TEST2
How would I do this>
department=TEST1 or department=TEST2
How would I do this>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You use only one '&' operator, and this condition
objectClass=user AND objectCategory=person AND department=APDSLN AND department=APDSLI
cannot be true.
You need to use '|' (meaning OR) operator also, this way:
deSearch.Filter = "(&(objectClass=user)(obje ctCategory =person)(| (departmen t=APDSLN)( department =APDSLI))) ";
which you can translate:
(objectClass=user) AND (objectCategory=person) AND (department=APDSLN OR department=APDSLI).
objectClass=user AND objectCategory=person AND department=APDSLN AND department=APDSLI
cannot be true.
You need to use '|' (meaning OR) operator also, this way:
deSearch.Filter = "(&(objectClass=user)(obje
which you can translate:
(objectClass=user) AND (objectCategory=person) AND (department=APDSLN OR department=APDSLI).
ASKER
deSearch.Filter = "(&(objectClass=user)(obje
But for soem reason, this does not - when I include the extra department criteria, nothing is returned - when I do one or the other, it works individually, etc. (above):
deSearch.Filter = "(&(objectClass=user)(obje