Browse learn

OpenLDAP Access Control

Learn how OpenLDAP access control rules select entries and attributes, evaluate identities, and grant the minimum required permissions.

On this page

OpenLDAP Access Control: What It Is and Why It Matters

Securing directory data is a foundational requirement for any real-world LDAP deployment. OpenLDAP implements access control using Access Control Lists (ACLs), a flexible, rule-based system that defines exactly who can do what to every part of your Directory Information Tree (DIT). Think of each entry in the directory—user profiles, passwords, group definitions, application data—as a protected resource. ACLs act as a firewall, enforcing fine-grained permissions from the moment a request reaches the server.

In OpenLDAP, the security and functional correctness of nearly every LDAP operation (search, bind, modify, add, delete) depend on getting ACL rules precisely right. A lax or misconfigured ACL can expose sensitive data like passwords; an overly strict or misordered rule can break application authentication or lock out stakeholders. Understanding and authoring ACLs is therefore an essential skill for anyone managing or integrating with OpenLDAP.

How OpenLDAP ACLs Work: Rule Structure and Syntax Fundamentals

Each OpenLDAP ACL defines a what (the scope—entries, attributes, subtree, or specific objects), one or more by clauses (the subject—users, groups, anonymous, self, DNs), and an access level (permissions—none, auth, read, write, manage, etc.). Every ACL sits in an ordered list, and each is evaluated against incoming operations.

A typical ACL rule is structured as follows:

text
access to <what>
    by <subject> <access-level>
    [by <other-subject> <access-level> ...]
  • The <what> clause matches directory entries or attributes. This can be everything (to *), a subtree (to dn.subtree=ou=People,dc=example,dc=com), a single attribute (to attrs=userPassword), or more complex filters.
  • The by clauses define who gets what. You can specify a single DN, all users, only anonymous sessions, groups (by DN or attribute), or the user themselves (self).
  • Each <access-level> specifies an allowed action: none (explicit deny), auth (bind only), read, write, manage (full access), and more.

For example, to protect password attributes:

text
access to attrs=userPassword
    by self write
    by anonymous auth
    by * none

This rule grants each user the ability to update their own password (self write), allows anonymous users to attempt to authenticate (anonymous auth), and denies everyone else access (* none).

Rule Evaluation Order: Why Sequence Shapes What’s Permitted

OpenLDAP processes ACLs strictly top-down: the server walks the list, and the first rule that matches both the operation’s target (to clause) and the requestor (by clause) determines the outcome. Unless explicitly overridden, evaluation stops after the first match.

This "first-match-wins" logic means that rule order is security-critical. A permissive general rule above a restrictive one will grant access too widely; a restrictive catch-all rule at the top can inadvertently block legitimate operations.

Consider this flawed example:

text
access to *
    by * read
access to attrs=userPassword
    by self write
    by * none

Here, all users are granted read to everything—including userPassword—because the first rule matches before the specific password-protecting rule is ever checked. Instead, the sensitive restriction must be ordered first.

OpenLDAP also supports control keywords like stop, continue, or break in rules to alter evaluation, but the default is stop: processing ends at the first applicable rule/subject match.

Key takeaway: Place the most specific, sensitive, or restrictive rules at the top, and general rules below.

Configuring ACLs: slapd.conf vs. cn=config (olcAccess) Distinctions

OpenLDAP supports two configuration models:

  1. slapd.conf: The historical, text-based configuration file. ACLs appear as one or more access directives within the relevant database section. Updates require editing the file and restarting slapd.

  2. cn=config (slapd-config): The modern, dynamic configuration system uses directory entries (olcAccess attributes) to store and manage ACLs. Changes are applied live via LDAP operations (LDIF modify requests), without restarting the service.

When writing or reading ACLs:

  • In slapd.conf, rules appear directly and are ordered top-down in the file.
  • In cn=config, each ACL is an ordered olcAccess attribute. The order is significant, and mistakes in order or syntax can cause immediate permission failures.

