> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/de/active-directory/enumeration/ldapsearch.md).

# LDAP-Suche

### Testen des anonymen LDAP-Zugriffs

{% code overflow="wrap" %}

```bash
ldapsearch -x -H ldap://172.16.0.100 -b "DC=whoami,DC=local"
```

{% endcode %}

Dieser Befehl versucht, LDAP ohne Authentifizierung abzufragen.

In vielen modernen Umgebungen ist der anonyme Zugriff eingeschränkt oder deaktiviert.

### LDAP-Verbindung mit Anmeldedaten

{% code overflow="wrap" %}

```bash
ldapsearch -x -H ldap://172.16.0.100 -D 'WHOAMI\user1' -w 'password' -b "DC=whoami,DC=local"
```

{% endcode %}

Erklärung:

| Option | Rolle                             |
| ------ | --------------------------------- |
| `-x`   | Einfache Authentifizierung        |
| `-H`   | LDAP-Serveradresse                |
| `-D`   | Zum Anmelden verwendete Identität |
| `-w`   | Passwort                          |
| `-b`   | DN-Datenbank durchsuchen          |

<figure><img src="/files/d05eaae11d543008d12fd95c54e108c1f253cabc" alt=""><figcaption></figcaption></figure>

### Benutzer auflisten in `CN=Users`

{% code overflow="wrap" %}

```bash
ldapsearch -x -H ldap://172.16.0.100 -D 'WHOAMI\user1' -w 'password' -b "CN=Users,DC=whoami,DC=local"
```

{% endcode %}

Hier suchen wir im Standardcontainer `Benutzer`.

### Eine OU auflisten

Wenn sich die Benutzer in einer Organisationseinheit befinden, verwenden wir `OU` anstelle von `CN`:

{% code overflow="wrap" %}

```bash
ldapsearch -x -H ldap://172.16.0.100 -D 'WHOAMI\user1' -w 'password' -b "OU=Users,DC=whoami,DC=local"
```

{% endcode %}

Wichtiger Unterschied:

| Element | Bedeutung                                  |
| ------- | ------------------------------------------ |
| `CN`    | Common Name, Container oder Standardobjekt |
| `OU`    | Organisationseinheit                       |
| `DC`    | Domänenkomponente                          |

### Nach einem bestimmten Benutzer suchen

{% code overflow="wrap" %}

```bash
ldapsearch -x -H ldap://172.16.0.100 -D 'WHOAMI\user1' -w 'password' -b "CN=user1,CN=Users,DC=whoami,DC=local"
```

{% endcode %}

Dieser Befehl zielt direkt auf das `user1` Objekt.

<figure><img src="/files/d7560a34c0062b42e566bb0a51ac8f0120f3639a" alt=""><figcaption></figcaption></figure>

### Computer auflisten

{% code overflow="wrap" %}

```bash
ldapsearch -x -H ldap://172.16.0.100 -D 'WHOAMI\user1' -w 'password' -b "CN=computers,DC=whoami,DC=local"
```

{% endcode %}

Bitte beachten Sie: In Active Directory heißt der Standardcontainer im Allgemeinen `CN=Computers`.

### Die integrierte Administratorengruppe auflisten

{% code overflow="wrap" %}

```bash
ldapsearch -x -H ldap://172.16.0.100 -D 'WHOAMI\user1' -w 'password' -b "CN=Administrators,CN=Builtin,DC=whoami,DC=local"
```

{% endcode %}

Dieser Befehl zielt auf die integrierte lokale Gruppe `Administratoren` in `Builtin` Container.

<figure><img src="/files/7fe190b30fd60d871db7a27542252e85204edd9d" alt=""><figcaption></figcaption></figure>

### Den DN eines Benutzers finden

```bash
ldapsearch -x -H ldap://172.16.0.100 -D 'WHOAMI\user1' -w 'password' -b "CN=user1,CN=Users,DC=whoami,DC=local" | grep dn
```

Beispielergebnis:

```bash
CN=user1,CN=Users,DC=whoami,DC=local
```

* Das **DN**oder **Ausgezeichneter Name**, ist der vollständige LDAP-Pfad des Objekts.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://hacking-notes.jord4n.pro/de/active-directory/enumeration/ldapsearch.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
