---
title: 'LDAP enumeration'
url: 'https://www.rawrso.me/ethical-hacking/cheat-sheets/ldap-enumeration'
markdown: 'https://www.rawrso.me/ethical-hacking/cheat-sheets/ldap-enumeration.md'
date: '2026-11-22'
description: 'Field Detail Summary Query AD over LDAP — users, SPNs, delegation, ACLs Category Windows/AD directory enumeration Phase enumeration Interface CLI Platform Linux Licence Open source Docs https://github.com/dirkjanm/ldapdomaindump / https://github.com/ropnop/windapsearch Related …'
taxonomy:
  category:
    - cheat-sheets
  tag:
    - pentest
    - cheatsheet
    - windows-ad-directory-enumeration
    - enumeration
---

# LDAP enumeration

| Field | Detail |
|---|---|
| **Summary** | Query AD over LDAP — users, SPNs, delegation, ACLs |
| **Category** | Windows/AD directory enumeration |
| **Phase** | enumeration |
| **Interface** | CLI |
| **Platform** | Linux |
| **Licence** | Open source |
| **Docs** | https://github.com/dirkjanm/ldapdomaindump / https://github.com/ropnop/windapsearch |
| **Related** | SMB and Active Directory enumeration, BloodHound and SharpHound, NetExec (CrackMapExec), Rubeus |

Active Directory *is* an LDAP directory. Querying it (#tcp/389, LDAPS #tcp/636, Global Catalog #tcp/3268) pulls users, groups, computers, policies, ACLs, SPNs and more — often with just a single low-priv credential, sometimes anonymously.

> **ℹ️ Note — Low-noise, high-value**LDAP reads are quiet compared with SMB host-by-host enumeration and are the backbone of what BloodHound and SharpHound collects. Still, do it with valid, in-scope creds.

## Find the base DN

```bash
# Anonymous base query — often reveals the naming context even without creds
ldapsearch -x -H ldap://10.10.10.5 -s base namingcontexts
ldapsearch -x -H ldap://10.10.10.5 -s base '(objectclass=*)'
#   -> defaultNamingContext: DC=corp,DC=local
```

## ldapsearch (the raw tool)

```bash
# Authenticated dump of a subtree
ldapsearch -x -H ldap://10.10.10.5 -D 'jdoe@corp.local' -w 'Pass' \
   -b 'DC=corp,DC=local'

# All users (sAMAccountName only)
ldapsearch -x -H ldap://10.10.10.5 -D 'jdoe@corp.local' -w 'Pass' \
   -b 'DC=corp,DC=local' '(objectClass=user)' sAMAccountName

# Useful targeted filters
'(objectClass=user)'                                 # users
'(objectClass=group)'                                # groups
'(objectClass=computer)'                             # computers
'(&(objectClass=user)(servicePrincipalName=*))'      # Kerberoastable (SPN set)
'(userAccountControl:1.2.840.113556.1.4.803:=4194304)'  # AS-REP roastable (no pre-auth)
'(userAccountControl:1.2.840.113556.1.4.803:=524288)'   # unconstrained delegation
'(adminCount=1)'                                     # protected/privileged accounts
'(memberOf=CN=Domain Admins,CN=Users,DC=corp,DC=local)'
```

Bit-filter OID `1.2.840.113556.1.4.803` = "bit set in userAccountControl" — memorise the common UAC values above.

## windapsearch (friendly wrapper)

```bash
windapsearch -d corp.local -u jdoe@corp.local -p 'Pass' --dc-ip 10.10.10.5 -U   # users
windapsearch ... -G            # groups
windapsearch ... -C            # computers
windapsearch ... --da          # Domain Admins members
windapsearch ... -PU           # privileged users
windapsearch ... --unconstrained-users
windapsearch ... -m <module>
```

## ldapdomaindump (dump everything to HTML/JSON/CSV)

```bash
ldapdomaindump -u 'corp.local\jdoe' -p 'Pass' 10.10.10.5
ldapdomaindump ldaps://10.10.10.5 -u 'corp.local\jdoe' -p 'Pass' -o loot/
```

Produces browsable `domain_users.html`, `domain_groups.html`, `domain_computers.html`, `domain_policy.html`, etc. — the quickest way to get a readable offline picture of the domain.

## NetExec LDAP module (fastest for specific wins)

```bash
nxc ldap 10.10.10.5 -u jdoe -p 'Pass' --asreproast asrep.txt
nxc ldap 10.10.10.5 -u jdoe -p 'Pass' --kerberoasting kerb.txt
nxc ldap 10.10.10.5 -u jdoe -p 'Pass' --trusted-for-delegation
nxc ldap 10.10.10.5 -u jdoe -p 'Pass' --password-not-required
nxc ldap 10.10.10.5 -u jdoe -p 'Pass' -M get-desc-users     # descriptions (passwords get left here!)
```

## Quick wins to grep for

- **User descriptions / comments** — admins still stash passwords there.
- **SPNs** → Kerberoast targets (Rubeus / Impacket).
- **"Password not required"** / **"password never expires"** accounts.
- **Delegation** flags (unconstrained/constrained) → escalation paths.
- **Group memberships** → who's effectively Domain Admin.
- **Password policy** (`domain_policy.html`) → lockout threshold **before** any spraying with NetExec (CrackMapExec).

## More LDAP queries & tooling

```bash
# Passwords stashed in description, enabled/disabled accounts, trusts, GPOs
ldapsearch -x -H ldap://dc -D u@d -w p -b "DC=corp,DC=local" "(description=*)" description sAMAccountName
#   '(userAccountControl:1.2.840.113556.1.4.803:=2)'        -> disabled accounts
#   '(!(userAccountControl:1.2.840.113556.1.4.803:=2))'     -> enabled accounts
#   '(objectClass=trustedDomain)'   '(objectClass=groupPolicyContainer)'
ldeep ldap -u u -p p -d corp.local -s ldap://dc all ./loot    # structured full dumper
# NetExec LDAP modules
nxc ldap dc -u u -p p -M adcs          # find AD CS (-> Certipy)
nxc ldap dc -u u -p p -M laps          # read LAPS local-admin passwords (if permitted)
nxc ldap dc -u u -p p -M maq           # MachineAccountQuota (can you add a computer?)
nxc ldap dc -u u -p p -M get-desc-users
```

## Kill-chain usage

### Enumeration

```bash
ldapsearch -x -H ldap://dc -b "DC=corp,DC=local" "(objectClass=user)"
```

## Where it fits

The quiet enumeration core of AD work — run right after you get any domain credential, alongside SMB and Active Directory enumeration. The output seeds roasting (Rubeus), spraying targets, and feeds the graph in BloodHound and SharpHound.

---

## Navigation

- Parent: [Pentest Tools — Map of Content](https://www.rawrso.me/ethical-hacking/cheat-sheets.md)
- Previous: [Kubernetes — kube-hunter, kube-bench, kubectl](https://www.rawrso.me/ethical-hacking/cheat-sheets/kubernetes-kube-hunter-and-kube-bench.md)
- Next: [masscan](https://www.rawrso.me/ethical-hacking/cheat-sheets/masscan.md)
