Before continuing reading, read about LDAP in general. Lightweight Directory Access Protocol (LDAP) is an Internet protocol that works on TCP/IP, used to access information from directories. The LDAP protocol is used to access an Active Directory.
LDAP enumeration is a method of enumeration of the Active Directory. The service typically operates on TCP ports 389 and 639 by default. LDAP enumeration can enumerate usernames, addresses, and loads of juicy information that can be reused for other attacks, such as social engineering attacks. This may include:
- Usernames: Who's inside the system?
- Groups: Which groups or teams are there?
- Computers: What machines are attached to?
- Addresses: Contact or company details.
For ethical hackers or penetration testers, LDAP enumeration helps understand a networkâs structure, which can be useful for security assessments. However, attackers might misuse it for social engineering or other attacks, so itâs critical to perform enumeration only with permission
Tools Used For LDAP Enumeration:
Several tools make LDAP enumeration easier, each with unique strengths. Hereâs a quick overview of the ones weâll cover:
- Nmap: A network scanning utility with LDAP query scripts.
- enum4linux: An enumerating Linux tool for Windows Active Directory information.
- windapsearch: A Python program for comprehensive LDAP queries in Windows domains.
- ldapsearch: A command-line program for accurate LDAP searches.
- JXplorer: A graphical LDAP client for browsing directories visually.
Installing the Tools on Linux
Before we begin, ensure that the tools are installed on your Linux platform (e.g., Ubuntu or Kali Linux). Open a terminal (Ctrl + Alt + T) and enter these commands:
# Update package listsudo apt update# Install Nmapsudo apt install nmap# Install enum4linuxsudo apt install enum4linux# Install ldapsearch (part of openldap-utils)sudo apt install ldap-utils# Install JXplorer (GUI tool)sudo apt install jxplorer
LDAP Enumeration using Nmap:
Using the LDAP-search NSE script of Nmap we can scan for the LDAP service, and then we can attempt other arguments to this script such as LDAP.searchattrib, you can also use the LDAP-brute script, and when you have no valid credentials. It's a good tool for finding LDAP services and pulling details like usernames or server information.
Example 1: Basic LDAP Search
To verify an LDAP service on port 389 and list user accounts:
nmap -p 389 --script ldap-search --script-args 'ldap.username="cn=ldaptest,cn=users,dc=cqure,dc=net",ldap.password=ldaptest,ldap.qfilter=users,ldap.attrib=sAMAccountName' <IP_ADDRESS>- - p 389: It scans the TCP port 389.
- --script ldap-search: This option runs the ldap-search script.
- --script-args: This option specifies credentials and filters (e.g., sAMAccountName for usernames).
- <IP_ADDRESS>: Replace with the target serverâs IP (e.g., 192.168.1.10).

Example 2: Custom LDAP Query
To find Windows servers and their details (e.g., operating system, creation date) use the below command:
nmap -p 389 --script ldap-search --script-args 'ldap.username="cn=ldaptest,cn=users,dc=cqure,dc=net",ldap.password=ldaptest,ldap.qfilter=custom,ldap.searchattrib="operatingSystem",ldap.searchvalue="Windows *Server*",ldap.attrib={operatingSystem,whencreated,OperatingSystemServicePack}' <IP_ADDRESS>- ldap.qfilter=custom: Allows custom filtering.
- ldap.searchvalue="Windows *Server*": Targets Windows Server systems.
- ldap.attrib: Retrieves specific attributes like operatingSystem.
Note: If you donât have credentials try the ldap-brute to test for weak passwords (only with permission):
nmap -p 389 --script ldap-brute <IP_ADDRESS>LDAP Enumeration Using enum4linux:
enum4linux is a Linux tool designed for enumerating Windows Active Directory and SMB services, including LDAP. Itâs excellent for extracting user accounts, groups, and domain details without needing a GUI.
Example: Enumerate Accounts and Groups
To list accounts and groups from an LDAP server:
enum4linux <IP_ADDRESS> | egrep "Account|Domain|Lockout|group"- <IP_ADDRESS>: The target serverâs IP.
- egrep: Filters output to show only lines with âAccount,â âDomain,â âLockout,â or âgroup.â

