2

How can we filter LDAP with multiple OUs.

For example: URL for single OU: LDAP://xxxx.com/OU=Users,OU=xxx,OU=xxxx,DC=xxxxx,DC=xxxxx

But I need result for multiple OU. Solution can be in LDAP URL or it can be in c# code which ever is suitable. I am using DirectoryEntry and DirectorySearcher classes for it in c#

Japneet Singh
  • 155
  • 1
  • 3
  • 13

1 Answers1

0

Yes you can with LDAP filters: The base of your search must be above all OUs, for example: dc=xxxx,dc=com. The filter should include the OUs, but since these are not always attributes of the targeted entries, you must specify to do the search as part of the DN... Example filter:

(&(objectclass=InetOrgPerson)(cn=John*)(|(ou:dn:=users)(ou:dn:=Groups)))

You can find examples in RFC4515, section 4.

Ludovic Poitou
  • 4,788
  • 2
  • 21
  • 30