mathewboswell.com — openldap-cache-buffer-active-directory.md
guest@mathewboswell:~$ cat openldap-cache-buffer-active-directory.md

Using OpenLDAP as a Cache and Buffer to Protect Active Directory Domain Controllers

2026-09-18 · # security # ldap # active-directory # infrastructure

Domain controllers are not glamorous, but almost everything depends on them. When they slow down, logins stall, applications time out, and the help desk phones light up.

A surprising amount of that load is not people logging in. It is applications asking the same questions over and over. Is this user in that group? What is this account's email address? Does this service account still exist? Many legacy apps issue those LDAP searches on every request, with no caching of their own.

One practical way to reduce that pressure is to put OpenLDAP in front of Active Directory as a read-only LDAP proxy with caching.

What the design actually does

OpenLDAP's slapd can run the ldap (or meta) backend to forward LDAP operations to upstream servers. Add the pcache overlay and it can store the results of matching search requests for a configured time. When an application repeats a query that fits a cached template, the proxy answers it locally instead of forwarding it.

That is the whole idea. Applications point at the proxy for directory lookups. The proxy answers repeat reads from cache and passes everything else upstream to the domain controllers.

What it does not do

Be clear about the boundaries, because this design gets oversold.

  • It does not replace Active Directory. AD remains the authoritative directory. Kerberos, Group Policy, domain joins, DNS integration, and replication all stay where they are.
  • It is not authentication failover for every protocol. It handles LDAP traffic sent to it. Kerberos and NTLM do not pass through it.
  • It is not a write path. Configure it read-only. Password changes and account updates go directly to AD.
  • It is not a rate limiter by itself. OpenLDAP has some resource limits, such as size and time limits on searches, but connection and request controls are typically handled by a load balancer, firewall, or a separate proxy layer in front of it.

Simple binds can be passed through to AD, but cached search results should not be treated as a substitute for checking credentials.

Where the benefits show up

The gains come from repetition. If a portal checks group membership on every page view, a cache with a short TTL turns thousands of identical upstream searches into a handful.

Other benefits follow:

  • Domain controllers spend less effort on noisy, low-value queries.
  • Application teams get a single, stable endpoint instead of hardcoding DC names.
  • You gain a choke point where directory query patterns are visible.

That last one matters for security. A sudden spike in broad searches, or an app enumerating every user object, is easier to spot at one layer than across many DC logs.

Choosing what to cache

Not every query belongs in cache. The pcache overlay works with query templates, so you decide which filter shapes and attributes are cacheable.

Good candidates are narrow, frequent, and tolerant of slight staleness: user attribute lookups by sAMAccountName, group membership checks, and mail lookups.

Poor candidates include anything security-sensitive where a few minutes of delay matters. If an account is disabled, how long can an application keep seeing it as active? Set TTLs with that question in mind. Minutes, not hours, is a common starting point.

Logging

Treat the proxy as a security component, not just a performance tweak.

  • Enable slapd stats logging for connections, binds, and searches.
  • Forward logs to your SIEM alongside DC security events.
  • Record which application identity issued each request.
  • Track cache hit rates so you know whether the design is earning its keep.

Avoid logging bind credentials. Check that your log level does not capture more than you intend.

High availability

A cache that becomes a single point of failure defeats the purpose.

Run at least two proxy instances behind a load balancer with health checks. Each instance should point at multiple domain controllers, ideally in the same site. Because the proxies are read-only and caches are disposable, you do not need replication between them; a cold instance just warms up.

Decide the failure behavior in advance. If both proxies are down, can applications fall back to AD directly, or should they fail closed? Either can be correct. Leaving it undefined is not.

A safe deployment pattern

  1. Inventory the callers. Find the applications generating the most repetitive LDAP traffic from DC logs.
  2. Build the proxy read-only. Use LDAPS or StartTLS both to clients and upstream. Use a dedicated, least-privilege service account for upstream searches.
  3. Define cache templates narrowly. Start with two or three query shapes and short TTLs.
  4. Put controls in front. Use the load balancer or firewall to restrict which hosts can connect and to cap connection rates.
  5. Migrate one application. Compare its results through the proxy with direct AD queries before moving the next.
  6. Measure. Watch DC search volume, proxy hit rates, and application latency.
  7. Document the boundary. Write down that the proxy serves LDAP reads only, so nobody later assumes it covers authentication outages.

The takeaway

OpenLDAP will not make your directory more authoritative or more resilient by magic. Used as a narrow, read-only cache, though, it can take a meaningful amount of repetitive pressure off domain controllers and give you a cleaner place to observe how applications use the directory. That is a modest claim, and a useful one.

guest@mathewboswell:~$ cd /posts
guest@mathewboswell:/posts/openldap-cache-buffer-active-directory2026 — System 1.0