> 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/es/active-directory/enumeration/ldapsearch.md).

# Búsqueda LDAP

Notas de seguridad de Active Directory para Búsqueda LDAP, que cubren enumeración, Kerberos, credenciales, abuso de ACL, movimiento lateral, flujo de explotación y pasos de validación.

### Probar acceso LDAP anónimo

{% code overflow="wrap" %}

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

{% endcode %}

Este comando intenta consultar LDAP sin autenticación.

En muchos entornos modernos, el acceso anónimo está limitado o deshabilitado.

### Conexión LDAP con credenciales

{% code overflow="wrap" %}

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

{% endcode %}

Explicación:

| Opción | Función                                 |
| ------ | --------------------------------------- |
| `-x`   | Autenticación simple                    |
| `-H`   | Dirección del servidor LDAP             |
| `-D`   | Identidad utilizada para iniciar sesión |
| `-w`   | Contraseña                              |
| `-b`   | Buscar en la base de datos DN           |

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-bd40b7a438e5eec9974aeea789e6d51159e7851f%2Fimage%20(3214).png?alt=media" alt=""><figcaption></figcaption></figure>

### Listar usuarios en `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 %}

Aquí, estamos buscando en el contenedor estándar `Users`.

### Listar una OU

Si los usuarios están en una unidad organizativa, usamos `OU` en lugar de `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 %}

Diferencia importante:

| Elemento | Significado                                |
| -------- | ------------------------------------------ |
| `CN`     | Nombre común, contenedor u objeto estándar |
| `OU`     | Unidad organizativa                        |
| `DC`     | Componente de dominio                      |

### Buscar un usuario específico

{% 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 %}

Este comando apunta directamente al `user1` objeto.

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-87dcb4c2eb100a4353cad9981e8c36cdd2e8bc2a%2Fimage%20(3215).png?alt=media" alt=""><figcaption></figcaption></figure>

### Listar equipos

{% 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 %}

Ten en cuenta: en Active Directory, el contenedor estándar generalmente se llama `CN=Computers`.

### Listar el grupo integrado de Administradores

{% 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 %}

Este comando apunta al grupo local integrado `Administrators` en el `Builtin` contenedor.

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-b9249ba2f57947b2b9ae0a30afb70f0b8fd11403%2Fimage%20(3216).png?alt=media" alt=""><figcaption></figcaption></figure>

### Encontrar el DN de un usuario

```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
```

Resultado de ejemplo:

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

* El **DN**, o **Nombre distinguido**, es la ruta LDAP completa del objeto.


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
