Search Filters
To narrow a search, you can specify search filters directly to the Smart Search field. If the search field contains an equal sign (=), Smart Search assumes the value is a search filter, and it uses this filter directly to perform the search.
Search filters use the value of an attribute to select the entries to be returned for Smart Search. For example, the following filter specifies a search for a common name equal to Babs Jensen:
cn=babs jensen
Search filter syntax
The basic syntax of a search filter is:
attribute operator value
For example:
employeenumber >= 100
In the example above, employeenumber
is the attribute, >=
is the operator, and 100 is the value.
You can also define filters that use combinations of different attributes.
Using attributes in a filter
When searching for an entry, you can specify attributes associated with that type of entry. For example, when you search for entries about people, you can use the cn
attribute to search for people with specific common names.
Examples of attributes for entries about people might include:
cn
(the person's common name)
telephonenumber
(the person's phone number)
employeenumber
(the person's employee number)
l
(the person's location)
Using operators in a filter
An operator defines one of the following types of searches:
For more information on these types of searches, see "How searching works."
Using multiple search filters
You can combine different search filters by using boolean operators. Use the operators in prefix notation as follows:
(boolean_operator((filter)(filter)(filter)...))
where boolean_operator is any one of the boolean operators. For example:
(&(ou=Marketing)(cn=Ray*))
In the example above, the combination of filters finds entries whose organizational unit is Marketing (ou=Marketing
) and whose common name starts with Ray (cn=Ray*
). The boolean operator for "And" (&
) is used in prefix notation, which means that it precedes the search criteria.
In addition, you can nest boolean operators to form complex expressions, such as:
(boolean_operator(filter)((boolean_operator(filter)(filter)))
Boolean operators
The boolean operators available for use with search filters are:
Search filter examples
The following filter searches for entries containing the manager attribute. This is also known as a presence search:
manager=*
The following filter searches for entries containing the common name of Ray Kultgen. This is also known as an equality search:
cn=Ray Kultgen
The following filter returns any entries that do not contain the common name of Ray Kultgen:
(!(cn=Ray Kultgen))
The following filter returns any entries that contain a description attribute with a substring of X.500:
description=*X.500*
The following filter returns any entries whose organizational unit is Marketing and whose description field does not contain the substring X.500:
(&(ou=Marketing)(!(description=*X.500*)))
The following filter returns any entries whose organizational unit is Marketing and who have Julie Fulmer or Cindy Zwaska as a manager:
(&(ou=Marketing)(|(manager="cn=Julie Fulmer,ou=Marketing,o=Ace
Industry,c=US")(manager="cn=Cindy Zwaska,ou=Marketing,o=Ace
Industry,c=US")))
The following filter returns any entries that do not represent a person:
(!(objectclass=person))
The following filter returns any entries that do not represent a person and whose common name is approximately printer3b:
(&(!(objectclass=person))(cn~=printer3b))
How searching works
Note:
The Directory Server interface is actually a collection of forms and CGI
programs that operate independently from the Directory Server. This interface
acts as an LDAP client to the Directory Server.
The following section explains what happens when you search the Directory Server:
cn=Robert E Lee
. An approximate search allows you to find this entry by specifying Robert Lee, Robert, or Lee. Similarly, a search for the location approximately equal to San Fransico (l~=San Fransico
; note the misspelling) would return entries including locations exactly equal to San Francisco (l=San Francisco
).
The Directory Server treats each value in an entry as a sequence of words and generates a phonetic code for each word. When you enter a value in an approximate search, the Directory Server also translates the value to a sequence of phonetic codes. An entry is considered to match a query if:
How substring searches work
The substring search finds entries that contain the value you have entered. In the Advanced Search interface, the substring search corresponds to the "starts with", "contains", and "ends with" search types.
For example, searches of the form:
cn=*derson
would match the common names containing strings such as:
Bill Anderson
Jill Anderson
Steve Sanderson
and so forth. Similarly, the search for
telephonenumber= *555*
would return all the entries in your directory with telephone numbers that contain 555.