Skip to content
Hi
I wanted to share a small tip if you need to log all LDAP’s query sent to your ADDS’s server.
You can easilly find the correct registry to change there:
You need to set at 5 the key Field Engineering there: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NTDS\Diagnostics
and you need to set to 1 those two keys:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NTDS\Expensive Search Results Threshold
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NTDS\Inefficient Search Results Threshold
For more detail you can find it some documentations there, Creating More Efficient Microsoft Active Directory-Enabled Applications
Thanks everyone
If you’re troubleshooting active directory and need to enable logging, follow these steps:
Enable LDAP auditing
Open Registry Editor. Go to HKEY_LOCAL_MACHINE → SYSTEM → CurrentControlSet → Services → NTDS → Diagnostics. Note: Set ’15 Field Engineering’ to ‘5’. This enables Expensive and Inefficient LDAP calls to be logged in Event Viewer.
View the logs
Unsecure LDAP binds
Go to Event Viewer → Filter Directory Service logs to locate the event ID 2889 (Windows Server 2003 to 2012)
Number of daily unsecure ldap binds
Go to Event Viewer → Filter Directory Service logs to locate the event ID 2887 (Windows Server 2003 to 2012)
Number of LDAP queries
Go to Event Viewer → Filter Directory Service logs to locate the event ID 1643 (Windows Server 2003 to 2012)
Recent LDAP queries
Go to Event Viewer → Filter Directory Service logs to locate the event ID 1644 (Windows Server 2003 to 2012)
Error from the LDAP server
Go to Event Viewer → Filter Directory Service logs to locate the event ID 1535 (Windows Server 2003 to 2012)
Time-out LDAP connection
Go to Event Viewer → Filter Directory Service logs to locate the event ID 1317 (Windows Server 2003 to 2012)
And that’s all for this blog post! Hope this information helps you! ☺️
После внедрения в компании Active Directory на базе Windows 2008 R2 остро ощутили нехватку подробного лога соединений по протоколу LDAP. Необходимость в подобном логе часто возникает при решении задач интеграции в Active Directory различных Linux сервисов.
Под катом — описание метода, позволяющего получить лог содержащий: ip-адрес и порт источника запроса, фильтр поиска, глубина (scope) поиска, запрошенный набор атрибутов, количество записей в результате поиска и т.д.
Предварительно необходимо настроить сеанс отслеживания событий:
- Запустить «Системный монитор»: Пуск → Выполнить… → perfmon.
- Открыть Производительность → Группы сборщиков данных → Сеансы отслеживания событий.
- В контекстном меню Создать → Группа сборщиков данных.
- Задать понятное имя группы. Выбрать «Создать вручную (для опытных)». Нажать «Далее».
- Нажать «Добавить» и выбрать поставщика данных «ActiveDirectory Domain Services: Core». Нажать «Далее».
- Задать папку для сохранения отчёта. Нажать «Далее».
- Выбрать «Сохранить и закрыть». Нажать «Готово».
- Будет создан остановленный сеанс отслеживания событий. Для начала сбора информации следует его запустить. ВАЖНО!!! Запущенный сбор информации неизбежно увеличит нагрузку на ваш сервер — учитывайте это при запуске сбора на высоко нагруженном сервере.
- По завершению сбора событий следует остановить сеанс.
Результатом сбора событий будет .etl файл в заданной папке.
Для анализа содержимого этого файла:
- Запустить командную строку Пуск → Выполнить… → cmd
- Перейти в папку с .elt файлом
- Сконвертировать дамп в .csv для последующего анализа:
> tracerpt *.etl -of csv
обратите внимание — tracerpt умеет выгружать данные не только в csv, но и в xml и evtx.
- На выходе будет два файла:
summary.txt — сводка о захваченных событиях
dumpfile.csv — собственно собранный дамп. Наиболее интересны события типа «DsDirSearch» — в ним будут зарегистрированы: ip и порт источника запроса, фильтр поиска, глубина (scope) поиска, запрошенный набор аттрибутов, количество записей в результате поиска.
P.S. Есть ещё как минимум один способ получить сведения о том, какие запросы поступили в Active Directory и что по ним нашлось: перехват трафика (Wireshark или Network Monitor). Но при использовании ssl перехват трафика становится более трудоёмким (и более ресурсоёмким).
Monitoring LDAP (Lightweight Directory Access Protocol) logs in Active Directory is crucial for troubleshooting, auditing, and ensuring secure access to directory resources. LDAP logs provide insights into authentication issues, query performance, and potential security concerns.
Steps to Monitor LDAP Logs in Active Directory
Step 1: Enable LDAP Logging
-
Open the Registry Editor:
- Press
Win + R
, typeregedit
, and press Enter.
- Press
-
Navigate to the following key:
HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\NTDS\\Diagnostics
-
Locate 16 LDAP Interface Events.
-
Double-click the entry and set the value to 2 or higher:
0
= No logging (default).1
= Minimal logging.2
= Verbose logging (recommended for monitoring).
-
Click OK to save changes.
Note: Higher levels generate more logs but may impact server performance.
Step 2: Use Event Viewer to View LDAP Logs
- Open Event Viewer:
- Press
Win + R
, typeeventvwr.msc
, and press Enter.
- Press
- Navigate to Applications and Services Logs > Directory Service.
- Look for events with Event ID 2889 or Event ID 1139:
- 2889: Indicates unsecure LDAP binds.
- 1139: Indicates LDAP client timeout or errors.
Step 3: Analyze LDAP Logs
Use tools like PowerShell to extract and analyze relevant log data:
-
Example: Filter Event ID 2889 logs:
Get-WinEvent -LogName "Directory Service" -FilterXPath "*[System/EventID=2889]" | Format-Table TimeCreated, Message -AutoSize
Best Practices for LDAP Monitoring
- Enable Secure LDAP (LDAPS): Use LDAPS (LDAP over SSL) to encrypt directory queries and prevent unsecure binds.
- Audit LDAP Bindings: Regularly check for Event ID 2889 to identify clients using unsecure binds.
- Monitor Query Performance: Look for events indicating slow LDAP queries or timeouts.
- Use Third-Party Tools: Consider tools like Netwrix or SolarWinds for advanced LDAP monitoring and reporting.
Relevant Articles
- Microsoft’s Audit Policy Recommendations
- How to Track Group Policy Changes
- How to Check Active Directory (AD) Event Logs
- How to Track File or Folder Changes in Windows