> 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/ar/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/747925bb70654566bdaddc1c3702104e994195cf" 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 %}

هنا، نحن نبحث في الحاوية القياسية `المستخدمين`.

### سرد وحدة تنظيمية

إذا كان المستخدمون موجودين في وحدة تنظيمية، فإننا نستخدم `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`   | الاسم الشائع، أو الحاوية، أو الكائن القياسي |
| `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/661d53e04825ca08e4cd7043ffbbddd6bf32fe27" 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`.

### سرد مجموعة المسؤولين المدمجة

{% 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/5df3319b20a8045e93978dc4361e714faf798a16" 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/ar/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.
