Skip to content
Tutorials Center
My learning

Topics

Lesson 28 of 38 ยท Integration and Security

LDAPS, StartTLS, LDAP Signing and Channel Binding

Secure LDAP traffic to Active Directory: simple versus SASL binds, LDAPS on port 636, StartTLS, LDAP signing requirements, channel binding tokens and how to roll out the hardening safely.

LDAP was designed in an era when sending a password in clear text over an internal network seemed acceptable. Today a simple bind over plain LDAP on port 389 puts the user's full password on the wire, and unsigned traffic can be tampered with or relayed. Securing directory traffic is one of the highest-value hardening tasks in Active Directory, and also one of the easiest to get wrong, because old applications break.

This lesson covers the ways to protect LDAP, the two domain controller policies (signing and channel binding), and a safe rollout plan. The server settings are described as read-only text and registry values. The Python parts are small stand-ins that classify connections and simulate a rollout report.

Bind types

A bind is how an LDAP client authenticates (see the protocol lessons earlier in the track). In Active Directory:

  • Anonymous: no credentials. Heavily restricted by default.
  • Simple bind: sends a DN or UPN and a password. Safe only inside a TLS-protected channel.
  • SASL bind: negotiates a mechanism. In AD the useful ones are GSSAPI (Kerberos, with NTLM fallback through SPNEGO) and EXTERNAL (client certificate over TLS). GSSAPI binds can negotiate signing and sealing, which protects integrity (and optionally confidentiality) of the LDAP messages themselves, with no certificate needed.

Two ways to get encryption

LDAPS wraps the whole connection in TLS from the first byte, on port 636 (and 3269 for the global catalog). The URL scheme is ldaps://dc1.example.com.

StartTLS starts on plain port 389 and then upgrades with an LDAP extended operation (OID 1.3.6.1.4.1.1466.20037). It uses the same certificate as LDAPS; the difference is only how the channel is established. Active Directory supports both when a suitable certificate is installed.

For either to work, each domain controller needs a server authentication certificate in its machine store: Extended Key Usage Server Authentication (1.3.6.1.5.5.7.3.1), the DC's FQDN in the Subject Alternative Name, a private key, and a chain of trust the clients accept. Enterprise CA auto-enrolment with the Domain Controller Authentication or Kerberos Authentication templates handles this for most domains. Clients then need the issuing CA in their trusted roots, and must connect with a name that matches the certificate, not an IP address.

You can test from a Windows machine with ldp.exe (connect, port 636, SSL checked), or from Linux:

TEXT
ldapsearch -H ldaps://dc1.example.com -D "[email protected]" -W -b "dc=example,dc=com" "(sAMAccountName=alice)"

If you see errors about certificate verification, fix the trust or the name rather than turning verification off (TLS_REQCERT never removes all protection against impostors).

LDAP signing

A domain controller policy, Domain controller: LDAP server signing requirements, has two practical values:

Value Behaviour
None Signing is negotiated if the client asks. Unsigned binds are fine.
Require signing Clients using SASL (GSSAPI) binds must sign. Simple binds on plain 389 are refused.

Microsoft has been moving the default toward requiring signing, and your own setting should be Require signing. Applications that fail afterwards were using unsigned simple binds on port 389 and must switch to LDAPS or StartTLS (for simple binds) or enable signing (for GSSAPI).

Before enforcing, enable the diagnostic LDAP Interface Events (16 LDAP Interface Events set to 2). The DC then logs event 2889 in the Directory Service log for every client that makes an unsigned bind or a simple bind without TLS, with the client IP and the account used. Collect them for a few weeks, fix each caller, then enforce.

Channel binding

An attacker in the middle can relay an authenticated session over TLS to the domain controller. LDAP channel binding tokens (CBT) tie the authentication (the Kerberos or NTLM exchange) to the specific TLS channel by including a hash of the server certificate in the authentication message. A relayed session carries the wrong token and is rejected. The registry value is LdapEnforceChannelBinding under HKLM\System\CurrentControlSet\Services\NTDS\Parameters:

Value Meaning
0 Never (do not use)
1 When supported: enforced for clients that send a token
2 Always: authentication over LDAPS without a valid token fails

Roll out the same way: set to 1, watch events 3039 to 3041 (they list clients that would fail), fix them, then set to 2. Channel binding applies to LDAPS and to StartTLS-protected binds, so you need TLS for it to mean anything.

Python Classify LDAP connections by risk (stand-in)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The cbt argument is carried but unused: channel binding hardens the TLS case further and is enforced on the server. The point of the exercise is to find callers that need action before you enforce signing.

A rollout simulator

Most outages come from enforcing before inventory. The little planner below turns a list of audit events into a work list:

Python From audit events to a work list

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Other protections worth turning on

  • Block anonymous and plain simple binds at the network edge: only DCs need 389/636 from application servers, never from the internet.
  • Use separate, least-privilege service accounts for each app (read-only on the needed OUs).
  • Prefer GSSAPI from domain-joined clients; use LDAPS with a verified certificate from everything else.
  • Monitor DCs for certificate expiry; an expired LDAPS certificate causes a sudden, confusing outage.
  • Consider the LDAP query policies (MaxPageSize, MaxQueryDuration) so a runaway application cannot hammer a DC.
  • Read the next lessons for application integration patterns and hardening the directory.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. Which port does LDAPS use for a domain controller (not the global catalog)?

    LDAPS is LDAP inside TLS from the start on 636; 3269 is the global catalog equivalent.
  2. 2. What does the DC log (event 2889) when LDAP Interface Events are enabled?

    Event 2889 identifies the callers that would break if signing is required, so you can fix them first.
  3. 3. What problem does channel binding solve?

    The authentication includes a token tied to the TLS channel, so a relayed session fails.
  4. 4. A GSSAPI bind can be protected without any certificate by:

    SASL GSSAPI can sign and encrypt messages with the session key, independent of TLS.
  5. 5. Why should you never disable certificate verification for LDAPS in an application?

    Without verification, TLS encrypts but does not authenticate the server, so man-in-the-middle attacks succeed.

Summary

  • Simple binds are safe only inside TLS; use LDAPS (636) or StartTLS, and GSSAPI with signing for domain clients.
  • Domain controllers need a valid server certificate with the right name; clients must trust the CA.
  • Roll out signing and channel binding in audit mode first (events 2889 and 3039 to 3041), then enforce.
  • Never turn off certificate checking.

Next: Application Authentication with LDAP