LDAP(3)
π LDAP(3) π
okay bestie, this is the LDAP(3) page from the Library Functions Manual, and itβs all about the OpenLDAP Lightweight Directory Access Protocol API. Itβs giving βdirectory services, but programmatic,β and weβre gonna walk through it together. π¦β¨
π NAME π
ldap β the OpenLDAP Lightweight Directory Access Protocol API. Thatβs the name, thatβs the mission, no cap. π
πΈ LIBRARY πΈ
OpenLDAP LDAP (libldap, -lldap).
π SYNOPSIS π
#include <ldap.h>
β¨ DESCRIPTION β¨
The Lightweight Directory Access Protocol (LDAP) (RFC 4510) is how you get at X.500 directory services. Those services can 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). It also supports SASL (RFC 4513) and Start TLS (RFC 4513), plus a bunch of protocol extensions. This API is loosely based upon the IETF/LDAPEXT C LDAP API draft specification β a (orphaned) work in progress, iykyk. π«Ά
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 you set the protocol version to 3 by calling ldap_set_option(3). The underlying session gets established when the first operation is issued. That 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). π
π§ LDAP versions π§
This library supports version 3 of the Lightweight Directory Access Protocol (LDAPv3) as defined in RFC 4510. It also supports a variant of version 2 of LDAP as defined by U-Mich LDAP and, to some degree, RFC 1777. Version 2 (all variants) are considered obsolete. Version 3 should be used instead. π¨
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. Periodt. π―
π INPUT and OUTPUT PARAMETERS π
All character string input/output is expected to be / is UTF-8 encoded Unicode (version 3.2). π§
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. ποΈ
π¦ DISPLAYING RESULTS π¦
Results obtained from the search routines can be output by hand, by calling ldap_first_entry(3) and ldap_next_entry(3) to step through the entries returned, ldap_first_attribute(3) and ldap_next_attribute(3) to step through an entryβs attributes, and ldap_get_values(3) to retrieve a given attributeβs values. Attribute values may or may not be displayable. π
πΈ UTILITY ROUTINES πΈ
Also provided are various utility routines. The ldap_sort(3) routines are used to sort the entries and values returned via the ldap search routines. π
π DEPRECATED INTERFACES π
A number of interfaces are now considered deprecated. For instance, ldap_add(3) is deprecated in favor of ldap_add_ext(3). Deprecated interfaces generally remain in the library. The macro LDAP_DEPRECATED can be defined to a non-zero value (e.g., -DLDAP_DEPRECATED=1) when compiling program designed to use deprecated interfaces. It is recommended that developers writing new programs, or updating old programs, avoid use of deprecated interfaces. Over time, it is expected that documentation (and, eventually, support) for deprecated interfaces to be eliminated. β οΈ
π§ BER LIBRARY π§
Also included in the distribution is a set of lightweight Basic Encoding Rules routines. These routines are used by the LDAP library routines to encode and decode LDAP protocol elements using the (slightly simplified) Basic Encoding Rules defined by LDAP. They are not normally used directly by an LDAP application program except in the handling of controls and extended operations. The routines provide a printf and scanf-like interface, as well as lower-level access. These routines are discussed in lber-decode(3), lber-encode(3), lber-memory(3), and lber-types(3). π§β¨
π INDEX π
Hereβs the whole friend group of routines β who does what, bestie:
ldap_initialize(3)β initialize the LDAP library without opening a connection to a serverldap_result(3)β wait for the result from an asynchronous operationldap_abandon_ext(3)β abandon (abort) an asynchronous operationldap_add_ext(3)β asynchronously add an entryldap_add_ext_s(3)β synchronously add an entryldap_sasl_bind(3)β asynchronously bind to the directoryldap_sasl_bind_s(3)β synchronously bind to the directoryldap_unbind_ext(3)β synchronously unbind from the LDAP server and close the connectionldap_unbind(3)andldap_unbind_s(3)β are equivalent toldap_unbind_ext(3)ldap_memfree(3)β dispose of memory allocated by LDAP routines.ldap_compare_ext(3)β asynchronously compare to a directory entryldap_compare_ext_s(3)β synchronously compare to a directory entryldap_delete_ext(3)β asynchronously delete an entryldap_delete_ext_s(3)β synchronously delete an entryld_errno(3)β LDAP error indicationldap_errlist(3)β list of LDAP errors and their meaningsldap_err2string(3)β convert LDAP error indication to a stringldap_extended_operation(3)β asynchronously perform an arbitrary extended operationldap_extended_operation_s(3)β synchronously perform an arbitrary extended operationldap_first_attribute(3)β return first attribute name in an entryldap_next_attribute(3)β return next attribute name in an entryldap_first_entry(3)β return first entry in a chain of search resultsldap_next_entry(3)β return next entry in a chain of search resultsldap_count_entries(3)β return number of entries in a search resultldap_get_dn(3)β extract the DN from an entryldap_get_values_len(3)β return an attributeβs values with lengthsldap_value_free_len(3)β free memory allocated byldap_get_values_len(3)ldap_count_values_len(3)β return number of valuesldap_modify_ext(3)β asynchronously modify an entryldap_modify_ext_s(3)β synchronously modify an entryldap_mods_free(3)β free array of pointers to mod structures used byldap_modify_ext(3)ldap_rename(3)β asynchronously rename an entryldap_rename_s(3)β synchronously rename an entryldap_msgfree(3)β free results allocated byldap_result(3)ldap_msgtype(3)β return the message type of a message fromldap_result(3)ldap_msgid(3)β return the message id of a message fromldap_result(3)ldap_search_ext(3)β asynchronously search the directoryldap_search_ext_s(3)β synchronously search the directoryldap_is_ldap_url(3)β check a URL string to see if it is an LDAP URLldap_url_parse(3)β break up an LDAP URL string into its componentsldap_sort_entries(3)β sort a list of search resultsldap_sort_values(3)β sort a list of attribute valuesldap_sort_strcasecmp(3)β case insensitive string comparison
π SEE ALSO π
ldap.conf(5), slapd(8), draft-ietf-ldapext-ldap-c-api-xx.txt <http://www.ietf.org>
π«Ά ACKNOWLEDGEMENTS π«Ά
OpenLDAP Software is developed and maintained by The OpenLDAP Project <http://www.openldap.org/>. OpenLDAP Software is derived from the University of Michigan LDAP 3.3 Release. π
These API manual pages are loosely based upon descriptions provided in the IETF/LDAPEXT C LDAP API Internet Draft, a (orphaned) work in progress. π
xoxo, from the OpenLDAP 2.6.16 source/version, dated 2026/10/21 β now go slay those directory operations, bestie π β¨
π¦ where this page comes from
- fedora 44: openldap-devel 2.6.16-1.fc44 Β· OLDAP-2.8
- fedora 44: openldap-devel 2.6.16-1.fc44 Β· OLDAP-2.8
- Copyright 1998-2026 The OpenLDAP Foundation All Rights Reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms