1LDAP(3)                    Library Functions Manual                    LDAP(3)
2
3
4

NAME

6       ldap - OpenLDAP Lightweight Directory Access Protocol API
7

LIBRARY

9       OpenLDAP LDAP (libldap, -lldap)
10

SYNOPSIS

12       #include <ldap.h>
13

DESCRIPTION

15       The  Lightweight  Directory  Access Protocol (LDAP) (RFC 4510) provides
16       access to X.500 directory services.  These services may be  stand-alone
17       or  part  of a distributed directory service.  This client API supports
18       LDAP over TCP (RFC 4511), LDAP over TLS/SSL, and LDAP  over  IPC  (UNIX
19       domain  sockets).  This API supports SASL (RFC 4513) and Start TLS (RFC
20       4513) as well as a number of protocol extensions.  This API is  loosely
21       based  upon  IETF/LDAPEXT  C LDAP API draft specification, a (orphaned)
22       work in progress.
23
24       The  OpenLDAP  Software  package  includes  a  stand-alone  server   in
25       slapd(8), various LDAP clients, and an LDAP client library used to pro‐
26       vide programmatic access to the LDAP protocol. This man page  gives  an
27       overview of the LDAP library routines.
28
29       Both synchronous and asynchronous APIs are provided.  Also included are
30       various routines to parse the results  returned  from  these  routines.
31       These routines are found in the -lldap library.
32
33       The basic interaction is as follows.  A session handle is created using
34       ldap_initialize(3) and  set  the  protocol  version  to  3  by  calling
35       ldap_set_option(3).  The underlying session is established first opera‐
36       tion is issued.  This would generally be a Start TLS or Bind operation,
37       or  a Search operation to read attributes of the Root DSE.  A Start TLS
38       operation is performed by calling ldap_start_tls_s(3).  A LDAP bind op‐
39       eration  is  performed  by  calling  ldap_sasl_bind(3)  or  one  of its
40       friends.    A   Search    operation    is    performed    by    calling
41       ldap_search_ext_s(3) or one of its friends.
42
43       Subsequently, additional operations are performed by calling one of the
44       synchronous or asynchronous routines  (e.g.,  ldap_compare_ext_s(3)  or
45       ldap_compare_ext(3) followed by ldap_result(3)).  Results returned from
46       these routines are interpreted by calling  the  LDAP  parsing  routines
47       such as ldap_parse_result(3).  The LDAP association and underlying con‐
48       nection is terminated by calling ldap_unbind_ext(3).  Errors can be in‐
49       terpreted by calling ldap_err2string(3).
50

LDAP versions

52       This  library  supports  version  3 of the Lightweight Directory Access
53       Protocol (LDAPv3) as defined in RFC 4510.  It also supports  a  variant
54       of version 2 of LDAP as defined by U-Mich LDAP and, to some degree, RFC
55       1777.  Version 2 (all variants) are  considered  obsolete.   Version  3
56       should be used instead.
57
58       For backwards compatibility reasons, the library defaults to version 2.
59       Hence, all new applications (and all actively maintained  applications)
60       should  use ldap_set_option(3) to select version 3.  The library manual
61       pages assume version 3 has been selected.
62

INPUT and OUTPUT PARAMETERS

