Courses3 levels
Level 1 · Foundations11 courses
Level 2 · Core5 courses
Level 3 · Advanced5 courses
Labs8 topics
Library Practice exams AI Range Pricing Start free

Practice library / Active Directory and Windows attacks

Lab · Medium · 1.5 hoursFree account

Active Directory LDAP Enumeration

Raw LDAP queries, from ldapsearch to a Windows foothold, to map users, groups, and leaked secrets.

  • active-directory
  • ldap
  • ldapsearch
  • enumeration
On this page 15 sections
  1. ·Prerequisites
  2. ·Lab Setup
  3. ·Build the target
  4. 1Find the domain's base DN without a credential
  5. 2Test anonymous access to real objects
  6. Locked: Bind with a low-privileged account and list users
  7. Locked: Mine the description for a leaked secret
  8. Locked: Enumerate computers and groups
  9. Locked: Find nested Domain Admins membership
  10. Locked: Read the domain password policy over LDAP
  11. Locked: Cross-platform enumeration with windapsearch
  12. Locked: Query LDAP from a Windows foothold with built-in tools
  13. Locked: Defence and Detection
  14. Locked: Check Your Work
  15. Locked: Clean-up

LDAP is the protocol under BloodHound, PowerView, and CrackMapExec, so every wrapper breaks the same way when a filter is wrong or a port is blocked. A raw LDAP query still works when the toolchain does not, and it also shows the exact attribute a defender watches. The exercises here read users, groups, and nested Domain Admin membership straight from ldapsearch and windapsearch against a lab domain.

Lab Objectives

  • Query Active Directory directly over LDAP, with no BloodHound, PowerView, or CrackMapExec
  • Enumerate users, computers, and groups with ldapsearch and windapsearch
  • Mine the description attribute and other attributes for leaked credentials
  • Find nested Domain Admins membership that a plain group listing never shows
  • Read the domain password policy straight from the domain object
  • Run the same LDAP filters from a Windows foothold with built-in tools alone

BloodHound, PowerView, and CrackMapExec all enumerate Active Directory the same way this lab does: over LDAP. They wrap the protocol in a graph, a PowerShell cmdlet, or a one-line flag. This lab skips the wrapper. Once you can read a distinguished name and write your own filter, every tool built on top of LDAP stops being a black box. Raw LDAP is the fallback that still works when a tool is blocked or missing on the foothold you landed on.

Prerequisites

Finish Active Directory Basics first. It uses the same CORP.LOCAL example domain that this lab queries, and it covers the AD vocabulary — domain, DC, SPN, Kerberos — this lab assumes. If LDAP, distinguished names, or directory attributes are unfamiliar, read the Active Directory Fundamentals workbook first; it explains the schema and the directory tree this lab queries.

Step 9 uses a Windows foothold. The Windows Command Line & PowerShell workbook covers the cmdlets and pipeline syntax that step assumes.

Once you can read and write an LDAP filter by hand, these labs build directly on it. AD Enumeration with PowerView wraps the same filters in PowerShell cmdlets. AD Enumeration with CrackMapExec automates them across a whole subnet. AD Enumeration with BloodHound turns this same data into attack-path graphs.

Lab Setup

Tools, both available on Kali:

  1. ldapsearch, from the ldap-utils package. Run ldapsearch -V to confirm it is installed. Install it with sudo apt install ldap-utils if the command is not found.
  2. windapsearch, a cross-platform Python LDAP client. Clone it and install its requirements: git clone https://github.com/ropnop/windapsearch && cd windapsearch && pip3 install -r requirements.txt.

Build the target

KaliRange hosts no targets, no virtual machines and no lab files. You run this lab on your own machine, against a domain that you build. The names and 192.168.1.x addresses below are the example addresses of this lab. Replace them with the addresses of your own domain.

Your lab domain must have these parts:

