Search filter

The search filter syntax has the form attribute operator value. The default filter, objectclass=*, returns all entries in the scope.

The following table lists the filter operators:

Operator Example Matches

=*

(mail=*)

All entries that contain a mail attribute.

=

(o=macromedia)

Entries in which the organization name is macromedia.

~=

(sn~=Hansen)

Entries with a surname that approximates Hansen. The matching rules for approximate matches vary among directory vendors, but anything that "sounds like" the search string should be matched. In this example, the directory server might return entries with the surnames Hansen and Hanson.

>=

(st>=ma)

The name "ma" and names appearing after "ma" in an alphabetical state attribute list.

<=

(st<=ma)

The name "ma" and names appearing before "ma" in an alphabetical state attribute list.

*

(o=macro*)

Organization names that start with "macro".

 

(o=*media)

Organization names that end with "media".

 

(o=mac*ia)

Organization names that start with "mac" and end with "ia". You can use more than one * operator in a string; for example, m*ro*dia.

 

(o=*med*)

Organization names that contain the string "med", including the exact string match "med".

&

(&(o=macromedia)
(co=usa))

Entries in which the organization name is "macromedia" and the country is "usa".

|

(|(o=macromedia)
(sn=macromedia)
(cn=macromedia))

Entries in which the organization name is "macromedia" or the surname is "macromedia", or the common name is "macromedia".

!

(!(STREET=*))

Entries that do not contain a StreetAddress attribute.

The Boolean operators & and | can operate on more than two attributes and precede all of the attributes on which they operate. You surround a filter with parentheses and use parentheses to group conditions.

If the pattern that you are matching contains an asterisk, left parenthesis, right parenthesis, backslash, or NUL character, you must use the following three-character escape sequence in place of the character:

Character Escape sequence

*

\2A

(

\28

)

\29

\

\5C

NUL

\00

For example, to match the common name St*r Industries, use the filter
(cn=St\2Ar Industries).

LDAP v3 supports an extensible match filter that permits server-specific matching rules. For more information on using extensible match filters, see your LDAP server documentation.

Searching and sorting notes


View comments in LiveDocs