Platform SDK: Active Directory, ADSI, and Directory Services

Creating a Query Filter

A query filter is simply the act of telling Active Directory what you want to find — in LDAP query syntax. All the specified data access technologies listed in the Choosing the Data Access Technology topic support the LDAP query syntax.

The LDAP query syntax is the following:

<expression><expression>…

A filter can contain one or more expressions. An expression has the following form:

(<logicaloperator><comparison><comparison…>)

where <logicaloperator> is the following:

Logical operator Meaning
| OR
& AND
! NOT

and <comparison> is the following:

(<attribute><operator><value>)

where <attribute> is the lDAPDisplayName of the attribute to evaluate, <value> is the value to compare against, and <operator> is one of the following comparison operators:

Logical operator Meaning
= Equals
~= Approximately equals
<= Less than or equal to
>= Greater than or equal to

In addition, depending on the attribute syntax, the <value> may contain the * wildcard. Note that a <value> containing only * checks for the existence of the <attribute>.