64       All character string input/output is expected to  be/is  UTF-8  encoded
65       Unicode (version 3.2).
66
67       Distinguished  names (DN) (and relative distinguished names (RDN) to be
68       passed to the LDAP routines should conform to  RFC  4514  UTF-8  string
69       representation.
70
71       Search  filters to be passed to the search routines are to be construc‐
72       ted by hand and should conform to RFC 4515 UTF-8 string representation.
73
74       LDAP URLs to be passed to routines are expected to conform to RFC  4516
75       format.  The ldap_url(3) routines can be used to work with LDAP URLs.
76
77       LDAP  controls  to  be  passed to routines can be manipulated using the
78       ldap_controls(3) routines.
79

DISPLAYING RESULTS

81       Results obtained from the search routines can be  output  by  hand,  by
82       calling  ldap_first_entry(3) and ldap_next_entry(3) to step through the
83       entries returned, ldap_first_attribute(3) and ldap_next_attribute(3) to
84       step  through an entry's attributes, and ldap_get_values(3) to retrieve
85       a given attribute's values.  Attribute values may or may  not  be  dis‐
86       playable.
87

UTILITY ROUTINES

89       Also  provided are various utility routines.  The ldap_sort(3) routines
90       are used to sort the entries and values returned via  the  ldap  search
91       routines.
92

DEPRECATED INTERFACES

94       A  number  of  interfaces are now considered deprecated.  For instance,
95       ldap_add(3) is deprecated in favor of ldap_add_ext(3).  Deprecated  in‐
96       terfaces  generally  remain  in the library.  The macro LDAP_DEPRECATED
97       can be defined to a non-zero  value  (e.g.,  -DLDAP_DEPRECATED=1)  when
98       compiling  program designed to use deprecated interfaces.  It is recom‐
99       mended that developers writing new programs, or updating old  programs,
100       avoid  use  of  deprecated  interfaces.  Over time, it is expected that
101       documentation (and, eventually, support) for deprecated  interfaces  to
102       be eliminated.
103

BER LIBRARY

105       Also  included in the distribution is a set of lightweight Basic Encod‐
106       ing Rules routines.  These routines are used by the LDAP  library  rou‐
107       tines  to  encode and decode LDAP protocol elements using the (slightly
108       simplified) Basic Encoding Rules defined by LDAP.  They  are  not  nor‐
109       mally  used  directly by an LDAP application program except in the han‐
110       dling of controls and extended  operations.   The  routines  provide  a
111       printf  and scanf-like interface, as well as lower-level access.  These
112       routines are discussed  in  lber-decode(3),  lber-encode(3),  lber-mem‐
113       ory(3), and lber-types(3).
114

INDEX

116       ldap_initialize(3)  initialize  the LDAP library without opening a con‐
117                           nection to a server
118
119       ldap_result(3)      wait for the result from an asynchronous operation
120
121       ldap_abandon_ext(3) abandon (abort) an asynchronous operation
122
123       ldap_add_ext(3)     asynchronously add an entry
124
125       ldap_add_ext_s(3)   synchronously add an entry
126
127       ldap_sasl_bind(3)   asynchronously bind to the directory
128
129       ldap_sasl_bind_s(3) synchronously bind to the directory
130
131       ldap_unbind_ext(3)  synchronously unbind from the LDAP server and close
132                           the connection
133
134       ldap_unbind(3) and ldap_unbind_s(3) are
135                           equivalent to ldap_unbind_ext(3)
136
137       ldap_memfree(3)     dispose of memory allocated by LDAP routines.
138
139       ldap_compare_ext(3) asynchronously compare to a directory entry
140
141       ldap_compare_ext_s(3)
142                           synchronously compare to a directory entry
143
144       ldap_delete_ext(3)  asynchronously delete an entry
145
146       ldap_delete_ext_s(3)
147                           synchronously delete an entry
148
149       ld_errno(3)         LDAP error indication
150
151       ldap_errlist(3)     list of LDAP errors and their meanings
152
153       ldap_err2string(3)  convert LDAP error indication to a string
154
155       ldap_extended_operation(3)
156                           asynchronously perform an arbitrary extended opera‐
157                           tion
158
159       ldap_extended_operation_s(3)
160                           synchronously perform an arbitrary extended  opera‐
161                           tion
162
163       ldap_first_attribute(3)
164                           return first attribute name in an entry
165
166       ldap_next_attribute(3)
167                           return next attribute name in an entry
168
169       ldap_first_entry(3) return first entry in a chain of search results
170
171       ldap_next_entry(3)  return next entry in a chain of search results
172
173       ldap_count_entries(3)
174                           return number of entries in a search result
175
176       ldap_get_dn(3)      extract the DN from an entry
177
178       ldap_get_values_len(3)
179                           return an attribute's values with lengths
180
181       ldap_value_free_len(3)
182                           free memory allocated by ldap_get_values_len(3)
183
184       ldap_count_values_len(3)
185                           return number of values
186
187       ldap_modify_ext(3)  asynchronously modify an entry
188
189       ldap_modify_ext_s(3)
190                           synchronously modify an entry
191
192       ldap_mods_free(3)   free  array  of  pointers to mod structures used by
193                           ldap_modify_ext(3)
194
195       ldap_rename(3)      asynchronously rename an entry
196
197       ldap_rename_s(3)    synchronously rename an entry
198
199       ldap_msgfree(3)     free results allocated by ldap_result(3)
200
201       ldap_msgtype(3)     return the message type of a message from  ldap_re‐
202                           sult(3)
203
204       ldap_msgid(3)       return  the  message  id of a message from ldap_re‐
205                           sult(3)
206
207       ldap_search_ext(3)  asynchronously search the directory
208
209       ldap_search_ext_s(3)
210                           synchronously search the directory
211
212       ldap_is_ldap_url(3) check a URL string to see if it is an LDAP URL
213
214       ldap_url_parse(3)   break up an LDAP URL string into its components
215
216       ldap_sort_entries(3)
217                           sort a list of search results
218
219       ldap_sort_values(3) sort a list of attribute values
220
221       ldap_sort_strcasecmp(3)
222                           case insensitive string comparison
223

SEE ALSO

225       ldap.conf(5),         slapd(8),          draft-ietf-ldapext-ldap-c-api-
226       xx.txt <http://www.ietf.org>
227

ACKNOWLEDGEMENTS

229       OpenLDAP  Software  is developed and maintained by The OpenLDAP Project
230       <http://www.openldap.org/>.  OpenLDAP Software is derived from the Uni‐
231       versity of Michigan LDAP 3.3 Release.
232
233       These  API manual pages are loosely based upon descriptions provided in
234       the IETF/LDAPEXT C LDAP  API  Internet  Draft,  a  (orphaned)  work  in
235       progress.
236
237
238
239
240OpenLDAP 2.6.6                    2023/07/31                           LDAP(3)
Impressum