OpenLDAP Documentation

repository·master·Indexed 20 days ago

https://github.com/openldap/openldap

A highly extensible LDAP (Lightweight Directory Access Protocol) server implementation. This documentation includes details on the LDAPv3 C++ Class Library, including the LDAPAttribute and LDAPAttributeList classes for managing LDAP attributes and interfacing with the OpenLDAP C-API, as well as Doxygen configuration settings for generating project documentation.

Tokens
148.9K
Snippets
385
Records
629
Agent score
70%

What's inside OpenLDAP

  1. Understand the lloadd runtime architecture

    master

    The lloadd load balancer uses a multi-threaded architecture to manage client and server (upstream) I/O. The runtime is organized into four main components:

    1. Main Thread: Handles signals and manages the overall event base.
    2. Listener Thread: Listens on rendezvous sockets and hands new connections to worker threads.
    3. Worker Threads: A set of $n$ threads responsible for handling client and server I/O. These threads typically dispatch actual work to a thread pool.
    4. Thread Pool: Dedicated threads used to execute the actual LDAP operations/work.

    To maintain fairness and prevent starvation, the system uses queues and timeouts to ensure that requests are processed according to a principle of fairness: G( requested => ( F( progressed | failed ) ) ).

  2. How lloadd handles LDAP responses (Upstream to Client)

    master

    When an upstream sends data back to the client, the following flow occurs:

    1. Read Upstream: Parses the PDU using ber_get_next(). It peeks at the msgid to resolve the corresponding client connection.
    2. Validation: Checks if the operation is unsolicited, abandoned, or non-existent. If so, the PDU is dropped.
    3. Write to Client: Reconstructs the final PDU and writes the BER to the client. If the write is incomplete, the client is marked as suspended.
    4. Cleanup: If it is a final response, the operation counts for both the upstream and the client are decremented.
    5. Response Handling: If the client is backlogged, the upstream is suspended and a callback is registered to unsuspend it once the client can accept more data.
  3. Upstream selection logic

    master

    To distribute load, lloadd selects an upstream using the following logic:

    1. Level Selection: While a level is available, pick a random ordering of upstreams based on their configured weights.
    2. Load Balancing: Within the selected level, find the least busy connection by checking the number of in-flight operations (requires locking the upstream map).
    3. Availability: Check if a new connection should be opened and attempt to lock for a socket write. If no BER is currently queued, the upstream is available for use.
  4. How lloadd handles LDAP operations (Client to Upstream)

    master

    When a client sends a request, lloadd performs the following lifecycle:

    1. Read Client: Uses ber_get_next() to parse the PDU. If the operation is STARTTLS, the state is set to TLS_SETUP.
    2. Identify Operation:
      • Unbind: Marks pending operations in upstreams as abandoned and clears the client link.
      • Bind: Checks if the mechanism is not EXTERNAL, abandons existing operations, sets state to BINDING, and picks an upstream.
      • Abandon: Finds the specific operation and marks it for abandonment to be sent to the upstream.
      • Exop (Extended Operation): For STARTTLS, it abandons all current operations, sets state to TLS_SETUP, and sends the hello.
      • Other: Picks an upstream, creates a PDU, and sends it (suspending the upstream if the write is not completed).
    3. PDU Construction: For requests, lloadd gets a new msgid from the upstream, creates an Op structure, and adds necessary controls like proxyauthz (constructed from authzid) and session tracking (constructed from remote IP, own name, and authzid).
  5. Manage upstream connections and TLS

    master

    Upstream management follows an asynchronous lifecycle:

    1. Async Connect: Establish connections up to the min_connections limit.
    2. TLS Setup: Once connected, set up TLS if requested.
    3. Bind: Perform the initial BIND interaction.
    4. Registration: Once the bind is complete, add the connection to the upstream's connection list.
    5. Scaling: If a connection is suspended or if the total connections exceed 75% of the operation limit, schedule the creation of a new connection (provided the connection limit has not been reached).
  6. Install dependencies for ppm

    master

    Before building the ppm module, ensure you have the following requirements met:

    • OpenLDAP sources: Both the OpenLDAP source tree and the ppm source must be available.
    • cracklib development files: Required if you want to test passwords against cracklib.
    • pandoc: Required if you want to build the man page documentation.
  7. Install and configure the ppm (Password Policy Module)

    master

    The ppm module is an extension for the OpenLDAP password policy overlay (slapo-ppolicy) that checks password quality based on character classes and other criteria during password modification.

    Setup Requirements

    1. Enable the ppolicy overlay in your database.
    2. Define a default password policy in your OpenLDAP configuration or use the pwdPolicySubentry attribute to point to a specific policy.

    Configuration by OpenLDAP Version

    OpenLDAP 2.6+

    Use the ppolicy_check_module parameter in your slapd.conf or cn=config to point to the ppm.so library. The policy configuration itself is stored in the pwdCheckModuleArg attribute of the password policy entry. This attribute must contain a base64 encoded version of your configuration text.

    slapd.conf example:

    overlay ppolicy
    ppolicy_default "cn=default,ou=policies,dc=my-domain,dc=com"
    ppolicy_check_module /usr/local/openldap/libexec/openldap/ppm.so

    LDIF example (cn=config):

    dn: cn=default,ou=policies,dc=my-domain,dc=com
    objectClass: pwdPolicy
    objectClass: top
    objectClass: pwdPolicyChecker
    objectClass: person
    pwdCheckQuality: 2
    pwdAttribute: userPassword
    sn: default
    cn: default
    pwdMinLength: 6
    pwdCheckModuleArg:: bWluUXVhbGl0eSAzCmNoZWNrUkROIDAKY2hlY2tBdHRyaWJ1dGVzCmZvcmJpZGRlbkNoYXJzCm1heENvbnNlY3V0aXZlUGVyQ2xhc3MgMAp1c2VDcmFja2xpYiAwCmNyYWNrbGliRGljdCAvdmFyL2NhY2hlL2NyYWNrbGliL2NyYWNrbGliX2RpY3QKY2xhc3MtdXBwZXJDYXNlIEFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWFlaIDAgMSAwCmNsYXNzLWxvd2VyQ2FzZSBhYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5eiAwIDEgMApjbGFzcy1kaWdpdCAwMTIzNDU2Nzg5IDAgMSAwCmNsYXNzLXNwZWNpYWwgPD4sPzsuOi8hwqfDuSUqwrVewqgkwqPCsibDqX4iIyd7KFstfMOoYF9cw6dew6BAKV3CsD19KyAwIDEgMAoK
    pwdUseCheckModule: TRUE

    OpenLDAP 2.5

    Add a pwdCheckModule attribute to your password policy entry pointing to the path of the ppm.so library (e.g., /usr/local/lib/ppm.so). Do not use the pwdUseCheckModule attribute.

    Note: Remove the ppolicy_check_module parameter from slapd.conf in version 2.5, as it is managed within the password policy definition.

    overlay ppolicy
    ppolicy_default "cn=default,ou=policies,dc=my-domain,dc=com"
    ppolicy_check_module /usr/local/openldap/libexec/openldap/ppm.so
  8. Overview of UTBM (Unicode Tuned Boyer-Moore)

    master

    UTBM (Unicode Tuned Boyer-Moore) is a package designed to perform tuned Boyer-Moore searches on Unicode UCS2 text. It is capable of handling both high and low surrogates.

    Core Assumptions

    When using UTBM, the following conditions are assumed to be met:

    • The search pattern and the target text are already normalized.
    • Upper, lower, and title case conversions are one-to-one.
    • For case conversions, UCS2 characters always convert to other UCS2 characters, and UTF-16 characters always convert to other UTF-16 characters.
  9. Overview of slapd backends

    master

    The slapd (8) daemon uses backends to serve LDAP requests. Backends can be compiled statically into slapd or loaded dynamically if module support is enabled. You can configure multiple instances of a backend to serve different databases from a single slapd server.

    Note that specific configuration options for each backend are found in their respective manual pages (e.g., slapd-mdb(5)).

  10. Overview of slapd modules in contrib/slapd-modules

    master
    The contrib/slapd-modules directory contains various native-API slapd modules, including overlays and plugins, that extend the functionality of the OpenLDAP server. These modules allow for specialized behaviors such as access control, automated group updates, attribute hiding, and compatibility with specific protocols or directory services (like Microsoft AD or Kerberos).
  11. Overview of the slapd-sql backend

    master

    The slapd-sql backend is an experimental module designed to present information stored in a Relational Database Management System (RDBMS) as an LDAP subtree.

    Key Use Cases:

    • Data Integration: Exposing existing account information from an RDBMS to modern applications that expect LDAP (e.g., for authentication or email lookups).
    • Synchronization: Distributing or synchronizing data between different sites or applications using RDBMS and/or LDAP.
    • Interoperability: Allowing SQL and LDAP applications to inter-operate without requiring full data replication.

    Important Limitations:

    • It is not intended as a general-purpose replacement for the standard MDB backend (LMDB).
    • It uses ODBC to connect to RDBMSes and is highly configurable for various SQL dialects.
    • It does not natively support multiple objectClasses per entry (though this can be implemented via a specific schema technique) or referrals (which can be implemented as user-defined schema).