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

# LDAP-поиск

### Проверка анонимного доступа к LDAP

{% code overflow="wrap" %}

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

{% endcode %}

Эта команда пытается выполнить запрос к LDAP без аутентификации.

Во многих современных средах анонимный доступ ограничен или отключён.

### Подключение к LDAP с учётными данными

{% code overflow="wrap" %}

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

{% endcode %}

Объяснение:

| Параметр | Роль                                  |
| -------- | ------------------------------------- |
| `-x`     | Простая аутентификация                |
| `-H`     | Адрес LDAP-сервера                    |
| `-D`     | Идентификатор, используемый для входа |
| `-w`     | Пароль                                |
| `-b`     | База поиска DN                        |

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

### Список пользователей в `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 %}

Здесь мы ищем в стандартном контейнере `Users`.

### Список OU

Если пользователи находятся в организационной единице, мы используем `OU` вместо `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 %}

Важное отличие:

| Элемент | Значение                                      |
| ------- | --------------------------------------------- |
| `CN`    | Common Name, контейнер или стандартный объект |
| `OU`    | Организационная единица                       |
| `DC`    | Компонент домена                              |

### Поиск конкретного пользователя

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

Эта команда напрямую обращается к `user1` объекту.

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

### Список компьютеров

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

Обратите внимание: в Active Directory стандартный контейнер обычно называется `CN=Computers`.

### Список встроенной группы Administrators

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

Эта команда обращается к встроенной локальной группе `Administrators` в `Builtin` контейнере.

<figure><img src="/files/572109e22a5e6342ea10807108a1d72fedbf3c1d" alt=""><figcaption></figcaption></figure>

### Найдите DN пользователя

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

Пример результата:

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

* У **DN**или **Отличительное имя**, это полный путь LDAP этого объекта.


---

# 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/ru/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.
