Overview
Curated: · Written: · Reviewed:
Directory Services (LDAP, Active Directory)
In one line
LDAP is the protocol for reading and writing directory entries. Active Directory (AD DS) adds domains, forests, replication, Kerberos and Windows security semantics on top. Reach for it when an application needs an authoritative store of identities, groups and attributes. You still have to decide how the app authenticates users, correlates them to a stable identity, authorizes each action, and reacts to disablement.
Key definitions
- DN (distinguished name): the entry's position in the tree. It changes when the object is renamed or moved.
- Immutable identifier:
entryUUID(LDAP servers) orobjectGUID(AD). This is the correlation key, not the DN. - Simple bind: DN and password sent as a reusable credential. It needs TLS or another confidentiality layer.
- StartTLS: upgrades an existing port 389 connection to TLS. The client must verify the server certificate, or the upgrade protects nothing.
- SPN (service principal name): the name a Kerberos service ticket is issued for. It is registered on the account that runs the service.
- Tombstone and Recycle Bin: deleted-object retention. The Recycle Bin restores the full object, including attributes and memberships.
Formulas and complexity
Kerberos rejects a request when client and KDC clocks differ by more than the allowed skew. The MIT default is 5 minutes:
Filter escaping under RFC 4515 turns * into \2a, ( into \28, ) into \29, \ into \5c and NUL into \00. The input a*b(c)\d becomes a\2ab\28c\29\5cd. DN escaping under RFC 4514 is a separate set of rules.
How it works
- The client binds over LDAPS, over StartTLS with certificate verification, with a Kerberos SASL bind, or as the authenticated user.
- The server checks the bound identity's rights per entry and per attribute, including effective group membership.
- A search is bounded by base, scope, filter, attribute list, size and time limits. Filter values are escaped by the library.
- Writes replicate to other domain controllers asynchronously, so a reader on another DC can see stale data until replication converges.
When to use and when not to
| Situation | Do | Avoid |
|---|---|---|
| App login | Federate or use Kerberos; never collect the directory password | App-held user passwords checked by simple bind |
| Profile lookups | Read-only bind account scoped to the needed OU and attributes | A privileged bind account for searches |
| Cross-domain lookup | Global catalog (port 3268) for partial attributes only | Assuming GC returns full attributes |
| Revocation | Disable, then revoke sessions, tickets and caches | Treating replication success as revocation |
| Group checks | Resolve nested membership, fail closed on partial results | Reading direct member values only |
Traps interviewers probe
- Storing the DN as the user key. A move or rename orphans the row and the app creates a duplicate. Fix: store
objectGUID/entryUUIDas the key and treat the DN as a mutable attribute. - Concatenating input into a filter. Input
*matches every entry, and a crafted value can authenticate another user. Fix: escape with the library per RFC 4515, bind to the matched entry only when exactly one entry matches, and never build DNs by string concatenation either. - Accepting an unverified TLS session.
TLS_REQCERT neverlets an on-path attacker read a simple-bind password after StartTLS. Fix: verify the CA chain and host name, and fail closed if StartTLS does not negotiate. AD also rejectsunicodePwdwrites on a cleartext connection, so use LDAPS for password changes. - Calling a disabled account contained. A cached session, a 10-hour default TGT or a locally validated cookie keeps working. Fix: revoke sessions, ticket-granting tickets and app caches as part of the disable runbook, and measure that latency.
- Raising the Kerberos skew allowance to fix a clock. This weakens replay protection. Fix: correct the host clock from its NTP source.
Interview tips
Opening: "The directory is the identity authority. I would federate or use Kerberos rather than collect passwords, key the local user on objectGUID, and authorize each action against effective groups."
Expected follow-ups:
- Nested group limits and how the app behaves when resolution is partial.
- Constrained versus unconstrained delegation, and which SPNs the front end may act toward.
- Referral chasing, and whether a referral can send your bind credentials to another server.
- Replication lag for a password reset or a disable, and how the app handles it.
- Restoring a DC after compromise, and why a restored backup can resurrect deleted accounts.
30-second outline:
- Authenticate by Kerberos or federation, verified TLS, no stored user password.
- Correlate on
objectGUID; store the DN as an attribute. - Authorize per action using effective groups; deny when group lookup is partial.
- Escape filters, bound searches, and avoid privileged bind accounts.
- Disablement propagates to sessions, tickets and caches; monitor it and test it.
Feedback on this overview
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.