> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bijection.com/llms.txt
> Use this file to discover all available pages before exploring further.

# LDAP and Active Directory

> Read bounded directory observations through a customer-run HTTPS bridge.

Mount `@bijectionhq/app-ldap` to read one LDAPv3 directory selection.
Run the bridge beside the directory with
[`bijection-ldap serve`](https://docs.bijection.com/integrations/bridges). The bridge authenticates
to the directory over LDAPS or StartTLS. Its directory bind password
stays with the bridge. Bijection seals only the HTTPS bridge bearer.

## Run the bridge

Place the bind password and a high-entropy bearer of at least 32 bytes in
separate files accessible only to the bridge user. The following private
configuration reads a generic LDAP subtree using Simple Paged Results.

```json theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
{
  "url": "ldaps://directory.example.org:636",
  "bind_dn": "cn=reader,ou=services,dc=example,dc=org",
  "password_file": "/run/secrets/ldap-bind",
  "token_file": "/run/secrets/ldap-bridge",
  "base_dn": "ou=people,dc=example,dc=org",
  "filter": "(objectClass=inetOrgPerson)",
  "attributes": ["cn", "mail"],
  "key_attribute": "entryUUID",
  "version_attribute": "entryCSN",
  "mode": "snapshot",
  "page_size": 100,
  "max_response_bytes": 36864
}
```

Run `bijection-ldap serve --config /path/to/ldap.json`. Put an HTTPS
ingress in front of the loopback listener and forward the bearer and the
`Bijection-Ldap-Protocol` and `Bijection-Ldap-Mode` response headers.
Route a paged pass to the same bridge process. Configure `ca_file`
for a private CA. Use `ldap://` with `start_tls: true` for StartTLS.

Set `max_response_bytes` to 36864 or less for this mount. Reduce
`page_size` or the attribute allowlist if a page is too large. Active
Directory controls the DirSync batch size, so lowering `page_size` does
not shrink a DirSync reply.

## Mount and bind

```ts bijection/app.ts theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
import { app, label, secret } from "@bijectionhq/bijection";
import ldap, { ldapBridgeApi } from "@bijectionhq/app-ldap";

const people = label();
const token = secret();
const bridge = ldapBridgeApi("https://directory-bridge.example.org", people, token);

export default app({ people, token, bridge, directory: ldap({ data: people, provider: bridge }) });
```

Pass the same label to the receiver binder and as the app's `data`. Set the HTTPS bearer with `bijection secret set token`.
Grant `directory.operator`, then call `directory.source.initialize` with
`{ mode: "snapshot" }` and read entries with `directory.entries.get({ key })`.
The initialized mode must match the bridge. Use a
fresh mount for a different directory, selection or mode.

## Keys, paging and recovery

| Mode | Position and removals |
| - | - |
| `snapshot` | Generic LDAPv3 enumeration. Each terminal page clears the provider position and the next poll starts a fresh baseline. Omitted entries stay landed. |
| `usn` | Active Directory on one domain controller. Configure `objectGUID` and `uSNChanged`. The sync token binds the DC invocation and completed USN window. Explicit Deleted Objects tombstones remove rows. Use `tombstone_filter` to narrow domain-wide tombstones. |
| `dirsync` | Active Directory at a naming-context root, with Replicating Directory Changes permission. The bridge uses DirSync cookies and re-reads live matches by GUID. Explicit tombstones remove rows. |

The app retains one observation per `objectGUID` or `entryUUID`, with
the DN, version text and attribute lists in the payload. Each page
admits at most 36 KiB and 512 changes. The app commits page changes
with the next opaque position. An incomplete pass can yield and
continue at its saved position on a later clock turn. Earlier pages can
be visible while the pass is under way.

An HTTP 410 on a retained cursor records a continuity gap. A bridge restart,
an expired paged session, a rejected provider cookie, a changed DC invocation
or an expired AD baseline can cause a gap. Inspect `source.health` and pass
its revision and gap stamp to `source.reset` to request a new baseline.
Reset preserves published rows. Entries that leave the base DN or stop
matching the filter stay landed until the bridge reports a tombstone.
The mount exposes read-only directory observations.

Live directory acquisition remains unverified.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.