skip to content

LDAP

The protocol behind corporate user and group lookups: an entry tree addressed by Distinguished Names, bind authentication, and filtered searches. Enterprise sign-in still bottoms out here.

on this pageshow

explore

questions

page 1 of 2

In LDAP, what does the Bind operation do to a session, and what state is that session in before one?

level: juniorimportance: must knowfreq 55%

answer

  1. a state change, not a login call
  2. what the session is before you ask
  3. anonymous until proven otherwise
  4. version, name, AuthenticationChoice
  5. what a failure leaves behind

basics

~20 s

The LDAP Bind operation sets the authentication state of an LDAP session. Before any Bind, and after any Bind that fails, the session is anonymous: it can already send searches, but every request is evaluated as an unauthenticated caller.

solid answer

~50 s

An LDAP session is usable the moment the transport is up: the client may send a `SearchRequest` straight away, and the directory answers as far as an unauthenticated caller is permitted. The session is in an **anonymous** authorization state, and the LDAP Bind operation is the one operation whose job is to change that. A `BindRequest` carries exactly three things — `version` (3 for LDAPv3), `name` (the bind DN of a directory entry, zero length for anonymous), and an `AuthenticationChoice` that is either `simple [0]`, an octet string password, or `sasl [3]`, a `SaslCredentials` naming a mechanism. Only a `success (0)` response moves the session to that identity. Receipt of a `BindRequest` discards whatever identity the session already held, so a Bind that fails does not leave you where you were — it leaves you anonymous.

code

asn1 · 14 lines
asn1
BindRequest ::= [APPLICATION 0] SEQUENCE {
     version                 INTEGER (1 ..  127),
     name                    LDAPDN,
     authentication          AuthenticationChoice }

AuthenticationChoice ::= CHOICE {
     simple                  [0] OCTET STRING,
                             -- 1 and 2 reserved
     sasl                    [3] SaslCredentials,
     ...  }

SaslCredentials ::= SEQUENCE {
     mechanism               LDAPString,
     credentials             OCTET STRING OPTIONAL }

go deeper

for a junior

Recall the shape: an LDAP session starts anonymous, and the Bind operation is what gives it an identity. Name the three fields of a BindRequest - version, the bind DN, and the choice between a password and a SASL mechanism.

for a middle

Explain the ordering: the server resets the session to anonymous on receiving a BindRequest and only promotes it on success (0). Be able to say why UnbindRequest is not the inverse of Bind.

for a senior

Show that you have debugged the consequence - a pooled connection silently left anonymous by a failed re-bind, producing missing search results rather than an error anywhere in the application.

for a principal

Frame the trade-off in binding identity to a connection at all: state that cannot be shared or migrated, a pool whose entries each carry an authorization state, and what that costs against a credential presented per request.

