The Lightweight Directory Access Protocol (LDAP) (RFC 4510) provides access to X.500 directory services. These services may be stand-alone or part of a distributed directory service. This client API supports LDAP over TCP (RFC 4511), LDAP over TLS/SSL, and LDAP over IPC (UNIX domain sockets). This API supports SASL (RFC 4513) and Start TLS (RFC 4513) as well as a number of protocol extensions. This API is loosely based upon IETF/LDAPEXT C LDAP API draft specification, a (orphaned) work in progress.
The OpenLDAP Software package includes a stand-alone server in slapd(8), various LDAP clients, and an LDAP client library used to provide programmatic access to the LDAP protocol. This man page gives an overview of the LDAP library routines.
Both synchronous and asynchronous APIs are provided. Also included are various routines to parse the results returned from these routines. These routines are found in the -lldap library.
The basic interaction is as follows. A session handle is created using ldap_initialize(3) and set the protocol version to 3 by calling ldap_set_option(3). The underlying session is established first operation is issued. This would generally be a Start TLS or Bind operation, or a Search operation to read attributes of the Root DSE. A Start TLS operation is performed by calling ldap_start_tls_s(3). A LDAP bind operation is performed by calling ldap_sasl_bind(3) or one of its friends. A Search operation is performed by calling ldap_search_ext_s(3) or one of its friends.
Subsequently, additional operations are performed by calling one of the synchronous or asynchronous routines (e.g., ldap_compare_ext_s(3) or ldap_compare_ext(3) followed by ldap_result(3)). Results returned from these routines are interpreted by calling the LDAP parsing routines such as ldap_parse_result(3). The LDAP association and underlying connection is terminated by calling ldap_unbind_ext(3). Errors can be interpreted by calling ldap_err2string(3).
For backwards compatibility reasons, the library defaults to version 2. Hence, all new applications (and all actively maintained applications) should use ldap_set_option(3) to select version 3. The library manual pages assume version 3 has been selected.
Distinguished names (DN) (and relative distinguished names (RDN) to be passed to the LDAP routines should conform to RFC 4514 UTF-8 string representation.
Search filters to be passed to the search routines are to be constructed by hand and should conform to RFC 4515 UTF-8 string representation.
LDAP URLs to be passed to routines are expected to conform to RFC 4516 format. The ldap_url(3) routines can be used to work with LDAP URLs.
LDAP controls to be passed to routines can be manipulated using the ldap_controls(3) routines.
These API manual pages are loosely based upon descriptions provided in the IETF/LDAPEXT C LDAP API Internet Draft, a (orphaned) work in progress.