HostRole
DC01 (192.168.1.10)Domain Controller of CORP.LOCAL (base DN DC=corp,DC=local), Windows Server 2022 Standard
FILE01Domain-joined member server, Windows Server 2019 Standard, in CN=Computers
A Windows footholdDomain-joined Windows host for Step 9, with dsquery (the AD DS command-line tools)
Your Kali machineThe attack box, on the same network as DC01
  • Domain users in CN=Users: john (John Doe, description Finance helpdesk contact), jane (Jane Smith), svc_sql (description SQL Server service account - do not disable) and Administrator.
  • The password of john is Password123. Use your own password and put it in the commands. john has no special rights. Every authenticated query in this lab uses only this account.
  • The description of jane is Temp acct - reset by svc-provisioning, pwd = Welcome2026!, and that is her real password (Step 4). Use your own password and change both.
  • A group Finance in OU=Groups with the members john and jane.
  • jane is a Domain Admin through nested group membership: a group inside Domain Admins holds her (Step 6). Administrator is a Domain Admin too.
  • Default read permissions, and anonymous reads of objects denied (the default; Step 2).
  • A weak password policy on the domain object: minimum length 8, history 5, lockout threshold 5, lockout duration 30 minutes, maximum password age 90 days (Step 7).
  • On the Windows foothold, you sign in as john over console or RDP (Step 9).

Build such a domain from free, legal parts. Install an evaluation copy of Windows Server from the Microsoft Evaluation Center (180 days) in virtual machines on your own computer, promote one to a domain controller and join the others. Or start from GOAD ("Game of Active Directory"), a deliberately vulnerable Active Directory lab that Orange Cyberdefense publishes on GitHub. Isolate it from the internet. Its names differ from CORP.LOCAL, so change the names in the commands. Take a snapshot of each virtual machine before Step 1.

Run every query in this lab only against a domain that you own or have written permission to test. Querying a directory you do not own, or do not have written permission to test, is unauthorised access in most jurisdictions. An authorised tester only runs these techniques inside a scoped, authorised engagement — and inside CORP.LOCAL, every query in this lab is read-only reconnaissance, never a write.

Step 1: Find the domain's base DN without a credential

1

Query the RootDSE before you touch a credential

Every LDAP server exposes a RootDSE: a special entry at the root of the tree that lists what the server supports, readable with no bind at all. Read it first to get the exact base DN every later query needs.

Run an anonymous, base-scope search against the DC.

ldapsearch -x -H ldap://192.168.1.10 -s base -b "" "(objectClass=*)" namingContexts defaultNamingContext supportedLDAPVersion

Example output:

dn:
namingContexts: DC=corp,DC=local
namingContexts: CN=Configuration,DC=corp,DC=local
namingContexts: CN=Schema,CN=Configuration,DC=corp,DC=local
defaultNamingContext: DC=corp,DC=local
supportedLDAPVersion: 3
supportedLDAPVersion: 2

# numResponses: 2
# numEntries: 1

defaultNamingContext gives the base DN: DC=corp,DC=local. Use this exact string in -b for every query that follows. -x selects simple authentication; with no -D or -w, ldapsearch binds anonymously.

Defender's view: a single RootDSE read from a new source is ordinary LDAP client traffic and rarely alerts on its own. It only becomes a signal as part of a pattern — the first request in a burst of many, from a host that does not normally talk to the DC.

Step 2: Test anonymous access to real objects

2

Try to read directory objects with no account at all

A RootDSE read works against almost every server. Reading real objects with no bind only works on a misconfigured one. Test it — the result decides whether this is a finding or a dead end.

ldapsearch -x -H ldap://192.168.1.10 -b "DC=corp,DC=local" "(objectClass=user)" sAMAccountName

Example output:

# search result
search: 2
result: 0 Success

# numResponses: 1
# numEntries: 0

Zero entries, no error. Since Windows Server 2003, a default-hardened domain controller denies anonymous reads of directory content under its dsHeuristics setting, so this is the expected, secure result. A domain that returns real sAMAccountName values here instead allows anonymous enumeration — record it as a finding, then move to Step 3 for the normal, authenticated path.

Defender's view: an empty result leaves nothing to detect. A domain that does return data here has a configuration gap a defender must close, independent of any query logging.

Sign in to continue

10 more sections are for signed-in members. It is free: sign in with Google.

Related