## What a Bind actually is The LDAP Bind operation is not "opening" something that was closed. An LDAP session — a client's connection to a directory server and the stream of `LDAPMessage` envelopes over it, each tagged with a `messageID` — exists and is usable the instant the transport is established. A client can send a `SearchRequest` before it has bound anything, and it will get a real answer: whatever a caller with no proven identity is allowed to see. What the session lacks is an identity. It is in an **anonymous authorization state**, and Bind is the operation that changes that state. RFC 4511 defines `BindRequest` as carrying three fields and nothing else: - **`version`** — the protocol version the client is speaking, `3` for LDAPv3. A server publishes what it accepts in `supportedLDAPVersion`. - **`name`** — the **bind DN**: the Distinguished Name of the directory entry the client claims to be, in the RFC 4514 string form. Zero length means the client is claiming nothing. - **`authentication`** — an `AuthenticationChoice`, which is `simple [0]`, an octet string holding a password, or `sasl [3]`, a `SaslCredentials` value naming a mechanism and carrying that mechanism's data. There is no session identifier for the client to store and no credential it keeps presenting on later requests. **The authentication state lives on the connection**, and it dies with the connection. ## The state machine, and the trap inside it The rule that catches people is the ordering: the server resets the session to anonymous when it *receives* a `BindRequest`, and only moves it to the new identity if the Bind succeeds. | event | resulting state of the session | |---|---| | transport established, no Bind sent yet | anonymous | | `BindRequest` received, still being processed | anonymous | | Bind answered `success (0)` | the identity that bound | | Bind answered any other result code | anonymous | | `UnbindRequest` sent | the session terminates; there is no response | Read the fourth row twice. **A re-bind that fails is a downgrade, not a no-op.** A shift-planning service that holds a long-lived pooled connection bound as a read-only directory entry, and then re-binds that same connection as a different identity, has an anonymous connection in its pool the moment that second Bind is refused. Nothing errors afterwards — the next borrower's search simply returns fewer entries, or none, and the service reports "the operator does not exist" for someone who plainly does. Diagnosing that means knowing this row of the table. `UnbindRequest` is also not the opposite of Bind, despite its name. It takes no response and ends the session outright. To drop an identity and keep the connection, a client binds again — an anonymous Bind, with a zero-length `name` and a zero-length `simple [0]` value, is the idiom. ## A successful Bind proves credentials, not permission A `success (0)` means the directory accepted what was presented. It does **not** mean the bound identity can read the tree, or any part of it. What the bound identity may then see is decided entry by entry and attribute by attribute when each later request is processed, by the directory's own access policy. A candidate who answers "then I can read everything under the naming context" has confused authentication with what the directory will show them. Two further limits are worth stating plainly: 1. A simple bind on an unprotected connection sends the password in the clear, because `simple [0]` is an octet string on the wire with nothing over it. 2. Binding says nothing about the *server's* identity. Only a mechanism that authenticates in both directions does that, and a plain password bind is not one. ## "Bind" is an overloaded word — say which one Three different things are called binding around directories, and an interview answer should distinguish them without being asked: - the **LDAP Bind operation** described here, which sets a session's authentication state; - a socket **bound** to a listening port, which is the transport and has nothing to do with identity; - a directory client library's `bind`/`rebind` call that **creates or replaces an entry** in a naming service — the same four letters, an entirely different act. Saying "the LDAP Bind operation" or "the bind DN" costs two words and removes the ambiguity completely.

  • How does a client drop an LDAP session's authenticated identity without closing the connection?
    By sending another `BindRequest`. Receipt of one resets the session to anonymous before the new credentials are even evaluated, so an anonymous Bind — zero-length `name`, zero-length `simple [0]` value — discards the old identity. `UnbindRequest` will not do it: it carries no response and terminates the session entirely.
  • How does a client learn which SASL mechanisms a directory will accept, before it has bound?
    From the `supportedSASLMechanisms` attribute of the root DSE, which a client can read while still anonymous. It lists the mechanism names the server is willing to negotiate, so a client can pick one rather than guessing and collecting an `authMethodNotSupported (7)` for each attempt.
  • Does a successful LDAP Bind mean the bound identity can read the directory?
    No. `success (0)` says the credentials were accepted, nothing more. What that identity may read is decided when each later request is processed, per entry and per attribute, by the directory's access policy — which is why a bind that works and a search that returns nothing are perfectly consistent.

A workshop's notice board is readable by anyone who walks in, and signing the shift register is a separate act that changes which cupboards the foreman will open for you. Scratching your name out again leaves you a stranger, not your earlier self.

saying these in an interview costs you the question

  • Says an LDAP session can send nothing at all until it binds
  • Treats a failed Bind as leaving the previous identity intact
  • Confuses the LDAP Bind operation with a library call that creates an entry
  • Thinks a successful Bind means the caller may read the whole tree
  • Calls UnbindRequest the way to drop credentials and keep the session
open as a page

In LDAPv3, how does a Control attached to a request differ from an extended operation?

level: juniorimportance: must knowfreq 46%

basics

~20 s

An LDAP Control rides along on a request the protocol already defines and changes how the server carries it out. An extended operation is a whole new request, named by its own OID, that the base operation set never had.

open as a page

In LDAP, how is a directory entry's Distinguished Name built from its own RDN and its ancestors'?

level: juniorimportance: must knowfreq 58%

basics

~20 s

A Distinguished Name chains the entry's own Relative Distinguished Name onto every ancestor's, up to the naming context the server holds. In the RFC 4514 string form the leftmost component is the entry itself and the rightmost sits nearest the root.

open as a page

When a directory server answers an LDAP write request, what does the LDAPResult in that reply tell the client?

level: juniorimportance: must knowfreq 48%

basics

~20 s

LDAPResult is the shared reply body for Add, Modify, ModifyDN, Delete and Compare. It carries a numeric resultCode such as success(0), a matchedDN showing how far the server resolved the name, and a human-readable diagnosticMessage.

open as a page

In LDAP, what does a directory entry's objectClass attribute declare, and why must every entry carry one?

level: juniorimportance: must knowfreq 52%

basics

~20 s

A directory entry's objectClass attribute names the classes the entry belongs to, and those classes' MUST and MAY lists decide which attributes it may hold. The abstract class top requires the attribute, so every entry carries it.

open as a page

