Identity Suite : Useful LDAP filters when you query Active Directory.

Blog Post created by kumsa29 Employee on Aug 3, 2018

The following table shows many example LDAP filters that can be useful when you query Active Directory:


QueryLDAP Filter
All user objects(&(objectCategory=person)(objectClass=user))
All user objects (Note 1)(sAMAccountType=805306368)
All computer objects(objectCategory=computer)
All contact objects(objectClass=contact)
All group objects(objectCategory=group)
All organizational unit objects(objectCategory=organizationalUnit)
All container objects(objectCategory=container)
All builtin container objects(objectCategory=builtinDomain)
All domain objects(objectCategory=domain)
Computer objects with no description(&(objectCategory=computer)(!(description=*)))
Group objects with a description(&(objectCategory=group)(description=*))
Users with cn starting with "Joe"(&(objectCategory=person)(objectClass=user) 
Object with description "East\West Sales" 
(Note 2)
(description=East\5CWest Sales)
Phone numbers in form (***) ***-***(telephoneNumber=(*)*-*)
Groups with cn starting with 
"Test" or "Admin"
All users with both a first and last name.(&(objectCategory=person)(objectClass=user) 
All users with direct reports but no 
All users with specified email address(&(objectCategory=person)(objectClass=user) 
 All users with Logon Script: field occupied (&(objectCategory=person)(objectClass=user)(scriptPath=*))
Object with Common Name "Jim * Smith" 
(Notes 3, 19)
(cn=Jim \2A Smith)
Objects with sAMAccountName that begins 
with "x", "y", or "z"
Objects with sAMAccountName that begins
with "a" or any number or symbol except "$"
All users with "Password Never Expires" set 
(Note 4)
All disabled user objects (Note 4)(&(objectCategory=person)(objectClass=user) 
All enabled user objects (Note 4)(&(objectCategory=person)(objectClass=user) 
All users not required to have a password 
(Note 4)
All users with "Do not require kerberos 
preauthentication" enabled
Users with accounts that do not expire 
(Note 5)
Users with accounts that do expire (Note 5)(&(objectCategory=person)(objectClass=user) 
Accounts trusted for delegation 
(unconstrained delegation)
Accounts that are sensitive and not trusted 
for delegation
All distribution groups (Notes 4, 15)(&(objectCategory=group) 
All security groups (Notes 4, 19)(groupType:1.2.840.113556.1.4.803:=2147483648)
All built-in groups (Notes 4, 16, 19)(groupType:1.2.840.113556.1.4.803:=1)
All global groups (Notes 4, 19)(groupType:1.2.840.113556.1.4.803:=2)
All domain local groups (Notes 4, 19)(groupType:1.2.840.113556.1.4.803:=4)
All universal groups (Notes 4, 19)(groupType:1.2.840.113556.1.4.803:=8)
All global security groups (Notes 17, 19)(groupType=-2147483646)
All universal security groups (Notes 17, 19)(groupType=-2147483640)
All domain local security groups 
(Notes 17, 19)
All global distribution groups (Note 19)(groupType=2)
All objects with service principal name(servicePrincipalName=*)
Users with "Allow Access" on "Dial-in" 
tab of ADUC 
(Note 6)
Users with "Control access though 
NPS Network Policy" on "Dial-in" tab of ADUC
All groups created after March 1, 2011(&(objectCategory=group) 
All users that must change their password 
at next logon
All users that changed their password since 
April 15, 2011 (CST) (Note 7)
All users with "primary" group 
other than "Domain Users"
All computers with "primary" group 
"Domain Computers"
Object with GUID 
(Note 8)
Object beginning with GUID 
(Note 8)
Object with SID "S-1-5-21-73586283 
-152049171-839522115-1111" (Note 9)
Object with SID "010500000000000515000 
(Note 9)
All computers that are not 
Domain Controllers (Note 4)
All Domain Controllers (Note 4)(&(objectCategory=computer) 
All Domain Controllers (Notes 14, 19)(primaryGroupID=516)
All servers(&(objectCategory=computer) 
All member servers (not DC's) (Note 4)(&(objectCategory=computer) 
All direct members of specified group(memberOf=cn=Test,ou=East,dc=Domain,dc=com)
All users not direct members of 
a specified group
All groups with specified direct member 
(Note 19)
(member=cn=Jim Smith,ou=West, 
All members of specified group, including 
due to group nesting (Note 10)
All groups specified user belongs to, 
including due to group nesting (Notes 10, 19)
cn=Jim Smith,ou=West,dc=Domain,dc=com)
Objects with givenName "Jim*" and sn 
"Smith*", or with cn "Jim Smith*" (Note 11)
(anr=Jim Smith)
All attributes in the Schema container 
replicated to the GC (Notes 6, 12)
All operational (constructed) attributes in 
the Schema container (Notes 4, 12)
All attributes in the Schema container not 
replicated to other Domain Controllers 
(Notes 4, 12)
All objects where deletion is not allowed 
(Notes 4)
Attributes whose values are copied when 
the object is copied (Notes 4, 12)
Attributes preserved in tombstone object 
when object deleted (Notes 4, 12)
Attributes in the Ambiguous Name 
Resolution (ANR) set (Notes 4, 12)
Attributes in the Schema that are 
indexed (Notes 4, 12)
Attributes marked confidential in 
the schema (Notes 4, 12)
Attributes in the RODC filtered attribute 
set, or FAS (Notes 4, 12)
All site links in the Configuration 
container (Note 13)
The nTDSDSA objects associated with 
all Global Catalogs. This will identify all DC's 
that are GC's. (Note 4)
The nTDSDSA object associated with the 
PDC Emulator. This will identify the DC 
with the PDC Emulator FSMO role (Note 18).
The nTDSDSA object associated with the 
RID Master. This will identify the DC 
with the RID Master FSMO role (Note 18).
The nTDSDSA object associated with the 
Infrastructure Master. This will identify the DC 
with this FSMO role (Note 18).
The nTDSDSA object associated with the 
Schema Master. This will identify the DC with 
the Schema Master FSMO role (Note 18).
The nTDSDSA object associated with the 
Domain Naming Master. This will identify the 
DC with this FSMO role (Note 18).
All Exchange servers in the Configuration 
container (Note 13)
All objects protected by AdminSDHolder(adminCount=1)
All trusts established with a domain(objectClass=trustedDomain)
All Group Policy objects(objectCategory=groupPolicyContainer)
All service connection point objects(objectClass=serviceConnectionPoint)
All Read-Only Domain Controllers 
(Notes 4, 19)



Credit: https://social.technet.microsoft.com/wiki/contents/articles/5392.active-directory-ldap-syntax-filters.aspx