The following are examples of ADSI queries using SQL:
Select ADsPath, Cn FROM 'LDAP://O=Internet/DC=COM/DC=MICROSOFT/DC=NTDEV' where objectClass='group' : Select all group objects
Select AdsPath, cn, revision FROM
'LDAP://nw01t1/O=Internet/DC=COM/DC=MICROSOFT/DC=NTDEV/dc=nwparent' where objectClass='*' AND revision >= 10 : All user objects which have the property revision greater than or equal to 10
Select AdsPath, cn, revision FROM 'LDAP://nw01t1/O=Internet/DC=COM/DC=MICROSOFT/DC=NTDEV/dc=nwparent' where objectClass='*' AND (cn = 'a*' OR cn = 'b*'): All Computer objects which have name attribute starting with "a" or "b"
The formal grammar for the SQL queries is defined in the following way. (All keywords are case insensitive.)
statement ::= select-statement
select-statement ::= SELECT [ALL] select-list FROM table-identifier [WHERE search-condition]
select-list ::= * | select-sublist [, select-sublist]...
select-sublist ::= column-identifier
column-identifier ::= user-defined-name
table-identifier ::= string-literal
search-condition ::= boolean-term [OR search-condition]
boolean-term ::= boolean-factor [AND boolean-term]
boolean-factor ::= [NOT] boolean-primary
boolean-primary ::= comparison-predicate | (search-condition)
comparison-predicate ::= column-identifier comparison-operator literal
comparison-operator ::= < | > | <= | >= | = | <>
user-defined-name ::= letter [letter | digit]...
literal ::= string-literal | numeric-literal | boolean-literal
string-literal ::= '{character}...' (Any sequence of characters delimited by quotes)
numeric-literal ::= digits [fraction] [exponent]
digits ::= digit [digit]...
fraction ::= . digits
exponent ::= E digits
boolean-literal ::= TRUE | FALSE | YES | NO | ON | OFF