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
39       operation  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
49       interpreted 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 con‐
72       structed by hand and should conform to RFC 4515 UTF-8 string  represen‐
73       tation.
74
75       LDAP  URLs to be passed to routines are expected to conform to RFC 4516
76       format.  The ldap_url(3) routines can be used to work with LDAP URLs.
77
78       LDAP controls to be passed to routines can  be  manipulated  using  the
79       ldap_controls(3) routines.
80

DISPLAYING RESULTS

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

UTILITY ROUTINES

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

DEPRECATED INTERFACES

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

BER LIBRARY

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

INDEX

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

SEE ALSO

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

ACKNOWLEDGEMENTS

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