In an LDAP SearchRequest, what do the scope values baseObject, singleLevel and wholeSubtree each match?

level: juniorimportance: must knowfreq 58%

basics

~20 s

An LDAP SearchRequest's scope decides how far below the base DN the server walks: baseObject (0) considers only the base entry itself, singleLevel (1) only its immediate subordinates, and wholeSubtree (2) the base entry plus every descendant.

open as a page

How does the StartTLS extended operation protect an LDAP connection differently from connecting with TLS already in place?

level: juniorimportance: must knowfreq 52%

basics

~20 s

StartTLS is an LDAP extended operation that negotiates TLS in band on an already-open, initially unprotected connection, so the server may decline it. The alternative connects to a separate, conventional port where TLS runs from the first byte, unnegotiated.

open as a page

Which three simple-bind mechanisms does RFC 4513 separate, and why is an unauthenticated bind the dangerous one?

level: middleimportance: must knowfreq 50%

basics

~20 s

RFC 4513 separates three mechanisms of simple bind by the lengths of two fields: anonymous (zero-length name and password), unauthenticated (a DN with a zero-length password), and name/password. The unauthenticated one can return success (0) for a DN nobody proved.

open as a page

A client marks an LDAP Control critical and the server does not recognise its OID — what happens?

level: middleimportance: must knowfreq 58%

basics

~20 s

The server refuses the whole operation and answers unavailableCriticalExtension (12), having performed none of it. Had criticality been FALSE — which is the encoding's default — the server would have ignored the unrecognised control and carried the operation out as if it had never been sent.

open as a page

A directory entry's common name contains a comma — what must the RFC 4514 string form of its Distinguished Name do?

level: middleimportance: must knowfreq 46%

basics

~20 s

The comma must be escaped inside the RDN value, as a backslash before it or as the hex pair for that octet. Unescaped, the comma is read as the separator between two RDNs, and the string names something other than the entry — usually nothing at all.

open as a page

In an LDAP Modify request, what is the difference between replacing an attribute and deleting one of its values?

level: middleimportance: must knowfreq 58%

basics

~20 s

Replace discards every existing value of the attribute and installs the values listed in the change. Delete removes only the values listed and leaves the rest in place. Replace is an overwrite, never a merge.

open as a page

To move a directory entry under a different parent, what must an LDAP ModifyDN request carry?

level: middleimportance: must knowfreq 52%

basics

~20 s

A ModifyDN request carries the entry's current Distinguished Name, the new RDN, a deleteoldrdn boolean deciding whether the old naming value is discarded, and the optional newSuperior field naming the new parent. Without newSuperior it is a rename in place.

open as a page

In a replicated LDAP directory, what does a multi-master write model permit that single-master does not, and what does it cost?

level: middleimportance: must knowfreq 48%

basics

~20 s

Single-master accepts writes at one server, so every change has one order and contradictory writes cannot both be accepted. Multi-master accepts writes at several servers, keeping writes available when one fails, at the cost of conflicting concurrent changes that must be resolved afterwards.

open as a page

In LDAP schema, how do STRUCTURAL and AUXILIARY object classes differ in what a directory entry declares?

level: middleimportance: must knowfreq 45%

basics

~20 s

A directory entry belongs to exactly one structural object class chain, rooted at the abstract class top, and that chain says what the entry is. Auxiliary classes are added in any number and only widen the attributes it may hold.

open as a page

In an RFC 4515 LDAP search filter, how is an asserted value containing a parenthesis, an asterisk or a backslash written?

level: middleimportance: must knowfreq 47%

basics

~20 s

RFC 4515 writes those octets as a backslash followed by two hexadecimal digits inside the asserted value: \28 for an open parenthesis, \29 for a close parenthesis, \2A for an asterisk, \5C for a backslash and \00 for NUL.

open as a page

Why does an LDAP client issue the StartTLS extended operation before the LDAP Bind operation rather than after?

level: middleimportance: must knowfreq 44%

basics

~20 s

Installing a TLS layer resets the LDAP connection's authentication state to anonymous, so a bind performed first is thrown away — and its password has already crossed the network in the clear. StartTLS first, then bind.

open as a page

For an RFC 4533 content synchronization session, when does refreshOnly fit a replica better than refreshAndPersist?

level: seniorimportance: must knowfreq 40%

basics

~20 s

refreshOnly fits a replica that cannot hold a connection open: it converges, receives a new syncCookie in the Sync Done Control, and disconnects, resuming later from that cookie. refreshAndPersist fits a replica with a stable link that should learn of each change as it happens.

open as a page

