Skip to main content

LDAP Protocol

Impacket’s LDAP implementation provides comprehensive support for querying and modifying Active Directory via the Lightweight Directory Access Protocol, including advanced features like paging, signing, and Kerberos authentication.

Overview

The LDAP implementation is located in impacket/ldap/ and includes:
  • Connection types - LDAP (389), LDAPS (636), Global Catalog (3268)
  • Authentication - Simple bind, NTLM, Kerberos
  • Operations - Search, add, modify, delete
  • Advanced features - Paging, signing, channel binding

Active Directory

LDAP is the primary protocol for querying and modifying Active Directory. Impacket supports all major LDAP operations needed for enumeration and exploitation.

Connection Types

LDAP Connection (Port 389)

From ldap.py:78-150, establishing basic LDAP connection:

LDAPS Connection (Port 636)

LDAPS provides encryption via TLS/SSL. Channel binding is automatically configured for secure authentication.

Global Catalog (Port 3268)

Authentication Methods

Search Operations

Search with Scope

Complex Filters

Use paged searches for large result sets to avoid server limits. Default page size is 1000.

Common AD Queries

Enumerate Users

Enumerate Groups

Enumerate Computers

Find SPNs (Kerberoasting)

Modify Operations

Add Object

Modify Object

Delete Object

Modify DN (Rename/Move)

Security Features

LDAP Signing

LDAP signing ensures message integrity. It’s enabled by default when using NTLM or Kerberos authentication.

Channel Binding

From ldap.py:152-170, channel binding for LDAPS:

Advanced Queries

User Account Control Flags

Time-based Queries

Error Handling

Always handle LDAP errors gracefully. Common errors include insufficient permissions, invalid filters, and connection issues.

Complete Example: AD Enumerator

References

  • Source: impacket/ldap/
  • RFC 4511: LDAP Protocol
  • [MS-ADTS]: Active Directory Technical Specification
  • [MS-ADSC]: Active Directory Schema Classes