# 389 - LDAP

### LDAP Enumeration

```bash
# reveal the structure of the directory
ldapsearch -x -H ldap://10.10.10.100 -s base namingcontexts

# dumps everything it can see from the domain root
ldapsearch -x -H ldap://10.10.10.100 -b 'DC=CANDY,DC=LOCAL' -s sub

# Return list of active users
ldapsearch -x -H 'ldap://10.10.10.100' -D 'SVC_TGS' -w 'password1' -b 
"dc=toffee,dc=bth" -s sub "(&(objectCategory=person)(objectClass=user)(!
(useraccountcontrol:1.2.840.113556.1.4.803:=2)))" samaccountname

# Get list of SPN's
ldapsearch -x -H 'ldap://10.10.10.100' -D 'SVC_TGS' -w 'password1' -b 
"dc=toffee,dc=bth" -s sub "(&(objectCategory=person)(objectClass=user)(!
(useraccountcontrol:1.2.840.113556.1.4.803:=2))(serviceprincipalname=*/*))" 
serviceprincipalname

# Get list of AD Users
impacket-GetADUsers -all toffee.bth/svc_tgs -dc-ip 10.10.10.100
# Get Domain Info via JSON and HTML Files
ldapdomaindump ldaps://192.168.46.132 -u 'ONEPIECE\rzoro' -p 'Password1'
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://gokulkarthik.gitbook.io/pentesting-checklist/windows-and-active-directory/protocol-enumeration/389-ldap.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
