A lot of information on an AD domain can be obtained through LDAP. Most of the information can only be obtained with an authenticated bind but metadata (naming contexts, DNS server name, Domain Functional Level (DFL)) can be obtainable anonymously, even with anonymous binding disabled.
The ldeep (Python) tool can be used to enumerate essential information like delegations, gpo, groups, machines, pso, trusts, users, and so on.
# remotely dump information ldeepldap-u"$USER"-p"$PASSWORD"-d"$DOMAIN"-sldap://"$DC_IP"all"ldeepdump/$DOMAIN"# parse saved information (in this case, enumerate trusts)ldeepcache-d"ldeepdump"-p"$DOMAIN"trusts
# list naming contextsldapsearch-h"$DC_IP"-x-sbasenamingcontextsldapsearch-H"ldap://$DC_IP"-x-sbasenamingcontexts# enumerate info in a base (e.g. naming context = DC=DOMAIN,DC=LOCAL)ldapsearch-h"$DC_IP"-x-b"DC=DOMAIN,DC=LOCAL"ldapsearch-H"ldap://$TARGET"-x-b"DC=DOMAIN,DC=LOCAL"
The ldapsearch-ad Python script can also be used to enumerate essential information like domain admins that have their password set to never expire, default password policies and the ones found in GPOs, trusts, kerberoastable accounts, and so on.
ldapsearch-ad --type all --server $DOMAIN_CONTROLLER --domain $DOMAIN --username $USER --password $PASSWORD
The FFL (Forest Functional Level), DFL (Domain Functional Level), DCFL (Domain Controller Functionality Level) and naming contexts can be listed with the following command.
ldapsearch-ad --type info --server $DOMAIN_CONTROLLER --domain $DOMAIN --username $USER --password $PASSWORD
The windapsearch script (Go (preferred) or Python) can be used to enumerate basic but useful information.
With Impacket's ntlmrelayx (Python), it is possible to gather lots of information regarding the domain users and groups, the computers, ADCS, etc. through a NTLM authentication relayed within an LDAP session.
# list PKIs/CAsnxcldap"domain_controller"-d"domain"-u"user"-p"password"-Madcs# list subnets referenced in AD-SSnxcldap"domain_controller"-d"domain"-u"user"-p"password"-Msubnets# machine account quotanxcldap"domain_controller"-d"domain"-u"user"-p"password"-Mmaq# users descriptionnxcldap"domain_controller"-d"domain"-u"user"-p"password"-Mget-desc-users
The PowerShell equivalent to netexec's subnets modules is the following
LDAP anonymous binding is usually disabled but it's worth checking. It could be handy to list the users and test for ASREProasting (since this attack needs no authentication).
Automation and scripting
A more advanced LDAP enumeration can be carried out with BloodHound (see this).
The enum4linux tool can also be used, among other things, for LDAP recon (see this).