Migration and maintenance: If moving from slapd.conf to cn=config, it's crucial to replicate not only the content but the order and precise logic of each ACL. Always test changes in isolation before applying to production, as misconfiguration can abruptly lock out users or even all access.

Canonical Access Patterns: Password Protection, Self-Modify, Group Delegation

Several patterns recur in secure OpenLDAP deployments:

1. Password and Sensitive Attribute Protection

Always restrict read and write access to password and similar sensitive attributes:

text
access to attrs=userPassword
    by self write
    by anonymous auth
    by * none
  • Users can change their own password (self write)
  • Anonymous can attempt authentication but not read (anonymous auth)
  • All others denied.

2. Allowing Self-Modification for Users

Enable users to update attributes (like their own email) without exposing data to others:

text
access to dn.subtree=ou=People,dc=example,dc=com attrs=mail
    by self write
    by * read

This grants each user write access to their own mail attribute but only read to others.

3. Group-Based Access (Delegation)

Authorize an administrative group to edit user entries:

text
access to dn.subtree=ou=People,dc=example,dc=com
    by group.exact="cn=Admins,ou=Groups,dc=example,dc=com" write
    by * read

This delegates write permission to members of Admins while others have read access. Group-based patterns require that group entries use an appropriate object class (like groupOfNames).

4. Secure Defaults

Finish the list with an explicit denial:

text
access to *
    by * none

Best Practices, Misconceptions, and Troubleshooting

Rootdn Handling:
Never list the rootdn (the directory admin) in your ACLs. By design, rootdn has unlimited access within its database—ACLs do not constrain it and listing it unnecessarily slows down evaluation.

Risks of Default or Misordered Rules:
The default OpenLDAP ACL grants read access to all (access to * by * read). This is insecure for any production environment. Always lock down sensitive attributes first and narrow access as required.

Order Is Everything:
If a general rule appears before a specific restriction, the specific rule will never be checked. Audit your ACL sequence carefully.

Common Troubleshooting Tips:

  • Review logs for "insufficient access" or operation denied errors.
  • Temporarily enable detailed logging to show ACL-related processing.
  • Use a test environment: invalid or unreachable rootdn, missing group entries, or syntax errors can break authentication entirely.
  • Review rule order and ensure every sensitive data path is covered before less-specific catch-alls.

Mindset:
Think like a firewall architect: enumerate what must be explicitly permitted, block everything else, and always test for unintended exposure or lock-out.

Further Exploration: Advanced and Set-Based ACLs

OpenLDAP supports advanced ACL constructs: set-based rules, attribute value filters, and context-dependent permissions. For example, you can grant access to users only if they are in a group and match some attribute value, or allow managers to modify subordinate entries using LDAP filter selectors.

However, these patterns are subtle and can be difficult to debug. Their evaluation can be order-dependent and require careful testing in non-production environments.

Example:
A set-based ACL might resemble:

text
access to dn.subtree=ou=People,dc=example,dc=com
    by set="user & group/roleOccupant" write
    by * read

Such expressions require the set syntax and can match based on complex relationships—powerful, but best handled with caution.

Key Takeaways: Designing Secure, Maintainable OpenLDAP ACLs

  • Always design ACLs with order and specificity in mind: Most restrictive rules first; never rely on fall-through for sensitive data.
  • Protect attributes like userPassword as a top priority.
  • Avoid listing rootdn in any ACLs: Its rights are unconstrained by design.
  • Validate and test all ACL changes in a safe environment before deploying.
  • Prefer explicit denials to ambiguous or open-ended defaults.
  • Embrace group and filter-based delegation for least-privilege access, but test complex patterns thoroughly.

For complete ACL syntax, troubleshooting, and edge-case patterns, consult official OpenLDAP documentation and curated example repositories before finalizing production deployments.

Sources