Search code examples
ldapldap-query

ldapsearch - filtering ou in dn


I understand you can't simply filter on dn, but I have something like this:

dc=lvl3,dc=lvl2,dc=lvl1, and someone could have a dn like this: CN=Last, First,OU=ou1,OU=retired,OU=ou1,DC=lvl3,DC=lvl2,DC=lvl1.

Is there a way I can filter results for those who do not have 'retired' in any ou?


Solution

  • No. Not as an LDAP filter.

    You could of course do a search and then sort on the CLient-side.

    Generally organization of "characteristics" of users should be done using Attributes and not by the Directory Structure.

    Something like:

    • employeeType=Active
    • employeeType=Retired
    • employeeType=etc

    To avoid these conditions.