← Back to the list of terms

LDAP Queries

What are LDAP Queries?

LDAP queries (Lightweight Directory Access Protocol) are a standardized format for searching and retrieving data from directory services such as Active Directory (AD). LDAP queries allow administrators and applications to search, modify, add, and delete directory entries—enabling access to information about users, groups, and other objects in a corporate network.

How LDAP Queries work

LDAP queries consist of a base DN (Distinguished Name) and a search filter. For example, the query (&(objectClass=user)(sAMAccountName=jdoe)) finds the user whose sAMAccountName is jdoe. Queries can use logical operators and support both exact and pattern-based matching.

LDAP Query examples:

(objectClass=user) — searches for all users in the domain.

In Active Directory: (objectClass=user) — retrieves a list of all user accounts; attributes like sAMAccountName, can refine the search.

PowerShell: Get-ADUser -Filter {Name -like "John*"} — returns all users whose name starts with “John”.

Verification tools: ldapsearch or PowerShell or PowerShell help validate query correctness.

Linux: ldapsearch -x -b "dc=example,dc=com" "(uid=jdoe)" — searches for a user by UID in the directory.

AD: (&(objectClass=group)(member=uid=jdoe)) —  lists groups that include user jdoe as a member.

OpenLDAP:

(objectClass=inetOrgPerson) — all users.

(&(objectClass=inetOrgPerson)(uid=jdoe)) — user by UID.

(&(objectClass=posixGroup)(cn=admins)) — group by name.

(&(objectClass=inetOrgPerson)(memberOf=cn=admins,ou=groups,dc=example,dc=com)) — members of a specific group.

(&(objectClass=inetOrgPerson)(mail=*@example.com)) — users with email addresses in the example.com domain.

Read also:

Сookies
By continuing to use this site, you agree to our use of cookies.