LDAP Authenticated Deep Dive
Beyond user and group enumeration, authenticated LDAP access exposes domain trusts, Group Policy objects, organizational unit structure, computer accounts, and ACL configurations that reveal attack paths not visible in basic queries. Run this when you have credentials and need a complete picture of the domain before planning your next move.
Domain and forest structure
trustDirection values: 1 = inbound (they trust us), 2 = outbound (we trust them), 3 = bidirectional. An outbound trust means accounts from the trusted domain can authenticate in this domain. trustAttributes value 8 means the trust is transitive — it extends to all domains trusted by the trusted domain. For exploitation paths, see AD Domain Trust Abuse.
Organizational units
OU structure tells you how the environment is organised and where specific computer types and users live. High-value OUs to note: servers, domain controllers, service accounts, and any OU that appears locked down differently from the rest.
Explain command
| -x | Use simple authentication instead of SASL. |
| -H ldap://$TARGET_IP | Specify the LDAP server URI to connect to. |
| -D "$USER@$DOMAIN" | Bind DN (distinguished name) used for authentication. |
| -w "$PASSWORD" | Password for the bind DN authentication. |
| -b "$BASE_DN" | Search base DN to start the LDAP query from. |
| (objectClass=organizationalUnit) | LDAP filter to match only organizational unit objects. |
| ou description | Attributes to retrieve: OU name and description. |
| -b "OU=Servers,$BASE_DN" | Restricts search base to the Servers OU subtree. |
| (objectClass=computer) | LDAP filter to match only computer objects. |
| dNSHostName operatingSystem | Attributes to retrieve: DNS hostname and OS of computers. |
| ou | Attribute to retrieve: organizational unit name only. |
| grep "^ou:" | Filters output to lines starting with the ou attribute. |
Computer accounts
Computer accounts are often overlooked as attack targets. They have passwords, can have SPNs, and can have delegation configured. A machine account compromise can be leveraged the same way a user account can.
Explain command
| -x | Use simple authentication instead of SASL. |
| -H ldap://$TARGET_IP | Specify the LDAP server URI to connect to. |
| -D "$USER@$DOMAIN" | Bind DN (credentials) used to authenticate to LDAP. |
| -w "$PASSWORD" | Password for the bind DN provided via -D. |
| -b "$BASE_DN" | Base DN defining the search starting point in the directory. |
| (objectClass=computer) | LDAP filter matching all computer objects in the directory. |
| dNSHostName operatingSystem operatingSystemVersion lastLogon sAMAccountName | Requested attributes: DNS name, OS info, last logon time, and account name. |
| (&(objectClass=computer)(servicePrincipalName=*)) | LDAP filter matching computers with at least one SPN set. |
| dNSHostName servicePrincipalName | Requested attributes: DNS hostname and associated SPNs. |
| (&(objectClass=computer)(lastLogon<=133000000000000000)) | LDAP filter matching computers with lastLogon at or before the given timestamp. |
| dNSHostName operatingSystem | Requested attributes: DNS hostname and operating system name. |
Group Policy Objects
GPOs frequently contain useful information — local admin configurations, software deployments, logon scripts, and occasionally hardcoded credentials in script paths. The GPO name alone tells you a lot about what is being configured.
gPCFileSysPath: \\corp.local\SysVol\corp.local\Policies\{31B2F340-016D-11D2-945F-00C04FB984F9}
Explain command
| -x | Use simple authentication instead of SASL. |
| -H ldap://$TARGET_IP | Specify the LDAP server URI to connect to. |
| -D "$USER@$DOMAIN" | Bind DN (distinguished name) used for authentication. |
| -w "$PASSWORD" | Password for the bind DN provided via -D. |
| -b "CN=Policies,CN=System,$BASE_DN" | Search base DN scoped to the Group Policy Policies container. |
| (objectClass=groupPolicyContainer) | LDAP filter matching Group Policy Container objects. |
| displayName | Requested attribute returning the human-readable GPO name. |
| gPCFileSysPath | Requested attribute returning the SYSVOL UNC path of the GPO. |
| -b "$BASE_DN" | Search base DN set to the root of the domain. |
| (gPLink=*) | LDAP filter matching objects that have any GPO link applied. |
| distinguishedName | Requested attribute returning the full DN of matched objects. |
| gPLink | Requested attribute listing GPOs linked to each OU. |
| | grep gPCFileSysPath | Pipes output and filters lines containing the SYSVOL path attribute. |
The gPCFileSysPath value is the UNC path to the GPO's files on SYSVOL. Mount that path via SMB and inspect the scripts and XML files — Group Policy Preferences XML files historically contained encrypted passwords (cpassword) that are trivially decrypted with a published AES key.
ACL-based attack paths
Object ACLs in AD control who can modify objects. Misconfigurations like WriteDACL, GenericWrite, or ForceChangePassword rights on high-value objects allow privilege escalation without exploiting any software vulnerability.
BloodHound is the most practical tool for ACL-based attack path analysis. After collection, the pre-built queries Shortest Paths to Domain Admins and Find Principals with DCSync Rights immediately surface the most direct escalation paths in the environment. For structured ACL enumeration see Active Directory ACL Enumeration; for exploitation see ACL Abuse Privilege Escalation.
Using windapsearch for structured output
windapsearch wraps common AD LDAP queries and formats output cleanly. Faster than raw ldapsearch for most tasks.
Explain command
| -d $DOMAIN | Specifies the target Active Directory domain name. |
| --dc $TARGET_IP | Specifies the IP address of the domain controller to query. |
| -u $USER | Username for LDAP bind authentication. |
| -p $PASSWORD | Password for LDAP bind authentication. |
| -m users | Enumerates all user objects in the domain via LDAP. |
| -m computers | Enumerates all computer objects in the domain via LDAP. |
| -m groups | Enumerates all group objects in the domain via LDAP. |
| -m privileged-users | Enumerates users in high-privilege groups (e.g. Domain Admins). |
| -m gpos | Enumerates all Group Policy Objects in the domain. |
| -m unconstrained-users | Enumerates user accounts with unconstrained Kerberos delegation set. |
| -m unconstrained-computers | Enumerates computer accounts with unconstrained Kerberos delegation set. |
Unconstrained delegation results feed directly into Unconstrained Delegation Abuse. For ADCS template misconfigurations discovered via LDAP, see ADCS Misconfiguration Discovery.
References
-
windapsearch — GitHubgithub.com/ropnop/windapsearch (opens in new tab)
Full module list and custom query syntax
-
BloodHound.py — GitHubgithub.com/dirkjanm/BloodHound.py (opens in new tab)
Linux-based BloodHound data collector
-
SharpHound — GitHubgithub.com/BloodHoundAD/SharpHound (opens in new tab)
Windows-based BloodHound collector, full collection methods
Was this helpful?
Your feedback helps improve this page.