You should check out RFC 2254 (String View for LDAP Search Filters).
LDAP filters use lacquer notation for Boolean operators. Thus, the operator is written before its operands:
(&(condition1)(condition2)(condition3)...)
The above example means that you want all LDAP entries to satisfy condition1 AND condition2 AND condition3, etc.
Then there are the conditions themselves. They are very simple and can consist of only a few types:
- Current state -
(attrName=*) - a simple condition is
(attrName>=value) / (attrName<=value) / (attrNamevalue=value) / (attrName~=value) - substring condition -
(attrName=*value*) / (attrName=*value) / (attrName=value*) - extensible condition -
(attrName:dn:=value) / (attrName:matchingRule:=value)
An extensible clause with the keyword :dn: means that you must also consider the attributes from the record DN. So, for your input to the register cn=John Doe,ou=HumanResources,ou=Users,dc=example,dc=com filter will match (ou:dn:=HumanResource) .
The translation of your filter example into an English sentence will be as follows:
Find all LDAP entries that have objectClass equal to person and have either ResearchAndDevelopment or HumanResources in their ou attribute or somewhere in their DN.
Pavel horal
source share