October 31, 2026
LDAP Explained: Understanding the Protocol Behind Active Directory
By Saimur Swarnab
7 min read
Ever wondered how an organization manages thousands of employee accounts, passwords, computers, and access permissions from a centralized system? How does an application know whether a user exists in the corporate directory? And what happens behind the scenes when someone logs in using their domain credentials?
Let's imagine an organization with thousands of employees.
Every employee has a username, an email address, a department, a job role, and specific access permissions. Some employees belong to the IT department, others work in Finance, HR, or Operations.
Now imagine managing all these accounts individually across hundreds of computers and applications.
Sounds complicated, right?
This is where centralized directory services become important.
One of the protocols commonly used to communicate with these directory services is LDAP (Lightweight Directory Access Protocol).
If you're exploring Active Directory, Windows infrastructure, or penetration testing, LDAP is one of those fundamental concepts you should understand.
So, let's break it down.
1. What Exactly Is LDAP?
LDAP stands for Lightweight Directory Access Protocol.
It is an application-layer protocol used to access, search, and manage information stored in directory services over a network.
In simpler terms, LDAP allows applications and systems to communicate with a directory and retrieve information about users, computers, groups, and other resources.
Think of LDAP as a communication language between a client and a directory server.
For example, when an employee attempts to access a corporate application, that application may need to verify the employee's identity against the organization's directory.
It can communicate with the directory server using LDAP.
LDAP isn't a directory service itself. It is a protocol used to interact with directory services.
This distinction is important, especially when learning Microsoft Active Directory.
2. Why Do Organizations Use LDAP?
Let's return to our imaginary organization.
It has thousands of employees and hundreds of systems. Each employee needs access to different resources depending on their responsibilities.
For example:
- An HR employee needs access to HR applications.
- A Finance employee needs access to financial systems.
- An IT administrator needs administrative access to specific infrastructure.
- A regular employee needs access to standard corporate resources.
Managing all these identities separately would create significant administrative overhead.
Instead, organizations use centralized directory services to maintain user identities and related information.
LDAP allows applications and systems to query that directory.
For example, an application might ask:
- Does this username exist?
- What is this employee's email address?
- Which groups does this user belong to?
- Is this account enabled?
- What organizational unit contains this user?
The directory server processes the request and returns information according to the permissions and access policies configured on the server.
This makes centralized identity management much easier.
3. How Does LDAP Actually Work?
Let's understand the communication process.
Imagine an employee trying to log in to an internal application using corporate credentials.
The application needs to communicate with the organization's directory server.
A simplified authentication workflow might look like this:
- The user enters their username and password.
- The application establishes a connection with the LDAP server.
- The application performs an LDAP Bind operation using the appropriate authentication method.
- The directory server validates the credentials.
- The server returns an authentication result.
- If authentication succeeds, the application applies its authorization policies.
One important thing to remember: LDAP authentication and application authorization are not the same.
Authentication answers:
Who are you?
Authorization answers:
What are you allowed to access?
An LDAP authentication success doesn't automatically mean the user has permission to access every resource in the application.
4. Understanding LDAP Directory Structure
Now let's look at how information is organized inside an LDAP directory.
LDAP stores information in a hierarchical structure.
Each object is represented by an entry containing attributes.
For example, a user entry might contain:
- Common name
- Username
- Email address
- Department
- Group membership
A simplified directory structure might look like this:
Let's look at a simplified text representation:
DC=example,DC=com
|
|-- OU=Employees
| |
| |-- CN=Rahim
| |-- CN=Karim
|
|-- OU=IT
|
|-- CN=Administrator
|-- CN=IT SupportDC=example,DC=com
|
|-- OU=Employees
| |
| |-- CN=Rahim
| |-- CN=Karim
|
|-- OU=IT
|
|-- CN=Administrator
|-- CN=IT SupportLet's understand the components.
DC โ Domain Component
Represents a component of the domain name.
For example:
DC=example,DC=com
Represents the domain example.com.
OU โ Organizational Unit
An Organizational Unit is used to organize directory objects into logical containers.
For example:
OU=Employees,DC=example,DC=com
CN โ Common Name
Identifies an object by its common name.
For example:
CN=Rahim,OU=Employees,DC=example,DC=com
This complete path is called a Distinguished Name (DN).
A DN uniquely identifies an entry within the directory.
5. LDAP Ports: What Should You Know?
When working with Active Directory or performing network assessments, understanding LDAP ports is important.
Here are some commonly used ports:
+------+-------------------------+---------------------------------+
| Port | Service | Description |
+------+-------------------------+---------------------------------+
| 389 | LDAP | Standard LDAP communication |
| 636 | LDAPS | LDAP over TLS |
| 3268 | Global Catalog | Active Directory Global Catalog |
| 3269 | Global Catalog over TLS | Secure Global Catalog |
+------+-------------------------+---------------------------------+
+------+-------------------------+---------------------------------+
| Port | Service | Description |
+------+-------------------------+---------------------------------+
| 389 | LDAP | Standard LDAP communication |
| 636 | LDAPS | LDAP over TLS |
| 3268 | Global Catalog | Active Directory Global Catalog |
| 3269 | Global Catalog over TLS | Secure Global Catalog |
+------+-------------------------+---------------------------------+
One important distinction:
LDAP normally uses port 389, while LDAPS uses port 636 to provide TLS-encrypted communication.
LDAP on port 389 can also use StartTLS to establish an encrypted connection.
This matters because directory queries and authentication-related information should be protected against interception.
6. LDAP and Microsoft Active Directory
This is probably the most important section if you're learning Windows infrastructure or Active Directory penetration testing.
People sometimes use LDAP and Active Directory interchangeably.
However, they are not the same thing.
Active Directory (AD) is Microsoft's directory service used to manage identities, computers, groups, and resources within a Windows domain environment.
LDAP is one of the protocols that applications and systems can use to communicate with Active Directory.
Active Directory also uses other protocols, including Kerberos, DNS, and SMB, for different purposes.
For example, when you perform an LDAP query against a Domain Controller, you might retrieve information about:
- Domain users.
- Security groups.
- Computer accounts.
- Organizational Units.
- Group memberships.
- Directory attributes.
Understanding this relationship makes it easier to explore how Windows domain environments operate.
7. LDAP from a Penetration Testing Perspective
Now let's move towards the offensive security side.
Imagine you are performing an authorized penetration test against an Active Directory environment.
During network reconnaissance, you discover that a Domain Controller exposes LDAP services.
What could you learn from it?
Quite a lot, depending on the permissions and configuration.
LDAP can provide valuable information about the domain structure and its directory objects.
A penetration tester might investigate:
- Domain information.
- User accounts and groups.
- Organizational Units.
- Group memberships.
- Service accounts.
- Password policy information.
- Directory permissions.
- Potentially exposed directory attributes.
For example, an incorrectly configured directory might allow unauthenticated users to retrieve information that should only be available to authenticated users.
This could help an attacker understand the organization's internal naming conventions, user accounts, and directory structure.
Some useful tools include:
ldapsearch
A command-line utility used to search LDAP directories.
Example:
ldapsearch -x -H ldap://x.x.1.10 \
-b "DC=example,DC=com"ldapsearch -x -H ldap://x.x.1.10 \
-b "DC=example,DC=com"This performs an LDAP search using an anonymous/simple bind attempt. Whether the server allows access to directory information depends on its configuration.
BloodHound
Used to analyze Active Directory relationships and identify potential attack paths based on collected directory information.
NetExec
Can help assess Windows network services and perform authorized Active Directory enumeration.
Impacket
A collection of Python tools and libraries for interacting with Windows network protocols.
Nmap
Can help identify exposed LDAP services and perform service discovery.
The interesting part is that LDAP enumeration can reveal relationships that might not be obvious from simply looking at an individual user account.
For example, group membership information may help identify privileged accounts or understand how administrative permissions are assigned.
8. Why Should SOC Analysts Care About LDAP?
LDAP isn't only important for penetration testers.
It is also relevant to Blue Teams and SOC analysts.
Active Directory contains valuable information about an organization's identity infrastructure.
If an attacker gains access to the internal network, they may use LDAP queries to discover users, groups, computers, and other directory objects.
This activity is commonly associated with Active Directory reconnaissance.
For example, suspicious LDAP activity might involve:
- Unusual queries for large numbers of user accounts.
- Enumeration of privileged groups.
- Repeated directory searches from unexpected systems.
- Access to sensitive directory attributes.
- Unusual LDAP communication from non-administrative endpoints.
A SOC analyst can investigate such activities using Domain Controller logs, endpoint telemetry, and network monitoring.
MITRE ATT&CK also documents Active Directory discovery techniques, including Account Discovery and Domain Trust Discovery.
The objective is to understand whether directory access is consistent with normal business activity or potentially related to malicious reconnaissance.
This is particularly useful when investigating suspicious activity inside a Windows domain environment.
9. LDAP vs Active Directory: Let's Clear the Confusion
This is a common question when someone starts learning Active Directory.
LDAP is a communication protocol. A directory service used to query and modify directory information stores and manages directory information can communicate with different directory services and uses LDAP and other protocols, not limited to Microsoft. Developed by Microsoft
The easiest way to remember this:
Active Directory is the directory service. LDAP is one of the protocols used to communicate with it.
They work together, but they are not interchangeable terms.
Final Thoughts
When I started exploring Active Directory and Windows domain environments, I frequently came across terms such as LDAP, Kerberos, NTLM, DNS, and SMB.
Initially, they all seemed like separate technologies.
But as I started understanding how they interact, the bigger picture became much clearer.
LDAP is an important part of centralized directory communication. It helps applications retrieve and manage directory information and plays a significant role in many Active Directory environments.
For penetration testers, understanding LDAP helps with directory enumeration and identifying potential misconfigurations.
For SOC analysts, understanding LDAP activity helps investigate suspicious directory access and potential Active Directory reconnaissance.
I'll be sharing more about Kerberos, NTLM, SMB, Active Directory enumeration, and other Windows security concepts as I continue learning.
Don't just memorize the protocols. Understand how they communicate, why they exist, and how attackers and defenders interact with them.