Note: enum4linux is simple and doesnât require credentials for anonymous queries, though authenticated scans yield more data.
LDAP Enumeration Using Windapsearch:
windapsearch is a Python script that uses LDAP queries to enumerate users, groups, computers, and privileged accounts in a Windows domain. Itâs ideal for penetration testers who have valid credentials.
Example 1: Enumerate Computers
To list computers in the domain:
python3 windapsearch.py --dc-ip <IP_ADDRESS> -u <USERNAME> -p <PASSWORD> --computers- --dc-ip: The domain controllerâs IP.
- -u <USERNAME>: A valid domain username (e.g., domain\user).
- -p <PASSWORD>: The userâs password.
- --computers: Targets computer objects.
Example 2: Enumerate Groups
To list groups:
python3 windapsearch.py --dc-ip <IP_ADDRESS> -u <USERNAME> -p <PASSWORD> --groupsExample 3: Enumerate Domain Admins
To find privileged users (e.g., Domain Admins):
python3 windapsearch.py --dc-ip <IP_ADDRESS> -u <USERNAME> -p <PASSWORD> --daExample 4: Enumerate Privileged Users
To list users with elevated privilege
python3 windapsearch.py --dc-ip <IP_ADDRESS> -u <USERNAME> -p <PASSWORD> --privileged-usersNote: windapsearch is precise and supports CSV output for further analysis, making it a favorite for Active Directory enumeration.
LDAP Enumeration Using Ldapsearch:
LDAP search makes a connection to an LDAP server, and it executes a search by using different paraments. The filter works to the string representation for search filters as defined in RFC 4515 else it uses (objectClass=*).
Example 1: Check Null Credentials
To test if the LDAP server allows anonymous access:
ldapsearch -x -H ldap://<IP_ADDRESS> -D '' -w '' -b "DC=<SUBDOMAIN>,DC=<TLD>"- -x: Uses simple authentication.
- -H ldap://<IP_ADDRESS>: Specifies the LDAP server.
- -D '' -w '': Attempts anonymous login (no username or password).
- -b "DC=<SUBDOMAIN>,DC=<TLD>": Sets the search base (e.g., DC=example,DC=com).
Example 2: Validate Credentials
To query with valid credentials:
ldapsearch -x -H ldap://<IP_ADDRESS> -D '<DOMAIN>\<USERNAME>' -w '<PASSWORD>' -b "DC=<SUBDOMAIN>,DC=<TLD>"- -D '<DOMAIN>\<USERNAME>': The userâs domain and username (e.g., MYDOM\john).
- -w '<PASSWORD>': The password.
- -b: The search base.
Note: For secure connections, use LDAPS (-H ldaps://<IP_ADDRESS>:636). If you get a âbind must be completedâ error, the credentials are invalid.
LDAP Enumeration with JXplorer
JXplorer is a graphical LDAP client that lets you browse and query LDAP directories visually, like a file explorer for Active Directory. Itâs great for beginners who prefer a GUI over the command line.
1. Launch JXplorer from the terminal:
jxplorer2. Connect to the LDAP server:
- Host: Enter the serverâs IP or hostname.
- Port: Use 389 for LDAP or 636 for LDAPS.
- Base DN: Set to DC=<SUBDOMAIN>,DC=<TLD> (e.g., DC=example,DC=com).
- User DN/Password: Enter credentials or leave blank for anonymous access.
3. Browse the directory tree to view users, groups, or computers.
Security Considerations
LDAP enumeration can reveal sensitive data so we need to responsibly use it don't use this without permission, here are some security consideration:
- Ethical Use: Do not enumerate systems unless authorized since it can be equated to illegal hacking.
- Secure Connections: Protect credentials and searches with LDAPS on port 636 to prevent exposing sensitive information.
- Limit Anonymous Access: Servers that support unsecured anonymous searches are vulnerable. Secure access through NTLM or Kerberos authentication.
- Validate Inputs: When using windapsearch or ldapsearch, ensure the credential and filter values are accurate, or else they will be subjected to LDAP
- Monitor Logs: Inspect LDAP server lists and monitor for suspicious searching activity as they might act as indicators of enumeration children reactions.
Why Use LDAP Enumeration
LDAP enumeration is valuable for:
- Security Testing: Direct penetration testers and assist them in determining vulnerabilities within Active Directory.
- Network Management: Assist system administrators while they audit user/group accounts.
- Learning: Teaches cybersecurity students about LDAP and directory services.
Conclusion
LDAP enumeration is a key skill for exploring Active Directory and understanding network structures. By using Nmap, enum4linux, windapsearch, ldapsearch, and JXplorer, you can uncover usernames, groups, and more on TCP ports 389 and 636. Whether youâre securing a network or learning cybersecurity, LDAP enumeration is a must-know technique.

