LDAP (Lightweight Directory Access Protocol) is the standard protocol for accessing and managing directory services. Per RFC 4511, LDAP defines operations for querying, adding, modifying, and deleting entries in a hierarchical directory. In IT environments, LDAP is most commonly associated with Active Directory, but it's also the protocol behind OpenLDAP, 389 Directory Server, and cloud directory services like Entra ID Secure LDAP.
Key takeaways
- LDAP is the standard protocol for querying directory services like Active Directory (RFC 4511).
- Runs on port 389 (plaintext) or 636 (LDAPS with TLS). Always use LDAPS in production.
- Core operations: Bind (authenticate), Search (query), Modify, Add, Delete.
- Distinguished Names (DNs) like CN=user,OU=Users,DC=contoso,DC=com identify directory entries.
- LDAP channel binding and signing should be enforced in AD to prevent relay attacks.
Quick explanation
In simple terms
LDAP is the standard way applications talk to directory services (like Active Directory) to look up user information, verify passwords, and manage accounts.
Technical definition
LDAP is an application-layer protocol (RFC 4511) for accessing and managing X.500-based directory services over TCP/IP. It uses a hierarchical data model (DIT), identifies entries by Distinguished Names, and supports operations including Bind, Search, Compare, Add, Modify, Delete, and Extended.
Analogy
LDAP is like a phone book lookup system. You connect to the phone book service (bind), search for a person by name (search filter), and get back their address and phone number (attributes). LDAPS is like making that call over an encrypted line.
Definition
LDAP is the standard protocol for querying and modifying entries in directory services like Active Directory and OpenLDAP. It defines operations for authentication (bind), search, add, modify, and delete over TCP port 389 (plaintext) or 636 (TLS).
LDAP stands for Lightweight Directory Access Protocol. Per RFC 4511, it's an application-layer protocol for accessing and managing distributed directory information services over TCP/IP. LDAP was designed as a simpler alternative to the X.500 Directory Access Protocol (DAP), removing the OSI networking requirement.
In practice, LDAP is the primary protocol used to query Active Directory, OpenLDAP, and other directory services. Applications use LDAP to authenticate users (bind), search for user and group information, and manage directory entries. LDAP runs on TCP port 389 for plaintext and TCP port 636 for LDAPS (LDAP over TLS).
Why it matters
Core concepts
Distinguished Name (DN)
The unique path that identifies an entry in the directory tree.
Every entry in the directory has a DN that describes its position in the tree. The DN is composed of Relative Distinguished Name (RDN) components separated by commas, reading from the most specific (CN=) to the root (DC=).
Example
CN=John Doe,OU=Users,DC=contoso,DC=com
Why it matters — DNs are used in every LDAP operation to identify the target entry. Incorrect DNs are the most common cause of LDAP query failures.
Bind (Authentication)
The authentication step where a client presents credentials to the directory server.
Bind is the first operation in an LDAP session. Simple bind sends a DN and password. SASL bind uses a negotiated mechanism (GSSAPI for Kerberos, DIGEST-MD5). Anonymous bind uses no credentials but most production directories disable it.
Example
A web application binds to AD using a service account: CN=svc-app,OU=Service Accounts,DC=contoso,DC=com with a password.
Why it matters — Simple bind over plaintext LDAP (port 389) sends the password in cleartext. This is why LDAPS or StartTLS is critical.
Search Filters
A string expression that specifies which entries to return from a search.
LDAP filters use prefix notation with operators: & (AND), | (OR), ! (NOT), = (equals), ~= (approx), >= (greater), <= (less), * (wildcard). Per RFC 4515, filters are enclosed in parentheses and can be nested.
Example
(&(objectClass=user)(department=Engineering)(!(userAccountControl:1.2.840.113556.1.4.803:=2))) returns active Engineering users.
Why it matters — Efficient filters reduce server load and network traffic. Poorly constructed filters can time out or return too many results on large directories.
How it works
Client connects to the directory server
An LDAP client opens a TCP connection to the directory server on port 389 (plaintext) or 636 (LDAPS). For LDAPS, TLS negotiation happens before any LDAP traffic.
Client → TCP Connect → Server
Authentication via Bind operation
The client sends a Bind request with credentials. The server validates them and returns a Bind response with a result code (0 = success, 49 = invalid credentials).
Bind Request → Authentication
Directory operations
The client sends Search, Add, Modify, or Delete operations. Searches include a base DN, scope (base/one-level/subtree), and filter. The server processes the operation against the DIT and returns entries or a result code.
Search/Modify → DIT → Results
Session teardown
The client sends an Unbind operation to close the session. The server releases resources associated with the connection.
Unbind → Connection closed
Benefits
Universal directory access standard
LDAP is an IETF standard (RFC 4511) supported by virtually every directory service, application, and operating system.
Efficient querying with filters
LDAP search filters allow precise queries against large directories with millions of entries.
Cross-platform compatibility
Every major platform supports LDAP: Windows (Active Directory), Linux (OpenLDAP, 389DS), macOS (Open Directory), and cloud (Entra ID via Secure LDAP).
Limitations
Plaintext LDAP exposes credentials
HighLDAP on port 389 sends credentials and data in cleartext, making it vulnerable to interception and man-in-the-middle attacks.
Workaround — Use LDAPS (port 636) or StartTLS. Per Microsoft, enforce LDAP channel binding and signing in Active Directory.
Complex queries can strain the server
MediumBadly constructed search filters or overly broad base DNs can cause timeouts and high server CPU on large directories.
Workaround — Use indexed attributes in filters. Narrow the base DN. Set result size limits (MaxResultSetSize).
Architecture
LDAP follows a client-server model. Clients connect to a directory server, authenticate (bind), and perform operations against the Directory Information Tree (DIT). Per RFC 4511, LDAP defines operations for search, compare, add, modify, delete, and extended operations.
Directory server
Stores directory data in a hierarchical tree (DIT) and responds to LDAP queries.
Active Directory Domain Services (AD DS) on Windows Server.
LDAP client
Initiates connections, sends operations (bind, search, modify), and processes results.
An application using System.DirectoryServices.Protocols in .NET to query AD for user attributes.
Directory Information Tree (DIT)
The hierarchical data structure that organizes directory entries using Distinguished Names (DNs).
DC=contoso,DC=com as the root, with OU=Users and CN=John Doe underneath.
Data flow
Client connects to port 389 (or 636 for TLS). Client sends a Bind operation with credentials. Server authenticates and returns a bind response. Client sends Search, Add, Modify, or Delete operations. Server processes against the DIT and returns results with status codes.
Architecture limitations
Examples
PowerShell LDAP query against Active Directory
An IT admin queries Active Directory for all users in the Engineering OU using PowerShell.
The PowerShell cmdlet sends an LDAP search to AD with a filter for user objects in the specified OU. The base DN is the OU, the scope is subtree, and the filter is (objectClass=user).
ldapsearch command-line query
A Linux admin uses ldapsearch to find a user in OpenLDAP.
ldapsearch connects to the LDAP server at ldap.contoso.com on port 636 (LDAPS), binds with the specified DN and password, searches the dc=contoso,dc=com tree for objects with uid=jdoe.
Comparisons
LDAP vs. Kerberos
LDAP vs. SAML/OIDC
Myths, corrected
Myth
LDAP is outdated and replaced by modern protocols
Correction
LDAP remains the primary protocol for on-premises directory access. Per Microsoft, Active Directory still uses LDAP as its core query protocol. Cloud directories like Entra ID offer LDAP via Secure LDAP for legacy app compatibility.
Why it happens: The rise of REST APIs (Graph API) and federation protocols (OIDC/SAML) for cloud applications creates a perception that LDAP is obsolete, but it serves a different purpose.
Myth
LDAPS is always more secure than StartTLS
Correction
Both encrypt the LDAP connection with TLS. LDAPS uses a dedicated port (636) and encrypts from the first byte. StartTLS upgrades a plaintext connection on port 389. Both are acceptable when properly configured. The key is that TLS is used, not which method initiates it.
Why it happens: Port 636 'feels' more secure because it's a separate encrypted port, but the encryption is equivalent.
Practical implications
For admins
Enforce LDAPS and disable plaintext LDAP in production AD environments. Monitor LDAP query performance and set MaxResultSetSize.
For MSPs
Many legacy LOB applications rely on LDAP bind for authentication. Plan migration paths to OIDC/SAML for new deployments.
For business
LDAP enables centralized identity management. Directory service downtime blocks authentication for all connected applications.
For security
Audit LDAP traffic for plaintext binds. Enforce channel binding and LDAP signing. Monitor for LDAP injection in web applications.
Decision guide
Use when
- You need to query or modify Active Directory or OpenLDAP entries.
- Legacy applications require LDAP bind for authentication.
- Cross-platform directory access is needed (Windows, Linux, macOS).
Avoid when
- Building new web applications (use OIDC/SAML instead).
- Querying Entra ID exclusively (use Microsoft Graph API, which is REST-based).
Alternatives
- SCIM for cloud directory provisioning
- Microsoft Graph API for Entra ID queries
- OIDC/SAML for web application SSO
Related terms
Active Directory
Microsoft's directory service that uses LDAP as its primary query protocol.
LDAPS
LDAP over TLS on port 636, encrypting all directory communication.
Kerberos
An authentication protocol used alongside LDAP in Active Directory environments.
Frequently asked questions
What is the difference between LDAP and LDAPS?
LDAP (port 389) transmits data in plaintext. LDAPS (port 636) wraps the entire LDAP connection in TLS encryption. StartTLS upgrades a plaintext LDAP connection on port 389 to TLS without changing ports.
What port does LDAP use?
LDAP uses TCP port 389 for plaintext connections and TCP port 636 for LDAPS (TLS-encrypted) connections. Global Catalog uses ports 3268 (plaintext) and 3269 (TLS).
What is LDAP injection?
LDAP injection occurs when user input is inserted into LDAP queries without sanitization. An attacker can modify the query logic to bypass authentication or extract directory data. Always sanitize and escape special characters in LDAP filters.
Is LDAP the same as Active Directory?
Active Directory is Microsoft's directory service. LDAP is the protocol used to query it. AD supports LDAP as its primary access protocol, along with Kerberos for authentication and DNS for service location.
What is LDAP channel binding?
Per Microsoft, LDAP channel binding and signing should be enforced in AD to prevent NTLM relay attacks. This has been required by default in recent Windows Server versions.
Conclusion
LDAP (Lightweight Directory Access Protocol) is the standard protocol for querying and modifying directory services. Per RFC 4511, it defines operations for bind, search, add, modify, and delete against a hierarchical Directory Information Tree.
In Active Directory environments, LDAP runs on port 389 (plaintext) and 636 (LDAPS with TLS). Per Microsoft, channel binding and LDAP signing should be enforced to prevent relay attacks. Always use LDAPS or StartTLS to protect credentials in transit.
Main takeaway
Explore LDAP signing and channel binding enforcement in Active Directory, and Entra ID Secure LDAP for cloud directory access.






-640x640.webp&w=3840&q=75)