In an LDAP SASL Bind, what does a saslBindInProgress (14) response mean, and what must the client send next?

level: middleimportance: should knowfreq 42%

basics

~20 s

saslBindInProgress (14) means the SASL Bind is not finished: the server has taken one step and is asking for another. The client reads serverSaslCreds [7], computes its next credentials, and sends a new BindRequest naming the same mechanism.

open as a page

Why does LDAP define a Password Modify extended operation instead of a Modify replacing userPassword?

level: middleimportance: should knowfreq 42%

basics

~20 s

A Modify with replace on userPassword makes the client decide the stored form and cannot express 'check the old value first' or 'server, choose a new one'. Password Modify puts both in the protocol and leaves the storage form to the server.

open as a page

Which directory entry does an LDAP client read to discover the naming contexts a server holds, and how?

level: middleimportance: should knowfreq 40%

basics

~20 s

The root DSE — the entry whose Distinguished Name is zero-length. Reading it at the empty name returns operational attributes including namingContexts, which lists every suffix the server holds, so a client can discover them instead of being configured with a guess.

open as a page

How does an LDAP referral reach a client as a result code, and how does a SearchResultReference differ from it?

level: middleimportance: should knowfreq 42%

basics

~20 s

An LDAP referral arrives as resultCode referral (10) on the operation's own result: the server did the operation nowhere and hands back one or more LDAP URLs. A SearchResultReference arrives mid-search, alongside real entries, saying part of the subtree continues elsewhere.

open as a page

Beyond MUST and MAY lists, what does an LDAP attribute type definition constrain about the values an entry stores?

level: middleimportance: should knowfreq 34%

basics

~20 s

Object classes say which attribute types may appear; the attribute type definition constrains each value. SYNTAX fixes the form, EQUALITY decides when two values are the same, SINGLE-VALUE caps the count, and NO-USER-MODIFICATION reserves the attribute to the server.

open as a page

In LDAPv3, where does a directory server publish the object class and attribute type definitions it enforces?

level: middleimportance: should knowfreq 30%

basics

~10 s

A directory server publishes its schema as an ordinary entry, the subschema subentry. Each entry's operational attribute subschemaSubentry holds that subentry's Distinguished Name, and the subentry carries objectClasses, attributeTypes, matchingRules and the rest.

open as a page

In an LDAP search filter, why does (!(ou=Cardiology)) return directory entries that carry no ou attribute at all?

level: middleimportance: should knowfreq 34%

basics

~20 s

An equality item evaluates to FALSE when a directory entry holds no matching value, including when it holds no such attribute at all. Negation turns FALSE into TRUE, so entries missing the attribute match and are returned.

open as a page

A shift-planning service's LDAP Bind is refused: what do invalidCredentials (49), inappropriateAuthentication (48) and strongerAuthRequired (8) each tell you?

level: seniorimportance: should knowfreq 45%

basics

~20 s

invalidCredentials (49) means the name and password pair was not accepted. inappropriateAuthentication (48) means credentials are required where none were supplied. strongerAuthRequired (8) means the mechanism is understood but policy demands a stronger one. Each implies a different fix.

open as a page

What does pairing the LDAP server-side sorting control with simple paged results cost a directory server?

level: seniorimportance: should knowfreq 36%

basics

~20 s

Ordering is defined over the whole result set, so the server must select and order everything before it can hand back page one. Paging then bounds the messages but not the work or the memory, and the server's own limits apply to the full set.

open as a page

An LDAP search returns noSuchObject(32) with a matchedDN shorter than the base you sent — what does that diagnose?

level: seniorimportance: should knowfreq 34%

basics

~20 s

It names the longest ancestor of your base that does exist, so everything below it in the name is wrong. A matchedDN equal to the suffix means the container is missing or misspelled; an empty one means the server holds no naming context covering that name at all.

open as a page

A long-running LDAP operation must be called off — what does an AbandonRequest actually guarantee?

level: seniorimportance: should knowfreq 30%

basics

~20 s

Very little. An AbandonRequest names the messageID of an outstanding operation and draws no response of any kind, so the client learns nothing about whether the server stopped, had already finished, or ignored it — and nothing is undone.

open as a page

Why does removing an obsolete branch from a directory take more than one LDAP Delete request?

level: seniorimportance: should knowfreq 38%

basics

~20 s

A Delete request is nothing but one Distinguished Name, and a server refuses to delete an entry that still has subordinates with notAllowedOnNonLeaf (66). Removing a branch is therefore a client-side depth-first walk, one request per entry.

open as a page

showing 1–30 of 38