Active Directory Enumeration
Active Directory is a hierarchical database, accessible over LDAP, that describes the whole organization: users, groups, computers, policies, trusts and the permissions between them. What matters to the attacker is that any authenticated domain user can read almost everything: who is an administrator, which accounts have SPNs, which computers have delegation, which ACLs sit on each object. Enumerating AD is drawing the map before attacking: Kerberoasting, ACL paths, delegations, AD CS and the shortest path to Domain Admin all come from here.
flowchart LR
Z["No credentials"] -->|"DNS, rootDSE, null session,<br/>kerbrute, RID cycling"| U["User list<br/>password policy"]
U -->|"AS-REP roasting, spraying"| C["First credential"]
C -->|"LDAP / SMB / BloodHound"| M["Full map:<br/>SPNs, ACLs, delegations,<br/>GPOs, AD CS, trusts"]
M --> A["Attack path"]
Threat model
Section titled “Threat model”AD favors interoperability: computers and applications need to query the directory, so reading it is a default right of any account. That bulk read gives the attacker the privilege map without touching anything broken. For the defender, the queries look legitimate: the challenge is telling reconnaissance apart from normal use.
Anatomy
Section titled “Anatomy”Ports and services on a DC
Section titled “Ports and services on a DC”| Port | Service | What it’s good for |
|---|---|---|
| 53 | DNS | SRV records, machine names |
| 88 | Kerberos | Validating users, roasting |
| 135 / 139 / 445 | RPC / SMB | Users, groups, shares (SYSVOL, NETLOGON), RID cycling |
| 389 / 636 | LDAP / LDAPS | The whole directory |
| 3268 / 3269 | Global catalog | Forest-wide searches |
| 5985 | WinRM | Remote access, if you have permissions |
Directory partitions
Section titled “Directory partitions”- Domain (
DC=corp,DC=local): users, groups, computers, OUs, GPOs. - Configuration (
CN=Configuration,…): sites, services, AD CS (templates and CA). - Schema (
CN=Schema,CN=Configuration,…): class and attribute definitions.
The rootDSE (the empty entry) can be read without authenticating and gives the naming contexts, the DC’s name and the functional level.
Attributes that matter
Section titled “Attributes that matter”| Attribute | What to look for |
|---|---|
userAccountControl |
Flags: DONT_REQ_PREAUTH (0x400000), TRUSTED_FOR_DELEGATION (0x80000), PASSWD_NOTREQD (0x20), DONT_EXPIRE_PASSWORD (0x10000), ACCOUNTDISABLE (0x2) |
servicePrincipalName |
User accounts with an SPN → Kerberoasting |
adminCount |
1 = protected by AdminSDHolder (privileged now or in the past) |
description, info |
Passwords written down by the help desk |
memberOf / member |
Memberships, including nested ones |
pwdLastSet, lastLogonTimestamp |
Old accounts, passwords that never rotate, abandoned accounts |
msDS-AllowedToDelegateTo · msDS-AllowedToActOnBehalfOfOtherIdentity |
Constrained delegation and RBCD (delegation) |
ms-DS-MachineAccountQuota |
How many computers a regular user can create (10 by default) |
nTSecurityDescriptor |
Each object’s DACL (ACL) |
userAccountControl flags are filtered in LDAP with the bitwise AND matching rule
1.2.840.113556.1.4.803:
(&(objectCategory=person)(userAccountControl:1.2.840.113556.1.4.803:=4194304)) # no pre-authentication(&(objectCategory=computer)(userAccountControl:1.2.840.113556.1.4.803:=524288)(!(userAccountControl:1.2.840.113556.1.4.803:=8192))) # unconstrained delegation, DCs excluded (8192)(&(objectCategory=person)(servicePrincipalName=*)) # users with an SPNVariants
Section titled “Variants”| Starting point | What you can get |
|---|---|
| No known internal network | Domain and DC names from DNS and the SMB/LDAP banner |
| No credentials | rootDSE, valid users through Kerberos, sometimes null session and RID cycling |
| Guest account or anonymous session allowed | Users through RID cycling, sometimes shares |
| Any domain account | Practically the whole directory, SYSVOL, full BloodHound |
| Local admin on a machine | Also, that machine’s sessions and local groups |
Red Team
Section titled “Red Team”Without credentials
Section titled “Without credentials”# Locate DCs and the domaindig +short SRV _ldap._tcp.dc._msdcs.corp.localnxc smb 10.10.10.0/24 # each machine's name, domain, version and SMB signingldapsearch -x -H ldap://10.10.10.10 -b '' -s base namingContexts dnsHostName domainFunctionality
# Valid users through Kerberos (no password: the KDC answers differently if the user exists)kerbrute userenum -d corp.local --dc 10.10.10.10 names.txt
# Null or guest session: RID cycling and usersnxc smb 10.10.10.10 -u '' -p '' --usersnxc smb 10.10.10.10 -u 'guest' -p '' --rid-bruteenum4linux-ng -A 10.10.10.10With the user list: AS-REP roasting (needs no passwords) and, minding the lockout policy, password spraying.
With a domain account
Section titled “With a domain account”The first pass, with NetExec:
nxc smb dc01.corp.local -u jdoe -p 'Passw0rd!' --users --groups --shares --pass-polnxc ldap dc01.corp.local -u jdoe -p 'Passw0rd!' --users # includes the descriptionnxc ldap dc01.corp.local -u jdoe -p 'Passw0rd!' --admin-count --trusted-for-delegation --password-not-requirednxc ldap dc01.corp.local -u jdoe -p 'Passw0rd!' -M maq # ms-DS-MachineAccountQuotanxc ldap dc01.corp.local -u jdoe -p 'Passw0rd!' -M adcs # is there AD CS?LDAP 10.10.10.10 389 DC01 -Username- -Last PW Set- -BadPW- -Description-LDAP 10.10.10.10 389 DC01 svc-backup 2018-05-02 10:11:09 0 Backup job. Pass: Backup2018!LDAP 10.10.10.10 389 DC01 helpdesk-admin 2025-11-03 08:40:52 0 Tier 2 supportThe password policy (--pass-pol) decides how many attempts you can make before locking accounts
out: note it down before trying any credential.
For the permission graph, BloodHound (see its card):
bloodhound-python -d corp.local -u jdoe -p 'Passw0rd!' -ns 10.10.10.10 -c All --zip# or with NetExecnxc ldap dc01.corp.local -u jdoe -p 'Passw0rd!' --bloodhound --collection All --dns-server 10.10.10.10Targeted queries with ldapsearch:
ldapsearch -x -H ldap://10.10.10.10 -D 'jdoe@corp.local' -w 'Passw0rd!' -b 'DC=corp,DC=local' \ '(&(objectCategory=computer)(userAccountControl:1.2.840.113556.1.4.803:=524288)(!(userAccountControl:1.2.840.113556.1.4.803:=8192)))' dNSHostNameOther sources with the same account:
adidnsdump -u 'corp.local\jdoe' -p 'Passw0rd!' dc01.corp.local # DNS records in the zonecertipy find -u jdoe@corp.local -p 'Passw0rd!' -dc-ip 10.10.10.10 -vulnerable -stdout # AD CSnxc smb dc01.corp.local -u jdoe -p 'Passw0rd!' -M gpp_password # passwords in SYSVOLFrom a domain-joined Windows machine
Section titled “From a domain-joined Windows machine”With the Active Directory module (if RSAT is installed) or with PowerView:
Get-ADUser -Filter 'servicePrincipalName -like "*"' -Properties servicePrincipalName,memberOf,pwdLastSetGet-ADComputer -Filter 'TrustedForDelegation -eq $true'Get-ADDomain | Select-Object DistinguishedName, DomainMode# PowerViewGet-DomainUser -PreauthNotRequiredGet-DomainUser -Properties samaccountname,description | ? descriptionGet-DomainGPOLocalGroup # who is local admin through GPOFind-DomainShare -CheckShareAccessWhat to do with each finding
Section titled “What to do with each finding”| Finding | Next step |
|---|---|
Password in description |
Validate it and see what it allows |
| Users with an SPN | Kerberoasting |
DONT_REQ_PREAUTH |
AS-REP roasting |
cpassword in SYSVOL |
GPP |
| Abusable ACLs in the graph | ACL abuse |
| Delegation (unconstrained, constrained, RBCD) | Kerberos delegation |
| AD CS with vulnerable templates | AD CS |
ms-DS-MachineAccountQuota > 0 |
Creating computer accounts (RBCD, relay) |
| Readable LAPS or gMSA | Read them (ACL) |
| SMB signing not required on machines | NTLM relay |
| Trusts to other domains | Trust abuse |
Researcher workflow
Section titled “Researcher workflow”- Without credentials: domain, DCs, rootDSE, valid users and policy (if there’s a null session).
- First credential: NetExec (users, groups, shares, policy) and full BloodHound.
- Check descriptions, SYSVOL and AD CS: they’re quick wins.
- List SPNs, accounts without pre-authentication, delegations, LAPS, MAQ and SMB signing.
- In BloodHound, shortest path from your account to Domain Admins and to valuable machines.
- Repeat the enumeration with every new account: permissions change.
- NetExec (card): SMB and LDAP with modules (
maq,adcs,laps,gpp_password…). - BloodHound with bloodhound-python, SharpHound or NetExec.
- ldapsearch, ldapdomaindump, windapsearch, adidnsdump.
- kerbrute, enum4linux-ng, rpcclient.
- Certipy for AD CS.
- PowerView and the Active Directory module on Windows; PingCastle (defensive too).
Impact and chaining
Section titled “Impact and chaining”Enumeration compromises nothing by itself, but it decides the whole attack: which accounts to roast, which ACLs to abuse, which delegation to exploit and which is the shortest path to Domain Admin. Thorough reconnaissance often makes any exploit unnecessary.
Blue Team
Section titled “Blue Team”Detection
Section titled “Detection”- Bulk LDAP queries from a user workstation (SharpHound, ldapdomaindump): spikes of domain-wide searches in a short time.
- Kerberos enumeration: bursts of 4768 with error code
0x6(unknown user) from the same source. - Null sessions and RID cycling: anonymous access to
IPC$and to SAMR/LSARPC. - Honeytokens: a decoy account with an attractive description or a fake SPN; any use or ticket request is an alert.
Telemetry and sources
Section titled “Telemetry and sources”- The DC’s LDAP query log (event 1644, enabled through Field Engineering) to see expensive or bulk filters.
- 4662 with SACLs on sensitive objects; 4768/4769; 5140/5145 on shares.
- Microsoft Defender for Identity (LDAP, account and SMB reconnaissance).
Hardening
Section titled “Hardening”- No null sessions:
RestrictAnonymous,RestrictAnonymousSAM, and remove Anonymous and Everyone from the Pre-Windows 2000 Compatible Access group (leftovers from old domains that allow enumeration without authentication). - Clean descriptions and attributes holding secrets; check SYSVOL too.
ms-DS-MachineAccountQuota = 0and computer joins only by authorized accounts.- Remove unnecessary SPNs and
DONT_REQ_PREAUTH, unconstrained delegations and broad LAPS read permissions. - Audit the domain with PingCastle or Purple Knight and the graph with BloodHound before the attacker does.
Response
Section titled “Response”If you detect reconnaissance, identify the source account and machine, review what it queried to anticipate the next step, and close first the vectors that reconnaissance would have revealed (roasting, ACLs, delegations).
CVEs and real cases
Section titled “CVEs and real cases”- Domain enumeration is a phase in nearly every AD intrusion (MITRE T1087.002, T1069.002, T1482); BloodHound/SharpHound appears in many ransomware incident reports as the step before escalation.
- Passwords in
descriptionand in SYSVOL (GPP, MS14-025) are still common real findings in assessments. - The Pre-Windows 2000 Compatible Access group containing Everyone or Anonymous, inherited from NT4 migrations, allows enumerating the domain without credentials in older domains.
More on MITRE ATT&CK (https://attack.mitre.org/tactics/TA0007/).
Testing checklist
Section titled “Testing checklist”- Domain, DCs and functional level (DNS, rootDSE, SMB banner).
- Valid users without credentials (kerbrute, null session, RID cycling).
- Password and lockout policy noted.
- Users, groups, shares and descriptions with the first credential.
- Full BloodHound collected.
- SPNs, accounts without pre-authentication, delegations,
adminCount. - SYSVOL (GPP, scripts), AD CS, LAPS, gMSA and MAQ.
- SMB and LDAP signing on the machines, and trusts.
- Enumeration repeated with every new account.