Previous: , Up: LDAP Support   [Contents][Index]


60.3 Syntax of Search Filters

LDAP search functions use RFC1558 syntax to describe the search filter. In that syntax simple filters have the form:

(<attr> <filtertype> <value>)

<attr> is an attribute name such as cn for Common Name, o for Organization, etc...

<value> is the corresponding value. This is generally an exact string but may also contain * characters as wildcards

filtertype is one = ~=, <=, >= which respectively describe equality, approximate equality, inferiority and superiority.

Thus (cn=John Smith) matches all records having a canonical name equal to John Smith.

A special case is the presence filter (<attr>=* which matches records containing a particular attribute. For instance (mail=*) matches all records containing a mail attribute.

Simple filters can be connected together with the logical operators &, | and ! which stand for the usual and, or and not operators.

(&(objectClass=Person)(mail=*)(|(sn=Smith)(givenname=John))) matches records of class Person containing a mail attribute and corresponding to people whose last name is Smith or whose first name is John.