1 .TH LDAP 3 "2008/07/16" "OpenLDAP 2.4.11"
2 .\" $OpenLDAP: pkg/ldap/doc/man/man3/ldap.3,v 1.40.2.4 2008/02/11 23:26:39 kurt Exp $
3 .\" Copyright 1998-2008 The OpenLDAP Foundation All Rights Reserved.
4 .\" Copying restrictions apply. See COPYRIGHT/LICENSE.
6 ldap \- OpenLDAP Lightweight Directory Access Protocol API
8 OpenLDAP LDAP (libldap, -lldap)
17 The Lightweight Directory Access Protocol (LDAP) (RFC 4510) provides
18 access to X.500 directory services. These services may be stand\-alone
19 or part of a distributed directory service. This client API supports
20 LDAP over TCP (RFC 4511), LDAP over TLS/SSL, and LDAP over IPC (UNIX
21 domain sockets). This API supports SASL (RFC 4513) and Start TLS
22 (RFC 4513) as well as a number of protocol extensions. This API is
23 loosely based upon IETF/LDAPEXT C LDAP API draft specification, a (orphaned)
26 The OpenLDAP Software package includes a stand\-alone server in
28 various LDAP clients, and an LDAP client library used to provide
29 programmatic access to the LDAP protocol. This man page gives an
30 overview of the LDAP library routines.
32 Both synchronous and asynchronous APIs are provided. Also included are
33 various routines to parse the results returned from these routines.
34 These routines are found in the \-lldap library.
36 The basic interaction is as follows. A session handle is
38 .BR ldap_initialize (3)
39 and set the protocol version to 3 by calling
40 .BR ldap_set_option (3).
41 The underlying session is established first operation is
42 issued. This would generally be a Start TLS or Bind operation,
43 or a Search operation to read attributes of the Root DSE.
44 A Start TLS operation is performed by calling
45 .BR ldap_start_tls_s (3).
46 A LDAP bind operation is performed by calling
47 .BR ldap_sasl_bind (3)
48 or one of its friends.
49 A Search operation is performed by calling ldap_search_ext_s(3)
50 or one of its friends.
52 Subsequently, additional operations are performed
53 by calling one of the synchronous or asynchronous routines (e.g.,
54 .BR ldap_compare_ext_s (3)
56 .BR ldap_compare_ext (3)
59 Results returned from these routines are interpreted by calling the
60 LDAP parsing routines such as
61 .BR ldap_parse_result (3).
62 The LDAP association and underlying connection is terminated by calling
63 .BR ldap_unbind_ext (3).
64 Errors can be interpreted by calling
65 .BR ldap_err2string (3).
67 This library supports version 3 of the Lightweight Directory Access
68 Protocol (LDAPv3) as defined in RFC 4510. It also supports a variant
69 of version 2 of LDAP as defined by U-Mich LDAP and, to some degree,
70 RFC 1777. Version 2 (all variants) are considered obsolete.
71 Version 3 should be used instead.
73 For backwards compatibility reasons, the library defaults to version 2.
74 Hence, all new applications (and all actively maintained applications)
76 .BR ldap_set_option (3)
77 to select version 3. The library manual pages assume version 3
79 .SH INPUT and OUTPUT PARAMETERS
80 All character string input/output is expected to be/is UTF\-8
81 encoded Unicode (version 3.2).
83 Distinguished names (DN) (and relative distinguished names (RDN) to
84 be passed to the LDAP routines should conform to RFC 4514 UTF\-8
85 string representation.
87 Search filters to be passed to the search routines are to be
88 constructed by hand and should conform to RFC 4515 UTF\-8
89 string representation.
91 LDAP URLs to be passed to routines are expected to conform
92 to RFC 4516 format. The
94 routines can be used to work with LDAP URLs.
96 LDAP controls to be passed to routines can be manipulated using the
99 .SH DISPLAYING RESULTS
100 Results obtained from the search routines can be output by hand,
102 .BR ldap_first_entry (3)
104 .BR ldap_next_entry (3)
106 the entries returned,
107 .BR ldap_first_attribute (3)
109 .BR ldap_next_attribute (3)
110 to step through an entry's attributes, and
111 .BR ldap_get_values (3)
112 to retrieve a given attribute's values. Attribute values
113 may or may not be displayable.
115 Also provided are various utility routines. The
117 routines are used to sort the entries and values returned via
118 the ldap search routines.
119 .SH DEPRECATED INTERFACES
120 A number of interfaces are now considered deprecated. For instance,
121 ldap_add(3) is deprecated in favor of ldap_add_ext(3).
122 Deprecated interfaces generally remain in the library. The macro
123 LDAP_DEPRECATED can be defined to a non-zero value
124 (e.g., -DLDAP_DEPRECATED=1) when compiling program designed to use
125 deprecated interfaces. It is recommended that developers writing new
126 programs, or updating old programs, avoid use of deprecated interfaces.
127 Over time, it is expected that documentation (and, eventually, support) for
128 deprecated interfaces to be eliminated.
130 Also included in the distribution is a set of lightweight Basic
131 Encoding Rules routines. These routines are used by the LDAP library
132 routines to encode and decode LDAP protocol elements using the
133 (slightly simplified) Basic Encoding Rules defined by LDAP. They are
134 not normally used directly by an LDAP application program except
135 in the handling of controls and extended operations. The
136 routines provide a printf and scanf\-like interface, as well as
137 lower\-level access. These routines are discussed in
138 .BR lber\-decode (3),
139 .BR lber\-encode (3),
140 .BR lber\-memory (3),
145 .SM ldap_initialize(3)
146 initialize the LDAP library without opening a connection to a server
149 wait for the result from an asynchronous operation
151 .SM ldap_abandon_ext(3)
152 abandon (abort) an asynchronous operation
155 asynchronously add an entry
157 .SM ldap_add_ext_s(3)
158 synchronously add an entry
160 .SM ldap_sasl_bind(3)
161 asynchronously bind to the directory
163 .SM ldap_sasl_bind_s(3)
164 synchronously bind to the directory
166 .SM ldap_unbind_ext(3)
167 synchronously unbind from the LDAP server and close the connection
169 .SM ldap_unbind(3) and ldap_unbind_s(3) are
171 .BR ldap_unbind_ext (3)
174 dispose of memory allocated by LDAP routines.
176 .SM ldap_compare_ext(3)
177 asynchronously compare to a directory entry
179 .SM ldap_compare_ext_s(3)
180 synchronously compare to a directory entry
182 .SM ldap_delete_ext(3)
183 asynchronously delete an entry
185 .SM ldap_delete_ext_s(3)
186 synchronously delete an entry
189 LDAP error indication
192 list of LDAP errors and their meanings
194 .SM ldap_err2string(3)
195 convert LDAP error indication to a string
197 .SM ldap_extended_operation(3)
198 asynchronously perform an arbitrary extended operation
200 .SM ldap_extended_operation_s(3)
201 synchronously perform an arbitrary extended operation
203 .SM ldap_first_attribute(3)
204 return first attribute name in an entry
206 .SM ldap_next_attribute(3)
207 return next attribute name in an entry
209 .SM ldap_first_entry(3)
210 return first entry in a chain of search results
212 .SM ldap_next_entry(3)
213 return next entry in a chain of search results
215 .SM ldap_count_entries(3)
216 return number of entries in a search result
219 extract the DN from an entry
221 .SM ldap_get_values_len(3)
222 return an attribute's values with lengths
224 .SM ldap_value_free_len(3)
225 free memory allocated by ldap_get_values_len(3)
227 .SM ldap_count_values_len(3)
228 return number of values
230 .SM ldap_modify_ext(3)
231 asynchronously modify an entry
233 .SM ldap_modify_ext_s(3)
234 synchronously modify an entry
236 .SM ldap_mods_free(3)
237 free array of pointers to mod structures used by ldap_modify_ext(3)
240 asynchronously rename an entry
243 synchronously rename an entry
246 free results allocated by ldap_result(3)
249 return the message type of a message from ldap_result(3)
252 return the message id of a message from ldap_result(3)
254 .SM ldap_search_ext(3)
255 asynchronously search the directory
257 .SM ldap_search_ext_s(3)
258 synchronously search the directory
260 .SM ldap_is_ldap_url(3)
261 check a URL string to see if it is an LDAP URL
263 .SM ldap_url_parse(3)
264 break up an LDAP URL string into its components
266 .SM ldap_sort_entries(3)
267 sort a list of search results
269 .SM ldap_sort_values(3)
270 sort a list of attribute values
272 .SM ldap_sort_strcasecmp(3)
273 case insensitive string comparison
277 .BR draft-ietf-ldapext-ldap-c-api-xx.txt \ <http://www.ietf.org>
279 .\" Shared Project Acknowledgement Text
280 .B "OpenLDAP Software"
281 is developed and maintained by The OpenLDAP Project <http://www.openldap.org/>.
282 .B "OpenLDAP Software"
283 is derived from University of Michigan LDAP 3.3 Release.
285 These API manual pages are loosely based upon descriptions provided
286 in the IETF/LDAPEXT C LDAP API Internet Draft, a (orphaned) work