3 Network Working Group M. Smith, Editor
4 INTERNET-DRAFT Netscape Communications Corp.
5 Intended Category: Standards Track T. Howes
6 Obsoletes: RFC 1823 Loudcloud, Inc.
7 Expires: May 2001 A. Herron
10 Sun Microsystems, Inc.
17 The C LDAP Application Program Interface
18 <draft-ietf-ldapext-ldap-c-api-05.txt>
21 1. Status of this Memo
23 This document is an Internet-Draft and is in full conformance with all
24 provisions of Section 10 of RFC2026. Internet-Drafts are working docu-
25 ments of the Internet Engineering Task Force (IETF), its areas, and its
26 working groups. Note that other groups may also distribute working
27 documents as Internet-Drafts.
29 Internet-Drafts are draft documents valid for a maximum of six months
30 and may be updated, replaced, or obsoleted by other documents at any
31 time. It is inappropriate to use Internet-Drafts as reference material
32 or to cite them other than as "work in progress."
34 The list of current Internet-Drafts can be accessed at
35 http://www.ietf.org/ietf/1id-abstracts.txt.
37 The list of Internet-Draft Shadow Directories can be accessed at
38 http://www.ietf.org/shadow.html.
40 This draft document will be submitted to the RFC Editor as a Standards
41 Track document. Distribution of this memo is unlimited. Technical dis-
42 cussion of this document will take place on the IETF LDAP Extension
43 Working Group mailing list <ietf-ldapext@netscape.com>. Please send
44 editorial comments directly to the authors.
46 Copyright (C) The Internet Society (1997-1999). All Rights Reserved.
48 Please see the Copyright section near the end of this document for more
54 Expires: May 2001 [Page 1]
56 C LDAP API C LDAP Application Program Interface 17 November 2000
61 This document defines a C language application program interface (API)
62 to the Lightweight Directory Access Protocol (LDAP). This document
63 replaces the previous definition of this API, defined in RFC 1823,
64 updating it to include support for features found in version 3 of the
65 LDAP protocol. New extended operation functions were added to support
66 LDAPv3 features such as controls. In addition, other LDAP API changes
67 were made to support information hiding and thread safety.
69 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
70 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
71 document are to be interpreted as described in RFC 2119[1].
73 The C LDAP API is designed to be powerful, yet simple to use. It defines
74 compatible synchronous and asynchronous interfaces to LDAP to suit a
75 wide variety of applications. This document gives a brief overview of
76 the LDAP model, then an overview of how the API is used by an applica-
77 tion program to obtain LDAP information. The API calls are described in
78 detail, followed by appendices that provide example code demonstrating
79 use of the API, the namespace consumed by the API, a summary of require-
80 ments for API extensions, known incompatibilities with RFC 1823, and a
81 list of changes made since the last revision of this document.
86 1. Status of this Memo............................................1
87 2. Introduction...................................................2
88 3. Table of Contents..............................................2
89 4. Overview of the LDAP Model.....................................4
90 5. Overview of LDAP API Use and General Requirements..............4
91 6. Header Requirements............................................6
92 7. Common Data Structures and Types...............................7
93 8. Memory Handling Overview.......................................9
94 9. Retrieving Information About the API Implementation............9
95 9.1. Retrieving Information at Compile Time......................10
96 9.2. Retrieving Information During Execution.....................11
97 10. Result Codes...................................................14
98 11. Performing LDAP Operations.....................................16
99 11.1. Initializing an LDAP Session................................16
100 11.2. LDAP Session Handle Options.................................17
101 11.3. Working With Controls.......................................23
102 11.3.1. A Client Control That Governs Referral Processing........24
103 11.4. Authenticating to the directory.............................25
104 11.5. Closing the session.........................................27
105 11.6. Searching...................................................28
106 11.7. Reading an Entry............................................32
110 Expires: May 2001 [Page 2]
112 C LDAP API C LDAP Application Program Interface 17 November 2000
116 11.8. Listing the Children of an Entry............................32
117 11.9. Comparing a Value Against an Entry..........................33
118 11.10. Modifying an entry..........................................35
119 11.11. Modifying the Name of an Entry..............................37
120 11.12. Adding an entry.............................................39
121 11.13. Deleting an entry...........................................41
122 11.14. Extended Operations.........................................43
123 12. Abandoning An Operation........................................44
124 13. Obtaining Results and Peeking Inside LDAP Messages.............45
125 14. Handling Errors and Parsing Results............................47
126 15. Stepping Through a List of Results.............................51
127 16. Parsing Search Results.........................................51
128 16.1. Stepping Through a List of Entries or References............52
129 16.2. Stepping Through the Attributes of an Entry.................53
130 16.3. Retrieving the Values of an Attribute.......................54
131 16.4. Retrieving the name of an entry.............................55
132 16.5. Retrieving controls from an entry...........................56
133 16.6. Parsing References..........................................57
134 17. Encoded ASN.1 Value Manipulation...............................58
135 17.1. BER Data Structures and Types...............................58
136 17.2. Memory Disposal and Utility Functions.......................60
137 17.3. Encoding....................................................60
138 17.4. Encoding Example............................................63
139 17.5. Decoding....................................................64
140 17.6. Decoding Example............................................67
141 18. Security Considerations........................................70
142 19. Acknowledgements...............................................70
143 20. Copyright......................................................70
144 21. Bibliography...................................................71
145 22. Authors' Addresses.............................................72
146 23. Appendix A - Sample C LDAP API Code............................73
147 24. Appendix B - Namespace Consumed By This Specification..........74
148 25. Appendix C - Summary of Requirements for API Extensions........75
149 25.1. Compatibility...............................................75
150 25.2. Style.......................................................75
151 25.3. Dependence on Externally Defined Types......................75
152 25.4. Compile Time Information....................................76
153 25.5. Runtime Information.........................................76
154 25.6. Values Used for Session Handle Options......................76
155 26. Appendix D - Known Incompatibilities with RFC 1823.............76
156 26.1. Opaque LDAP Structure.......................................76
157 26.2. Additional Result Codes.....................................77
158 26.3. Freeing of String Data with ldap_memfree()..................77
159 26.4. Changes to ldap_result()....................................77
160 26.5. Changes to ldap_first_attribute() and ldap_next_attribute...77
161 26.6. Changes to ldap_modrdn() and ldap_modrdn_s() Functions......78
162 26.7. Changes to the berval structure.............................78
163 26.8. API Specification Clarified.................................78
166 Expires: May 2001 [Page 3]
168 C LDAP API C LDAP Application Program Interface 17 November 2000
171 26.9. Deprecated Functions........................................78
172 27. Appendix E - Data Types and Legacy Implementations.............79
173 28. Appendix F - Changes Made Since Last Document Revision.........80
174 28.1. API Changes.................................................80
175 28.2. Editorial Changes and Clarifications........................81
178 4. Overview of the LDAP Model
180 LDAP is the lightweight directory access protocol, described in [2] and
181 [3]. It can provide a lightweight frontend to the X.500 directory [4],
182 or a stand-alone service. In either mode, LDAP is based on a client-
183 server model in which a client makes a TCP connection to an LDAP server,
184 over which it sends requests and receives responses.
186 The LDAP information model is based on the entry, which contains infor-
187 mation about some object (e.g., a person). Entries are composed of
188 attributes, which have a type and one or more values. Each attribute has
189 a syntax that determines what kinds of values are allowed in the attri-
190 bute (e.g., ASCII characters, a jpeg photograph, etc.) and how those
191 values behave during directory operations (e.g., is case significant
194 Entries may be organized in a tree structure, usually based on politi-
195 cal, geographical, and organizational boundaries. Each entry is uniquely
196 named relative to its sibling entries by its relative distinguished name
197 (RDN) consisting of one or more distinguished attribute values from the
198 entry. At most one value from each attribute may be used in the RDN.
199 For example, the entry for the person Babs Jensen might be named with
200 the "Barbara Jensen" value from the commonName attribute.
202 A globally unique name for an entry, called a distinguished name or DN,
203 is constructed by concatenating the sequence of RDNs from the entry up
204 to the root of the tree. For example, if Babs worked for the University
205 of Michigan, the DN of her U-M entry might be "cn=Barbara Jensen,
206 o=University of Michigan, c=US". The DN format used by LDAP is defined
209 Operations are provided to authenticate, search for and retrieve infor-
210 mation, modify information, and add and delete entries from the tree.
211 The next sections give an overview of how the API is used and detailed
212 descriptions of the LDAP API calls that implement all of these func-
216 5. Overview of LDAP API Use and General Requirements
218 An application generally uses the C LDAP API in four simple steps.
222 Expires: May 2001 [Page 4]
224 C LDAP API C LDAP Application Program Interface 17 November 2000
227 1. Initialize an LDAP session with a primary LDAP server. The
228 ldap_init() function returns a handle to the session, allowing
229 multiple connections to be open at once.
231 2. Authenticate to the LDAP server. The ldap_sasl_bind() function
232 and friends support a variety of authentication methods.
234 3. Perform some LDAP operations and obtain some results.
235 ldap_search() and friends return results which can be parsed by
236 ldap_parse_result(), ldap_first_entry(), ldap_next_entry(), etc.
238 4. Close the session. The ldap_unbind() function closes the connec-
241 Operations can be performed either synchronously or asynchronously. The
242 names of the synchronous functions end in _s. For example, a synchronous
243 search can be completed by calling ldap_search_s(). An asynchronous
244 search can be initiated by calling ldap_search(). All synchronous rou-
245 tines return an indication of the outcome of the operation (e.g, the
246 constant LDAP_SUCCESS or some other result code). The asynchronous rou-
247 tines make available to the caller the message id of the operation ini-
248 tiated. This id can be used in subsequent calls to ldap_result() to
249 obtain the result(s) of the operation. An asynchronous operation can be
250 abandoned by calling ldap_abandon() or ldap_abandon_ext(). Note that
251 there is no requirement that an LDAP API implementation not block when
252 handling asynchronous API functions; the term "asynchronous" as used in
253 this document refers to the fact that the sending of LDAP requests can
254 be separated from the receiving of LDAP responses.
256 Results and errors are returned in an opaque structure called LDAPMes-
257 sage. Routines are provided to parse this structure, step through
258 entries and attributes returned, etc. Routines are also provided to
259 interpret errors. Later sections of this document describe these rou-
260 tines in more detail.
262 LDAP version 3 servers can return referrals and references to other
263 servers. By default, implementations of this API will attempt to follow
264 referrals automatically for the application. This behavior can be dis-
265 abled globally (using the ldap_set_option() call) or on a per-request
266 basis through the use of a client control.
268 All DN and string attribute values passed into or produced by this C
269 LDAP API are represented using the character set of the underlying LDAP
270 protocol version in use. When this API is used with LDAPv3, DN and
271 string values are represented as UTF-8[6] characters. When this API is
272 used with LDAPv2, the US-ASCII[7] or T.61[7] character set are used.
273 Future documents MAY specify additional APIs supporting other character
278 Expires: May 2001 [Page 5]
280 C LDAP API C LDAP Application Program Interface 17 November 2000
283 For compatibility with existing applications, implementations of this
284 API will by default use version 2 of the LDAP protocol. Applications
285 that intend to take advantage of LDAP version 3 features will need to
286 use the ldap_set_option() call with a LDAP_OPT_PROTOCOL_VERSION to
289 Unless otherwise indicated, conformant implementations of this specifi-
290 cation MUST implement all of the C LDAP API functions as described in
291 this document, and they MUST use the function prototypes, macro defini-
292 tions, and types defined in this document.
294 Note that this API is designed for use in environments where the 'int'
295 type is at least 32 bits in size.
298 6. Header Requirements
300 To promote portability of applications, the following requirements are
301 imposed on the headers used by applications to access the services of
305 Applications only need to include a single header named ldap.h
306 to access all of the API services described in this document.
307 Therefore, the following C source program MUST compile and exe-
318 The ldap.h header MAY include other implementation-specific
321 Implementations SHOULD also provide a header named lber.h to facilitate
322 development of applications desiring compatibility with older LDAP
323 implementations. The lber.h header MAY be empty. Old applications that
324 include lber.h in order to use BER facilities will need to include
329 All headers SHOULD be idempotent; that is, if they are included
330 more than once the effect is as if they had only been included
334 Expires: May 2001 [Page 6]
336 C LDAP API C LDAP Application Program Interface 17 November 2000
341 Must Be Included Before API Is Used
342 An application MUST include the ldap.h header before referencing
343 any of the function or type definitions described in this API
347 Headers SHOULD be mutually independent with minimal dependence
348 on system or any other headers.
350 Use of the 'const' Keyword
351 This API specification is defined in terms of ISO C[8]. It
352 makes use of function prototypes and the 'const' keyword. The
353 use of 'const' in this specification is limited to simple, non-
354 array function parameters to avoid forcing applications to
355 declare parameters and variables that accept return values from
356 LDAP API functions as 'const.' Implementations specifically
357 designed to be used with non-ISO C translators SHOULD provide
358 function declarations without prototypes or function prototypes
359 without specification of 'const' arguments.
361 Definition of 'struct timeval'
362 This API specification uses the 'struct timeval' type. Imple-
363 mentations of this API MUST ensure that the struct timeval type
364 is by default defined as a consequence of including the ldap.h
365 header. Because struct timeval is usually defined in one or
366 more system headers, it is possible for header conflicts to
367 occur if ldap.h also defines it or arranges for it to be defined
368 by including another header. Therefore, applications MAY want
369 to arrange for struct timeval to be defined before they include
370 ldap.h. To support this, the ldap.h header MUST NOT itself
371 define struct timeval if the preprocessor symbol
372 LDAP_TYPE_TIMEVAL_DEFINED is defined before ldap.h is included.
375 7. Common Data Structures and Types
377 Data structures and types that are common to several LDAP API functions
380 typedef struct ldap LDAP;
382 typedef struct ldapmsg LDAPMessage;
384 typedef struct berelement BerElement;
386 typedef <impl_len_t> ber_len_t;
390 Expires: May 2001 [Page 7]
392 C LDAP API C LDAP Application Program Interface 17 November 2000
395 typedef struct berval {
402 <impl_usec_t> tv_usec;
405 The LDAP structure is an opaque data type that represents an LDAP ses-
406 sion Typically this corresponds to a connection to a single server, but
407 it MAY encompass several server connections in the face of LDAPv3 refer-
410 The LDAPMessage structure is an opaque data type that is used to return
411 entry, reference, result, and error information. An LDAPMessage struc-
412 ture can represent the beginning of a list, or chain of messages that
413 consists of a series of entries, references, and result messages as
414 returned by LDAP operations such as search. LDAP API functions such as
415 ldap_parse_result() that operate on message chains that can contain more
416 than one result message always operate on the first result message in
417 the chain. See the "Obtaining Results and Peeking Inside LDAP Messages"
418 section of this document for more information.
420 The BerElement structure is an opaque data type that is used to hold
421 data and state information about encoded data. It is described in more
422 detail in the section "Encoded ASN.1 Value Manipulation" later in this
425 The `ber_len_t' type is an unsigned integral data type that is large
426 enough to contain the length of the largest piece of data supported by
427 the API implementation. The `<impl_len_t>' in the `ber_len_t' typedef
428 MUST be replaced with an appropriate type. The width (number of signi-
429 ficant bits) of `ber_len_t' MUST be at least 32 and no larger than that
430 of `unsigned long'. See the appendix "Data Types and Legacy Implementa-
431 tions" for additional considerations.
433 The BerValue structure is used to represent arbitrary binary data and
434 its fields have the following meanings:
436 bv_len Length of data in bytes.
438 bv_val A pointer to the data itself.
441 The timeval structure is used to represent an interval of time and its
442 fields have the following meanings:
446 Expires: May 2001 [Page 8]
448 C LDAP API C LDAP Application Program Interface 17 November 2000
451 tv_sec Seconds component of time interval.
453 tv_usec Microseconds component of time interval.
455 Note that because the struct timeval definition typically is derived
456 from a system header, the types used for the tv_sec and tv_usec com-
457 ponents are implementation-specific integral types. Therefore,
458 `<impl_sec_t>' and `<impl_usec_t>' in the struct timeval definition MUST
459 be replaced with appropriate types. See the earlier section "Header
460 Requirements" for more information on struct timeval.
463 8. Memory Handling Overview
465 All memory that is allocated by a function in this C LDAP API and
466 returned to the caller SHOULD be disposed of by calling the appropriate
467 "free" function provided by this API. The correct "free" function to
468 call is documented in each section of this document where a function
469 that allocates memory is described.
471 Memory that is allocated through means outside of the C LDAP API MUST
472 NOT be disposed of using a function provided by this API.
474 If a pointer value passed to one of the C LDAP API "free" functions is
475 NULL, graceful failure (i.e, ignoring of the NULL pointer) MUST occur.
477 The complete list of "free" functions that are used to dispose of allo-
488 ldap_value_free_len()
491 9. Retrieving Information About the API Implementation
493 Applications developed to this specification need to be able to deter-
494 mine information about the particular API implementation they are using
495 both at compile time and during execution.
502 Expires: May 2001 [Page 9]
504 C LDAP API C LDAP Application Program Interface 17 November 2000
507 9.1. Retrieving Information at Compile Time
509 All conformant implementations MUST include the following five defini-
510 tions in a header so compile time tests can be done by LDAP software
513 #define LDAP_API_VERSION level
514 #define LDAP_VERSION_MIN min-version
515 #define LDAP_VERSION_MAX max-version
516 #define LDAP_VENDOR_NAME "vend-name"
517 #define LDAP_VENDOR_VERSION vend-version
521 "level" is replaced with the RFC number given to this C LDAP API
522 specification when it is published as a standards track RFC.
524 min-version is replaced with the lowest LDAP protocol version sup-
525 ported by the implementation.
527 max-version is replaced with the highest LDAP protocol version sup-
528 ported by the implementation. This SHOULD be 3.
530 "vend-name" is replaced with a text string that identifies the
531 party that supplies the API implementation.
533 "vend-version" is a supplier-specific version number multiplied
536 Note that the LDAP_VENDOR_NAME macro SHOULD be defined as "" if no ven-
537 dor name is available and the LDAP_VENDOR_VERSION macro SHOULD be
538 defined as 0 if no vendor-specific version information is available.
540 For example, if this specification is published as RFC 88888, Netscape
541 Communication's version 4.0 implementation that supports LDAPv2 and v3
542 might include macro definitions like these:
544 #define LDAP_API_VERSION 88888 /* RFC 88888 compliant */
545 #define LDAP_VERSION_MIN 2
546 #define LDAP_VERSION_MAX 3
547 #define LDAP_VENDOR_NAME "Netscape Communications Corp."
548 #define LDAP_VENDOR_VERSION 400 /* version 4.0 */
550 and application code can test the C LDAP API version level using a
551 construct such as this one:
553 #if (LDAP_API_VERSION >= 88888)
554 /* use features supported in RFC 88888 or later */
558 Expires: May 2001 [Page 10]
560 C LDAP API C LDAP Application Program Interface 17 November 2000
565 Until such time as this document is published as an RFC, implementations
566 SHOULD use the value 2000 plus the revision number of this draft for
567 LDAP_API_VERSION. For example, the correct value for LDAP_API_VERSION
568 for revision 05 of this draft is 2005.
570 Documents that extend this specification SHOULD define a macro of the
573 #define LDAP_API_FEATURE_x level
575 where "x" is replaced with a name (textual identifier) for the feature
576 and "level" is replaced with the number of the RFC that specifies the
577 API extension. The name SHOULD NOT begin with the string "X_".
579 For example, if C LDAP API extensions for Transport Layer Security [9]
580 were published in RFC 99999, that RFC might require conformant implemen-
581 tations to define a macro like this:
583 #define LDAP_API_FEATURE_TLS 99999
586 Private or experimental API extensions SHOULD be indicated by defining a
587 macro of this same form where "x" (the extension's name) begins with the
588 string "X_" and "level" is replaced with a integer number that is
589 specific to the extension.
591 It is RECOMMENDED that private or experimental API extensions use only
592 the following prefixes for macros, types, and function names:
597 and that these prefixes not be used by standard extensions.
600 9.2. Retrieving Information During Execution
602 The ldap_get_option() call (described in greater detail later in this
603 document) can be used during execution in conjunction with an option
604 parameter value of LDAP_OPT_API_INFO (0x00) to retrieve some basic
605 information about the API and about the specific implementation being
606 used. The ld parameter to ldap_get_option() can be either NULL or a
607 valid LDAP session handle which was obtained by calling ldap_init().
608 The optdata parameter to ldap_get_option() SHOULD be the address of an
609 LDAPAPIInfo structure which is defined as follows:
614 Expires: May 2001 [Page 11]
616 C LDAP API C LDAP Application Program Interface 17 November 2000
619 typedef struct ldapapiinfo {
620 int ldapai_info_version; /* version of this struct (1) */
621 int ldapai_api_version; /* revision of API supported */
622 int ldapai_protocol_version; /* highest LDAP version supported */
623 char **ldapai_extensions; /* names of API extensions */
624 char *ldapai_vendor_name; /* name of supplier */
625 int ldapai_vendor_version; /* supplier-specific version times 100 */
628 In addition, API implementations MUST include the following macro defin-
631 #define LDAP_API_INFO_VERSION 1
633 Note that the ldapai_info_version field of the LDAPAPIInfo structure
634 SHOULD be set to the value LDAP_API_INFO_VERSION (1) before calling
635 ldap_get_option() so that it can be checked for consistency. All other
636 fields are set by the ldap_get_option() function.
638 The members of the LDAPAPIInfo structure are:
641 A number that identifies the version of the LDAPAPIInfo struc-
642 ture. This SHOULD be set to the value LDAP_API_INFO_VERSION
643 (1) before calling ldap_get_option(). If the value received
644 is not recognized by the API implementation, the
645 ldap_get_option() function sets ldapai_info_version to a valid
646 value that would be recognized, sets the ldapai_api_version to
647 the correct value, and returns an error without filling in any
648 of the other fields in the LDAPAPIInfo structure.
651 A number that matches that assigned to the C LDAP API RFC sup-
652 ported by the API implementation. This SHOULD match the value
653 of the LDAP_API_VERSION macro defined earlier.
655 ldapai_protocol_version
656 The highest LDAP protocol version supported by the implementa-
657 tion. For example, if LDAPv3 is the highest version supported
658 then this field will be set to 3.
661 A zero-terminated string that contains the name of the party
662 that produced the LDAP API implementation. This field may be
663 set to NULL if no name is available. If non-NULL, the caller
664 is responsible for disposing of the memory occupied by passing
665 this pointer to ldap_memfree() which is described later in
666 this document. This value SHOULD match the value of the
670 Expires: May 2001 [Page 12]
672 C LDAP API C LDAP Application Program Interface 17 November 2000
675 LDAP_VENDOR_NAME macro described earlier in this document.
677 ldapai_vendor_version
678 An implementation-specific version number multiplied by 100.
679 For example, if the implementation version is 4.0 then this
680 field will be set to 400. If no version information is avail-
681 able, this field will be set to 0. This value SHOULD match
682 the value of the LDAP_VENDOR_VERSION macro described earlier
686 A NULL-terminated array of character strings that lists the
687 names of the API extensions supported by the LDAP API imple-
688 mentation. These names will typically match the textual iden-
689 tifiers that appear in the "x" portion of the
690 LDAP_API_FEATURE_x macros described above, although the pre-
691 cise value MUST be defined by documents that specify C LDAP
692 API extensions. If no API extensions are supported, this
693 field will be set to NULL. The caller is responsible for
694 disposing of the memory occupied by this array by passing it
695 to ldap_value_free() which is described later in this docu-
696 ment. To retrieve more information about a particular exten-
697 sion, the ldap_get_option() call can be used with an option
698 parameter value of LDAP_OPT_API_FEATURE_INFO (0x15). The opt-
699 data parameter to the ldap_get_option() SHOULD be the address
700 of an LDAPAPIFeatureInfo structure which is defined as fol-
703 typedef struct ldap_apifeature_info {
704 int ldapaif_info_version; /* version of this struct (1) */
705 char *ldapaif_name; /* name of supported feature */
706 int ldapaif_version; /* revision of supported feature */
707 } LDAPAPIFeatureInfo;
709 In addition, API implementations MUST include the following
712 #define LDAP_FEATURE_INFO_VERSION 1
714 Note that the ldapaif_info_version field of the LDAPAPI-
715 FeatureInfo structure SHOULD be set to the value
716 LDAP_FEATURE_INFO_VERSION (1) and the ldapaif_name field
717 SHOULD be set to the extension name string as described below
718 before ldap_get_option() is called. The call will fill in the
719 ldapaif_version field of the LDAPAPIFeatureInfo structure.
721 The members of the LDAPAPIFeatureInfo structure are:
726 Expires: May 2001 [Page 13]
728 C LDAP API C LDAP Application Program Interface 17 November 2000
732 A number that identifies the version of the LDAPAPI-
733 FeatureInfo structure. This SHOULD be set to the value
734 LDAP_FEATURE_INFO_VERSION (1) before calling
735 ldap_get_option(). If the value received is not recognized
736 by the API implementation, the ldap_get_option() function
737 sets ldapaif_info_version to a valid value that would be
738 recognized and returns an error without filling in the
739 ldapaif_version field in the LDAPAPIFeatureInfo structure.
742 The name of an extension, as returned in the
743 ldapai_extensions array of the LDAPAPIInfo structure and as
744 specified in the document that describes the extension.
747 This field will be set as a result of calling
748 ldap_get_option(). It is a number that matches that
749 assigned to the C LDAP API extension RFC supported for this
750 extension. For private or experimental API extensions, the
751 value is extension-specific. In either case, the value of
752 ldapaxi_ext_version SHOULD be identical to the value of the
753 LDAP_API_FEATURE_x macro defined for the extension
759 Many of the LDAP API routines return result codes, some of which indi-
760 cate local API errors and some of which are LDAP resultCodes that are
761 returned by servers. All of the result codes are non-negative integers.
762 Supported result codes are as follows (hexadecimal values are given in
763 parentheses after the constant):
766 LDAP_OPERATIONS_ERROR (0x01)
767 LDAP_PROTOCOL_ERROR (0x02)
768 LDAP_TIMELIMIT_EXCEEDED (0x03)
769 LDAP_SIZELIMIT_EXCEEDED (0x04)
770 LDAP_COMPARE_FALSE (0x05)
771 LDAP_COMPARE_TRUE (0x06)
772 LDAP_STRONG_AUTH_NOT_SUPPORTED (0x07)
773 LDAP_STRONG_AUTH_REQUIRED (0x08)
774 LDAP_REFERRAL (0x0a) -- new in LDAPv3
775 LDAP_ADMINLIMIT_EXCEEDED (0x0b) -- new in LDAPv3
776 LDAP_UNAVAILABLE_CRITICAL_EXTENSION (0x0c) -- new in LDAPv3
777 LDAP_CONFIDENTIALITY_REQUIRED (0x0d) -- new in LDAPv3
778 LDAP_SASL_BIND_IN_PROGRESS (0x0e) -- new in LDAPv3
782 Expires: May 2001 [Page 14]
784 C LDAP API C LDAP Application Program Interface 17 November 2000
787 LDAP_NO_SUCH_ATTRIBUTE (0x10)
788 LDAP_UNDEFINED_TYPE (0x11)
789 LDAP_INAPPROPRIATE_MATCHING (0x12)
790 LDAP_CONSTRAINT_VIOLATION (0x13)
791 LDAP_TYPE_OR_VALUE_EXISTS (0x14)
792 LDAP_INVALID_SYNTAX (0x15)
793 LDAP_NO_SUCH_OBJECT (0x20)
794 LDAP_ALIAS_PROBLEM (0x21)
795 LDAP_INVALID_DN_SYNTAX (0x22)
796 LDAP_IS_LEAF (0x23) -- not used in LDAPv3
797 LDAP_ALIAS_DEREF_PROBLEM (0x24)
798 LDAP_INAPPROPRIATE_AUTH (0x30)
799 LDAP_INVALID_CREDENTIALS (0x31)
800 LDAP_INSUFFICIENT_ACCESS (0x32)
802 LDAP_UNAVAILABLE (0x34)
803 LDAP_UNWILLING_TO_PERFORM (0x35)
804 LDAP_LOOP_DETECT (0x36)
805 LDAP_NAMING_VIOLATION (0x40)
806 LDAP_OBJECT_CLASS_VIOLATION (0x41)
807 LDAP_NOT_ALLOWED_ON_NONLEAF (0x42)
808 LDAP_NOT_ALLOWED_ON_RDN (0x43)
809 LDAP_ALREADY_EXISTS (0x44)
810 LDAP_NO_OBJECT_CLASS_MODS (0x45)
811 LDAP_RESULTS_TOO_LARGE (0x46) -- reserved for CLDAP
812 LDAP_AFFECTS_MULTIPLE_DSAS (0x47) -- new in LDAPv3
814 LDAP_SERVER_DOWN (0x51)
815 LDAP_LOCAL_ERROR (0x52)
816 LDAP_ENCODING_ERROR (0x53)
817 LDAP_DECODING_ERROR (0x54)
819 LDAP_AUTH_UNKNOWN (0x56)
820 LDAP_FILTER_ERROR (0x57)
821 LDAP_USER_CANCELLED (0x58)
822 LDAP_PARAM_ERROR (0x59)
823 LDAP_NO_MEMORY (0x5a)
824 LDAP_CONNECT_ERROR (0x5b)
825 LDAP_NOT_SUPPORTED (0x5c)
826 LDAP_CONTROL_NOT_FOUND (0x5d)
827 LDAP_NO_RESULTS_RETURNED (0x5e)
828 LDAP_MORE_RESULTS_TO_RETURN (0x5f)
829 LDAP_CLIENT_LOOP (0x60)
830 LDAP_REFERRAL_LIMIT_EXCEEDED (0x61)
838 Expires: May 2001 [Page 15]
840 C LDAP API C LDAP Application Program Interface 17 November 2000
843 11. Performing LDAP Operations
845 This section describes each LDAP operation API call in detail. Most
846 functions take a "session handle," a pointer to an LDAP structure con-
847 taining per-connection information. Many routines return results in an
848 LDAPMessage structure. These structures and others are described as
852 11.1. Initializing an LDAP Session
854 ldap_init() initializes a session with an LDAP server. The server is not
855 actually contacted until an operation is performed that requires it,
856 allowing various options to be set after initialization.
859 const char *hostname,
863 Use of the following routine is deprecated:
866 const char *hostname,
870 Unlike ldap_init(), ldap_open() attempts to make a server connection
871 before returning to the caller. A more complete description can be
876 hostname Contains a space-separated list of hostnames or dotted strings
877 representing the IP address of hosts running an LDAP server to
878 connect to. Each hostname in the list MAY include a port number
879 which is separated from the host itself with a colon (:) char-
880 acter. The hosts will be tried in the order listed, stopping
881 with the first one to which a successful connection is made.
883 Note: A suitable representation for including a literal IPv6[10]
884 address in the hostname parameter is desired, but has not yet been
885 determined or implemented in practice.
887 portno Contains the TCP port number to connect to. The default LDAP
888 port of 389 can be obtained by supplying the value zero (0) or
889 the macro LDAP_PORT (389). If a host includes a port number
890 then this parameter is ignored.
894 Expires: May 2001 [Page 16]
896 C LDAP API C LDAP Application Program Interface 17 November 2000
899 ldap_init() and ldap_open() both return a "session handle," a pointer to
900 an opaque structure that MUST be passed to subsequent calls pertaining
901 to the session. These routines return NULL if the session cannot be ini-
902 tialized in which case the operating system error reporting mechanism
903 can be checked to see why the call failed.
905 Note that if you connect to an LDAPv2 server, one of the LDAP bind calls
906 described below SHOULD be completed before other operations can be per-
907 formed on the session. LDAPv3 does not require that a bind operation be
908 completed before other operations can be performed.
910 The calling program can set various attributes of the session by calling
911 the routines described in the next section.
914 11.2. LDAP Session Handle Options
916 The LDAP session handle returned by ldap_init() is a pointer to an
917 opaque data type representing an LDAP session. In RFC 1823 this data
918 type was a structure exposed to the caller, and various fields in the
919 structure could be set to control aspects of the session, such as size
920 and time limits on searches.
922 In the interest of insulating callers from inevitable changes to this
923 structure, these aspects of the session are now accessed through a pair
924 of accessor functions, described below.
926 ldap_get_option() is used to access the current value of various
927 session-wide parameters. ldap_set_option() is used to set the value of
928 these parameters. Note that some options are READ-ONLY and cannot be
929 set; it is an error to call ldap_set_option() and attempt to set a
932 Note that if automatic referral following is enabled (the default), any
933 connections created during the course of following referrals will
934 inherit the options associated with the session that sent the original
935 request that caused the referrals to be returned.
950 Expires: May 2001 [Page 17]
952 C LDAP API C LDAP Application Program Interface 17 November 2000
957 #define LDAP_OPT_ON (<impl_void_star_value>)
958 #define LDAP_OPT_OFF ((void *)0)
960 LDAP_OPT_ON MUST be defined as a non-null pointer to void; that is,
961 <impl_void_star_value> MUST be replaced with a non-null pointer to
962 void, e.g., one could use:
963 #define LDAP_OPT_ON ((void *)1)
964 if that value is safe to use on the architecture where the API is
969 ld The session handle. If this is NULL, a set of global defaults is
970 accessed. New LDAP session handles created with ldap_init() or
971 ldap_open() inherit their characteristics from these global
974 option The name of the option being accessed or set. This parameter
975 SHOULD be one of the following constants, which have the indi-
976 cated meanings. After the constant the actual hexadecimal value
977 of the constant is listed in parentheses.
980 LDAP_OPT_API_INFO (0x00)
981 Type for invalue parameter: not applicable (option is READ-ONLY)
983 Type for outvalue parameter: LDAPAPIInfo *
986 Used to retrieve some basic information about the LDAP API
987 implementation at execution time. See the section "Retriev-
988 ing Information About the API Implementation" above for more
989 information. This option is READ-ONLY and cannot be set.
991 LDAP_OPT_DEREF (0x02)
992 Type for invalue parameter: int *
994 Type for outvalue parameter: int *
997 Determines how aliases are handled during search. It SHOULD
998 have one of the following values: LDAP_DEREF_NEVER (0x00),
999 LDAP_DEREF_SEARCHING (0x01), LDAP_DEREF_FINDING (0x02), or
1000 LDAP_DEREF_ALWAYS (0x03). The LDAP_DEREF_SEARCHING value
1001 means aliases are dereferenced during the search but not when
1002 locating the base object of the search. The
1006 Expires: May 2001 [Page 18]
1008 C LDAP API C LDAP Application Program Interface 17 November 2000
1011 LDAP_DEREF_FINDING value means aliases are dereferenced when
1012 locating the base object but not during the search. The
1013 default value for this option is LDAP_DEREF_NEVER.
1015 LDAP_OPT_SIZELIMIT (0x03)
1016 Type for invalue parameter: int *
1018 Type for outvalue parameter: int *
1021 A limit on the number of entries to return from a search. A
1022 value of LDAP_NO_LIMIT (0) means no limit. The default value
1023 for this option is LDAP_NO_LIMIT.
1025 LDAP_OPT_TIMELIMIT (0x04)
1026 Type for invalue parameter: int *
1028 Type for outvalue parameter: int *
1031 A limit on the number of seconds to spend on a search. A
1032 value of LDAP_NO_LIMIT (0) means no limit. The default value
1033 for this option is LDAP_NO_LIMIT. This value is passed to
1034 the server in the search request only; it does not affect how
1035 long the C LDAP API implementation itself will wait locally
1036 for search results. Note that the timeout parameter passed
1037 to the ldap_search_ext_s() or ldap_result() functions can be
1038 used to specify a limit on how long the API implementation
1039 will wait for results.
1041 LDAP_OPT_REFERRALS (0x08)
1042 Type for invalue parameter: void * (LDAP_OPT_ON or LDAP_OPT_OFF)
1044 Type for outvalue parameter: int *
1047 Determines whether the LDAP library automatically follows
1048 referrals returned by LDAP servers or not. It MAY be set to
1049 one of the constants LDAP_OPT_ON or LDAP_OPT_OFF; any non-
1050 NULL pointer value passed to ldap_set_option() enables this
1051 option. When reading the current setting using
1052 ldap_get_option(), a zero value means OFF and any non-zero
1053 value means ON. By default, this option is ON.
1055 LDAP_OPT_RESTART (0x09)
1056 Type for invalue parameter: void * (LDAP_OPT_ON or LDAP_OPT_OFF)
1058 Type for outvalue parameter: int *
1062 Expires: May 2001 [Page 19]
1064 C LDAP API C LDAP Application Program Interface 17 November 2000
1068 Determines whether LDAP I/O operations are automatically res-
1069 tarted if they abort prematurely. It MAY be set to one of the
1070 constants LDAP_OPT_ON or LDAP_OPT_OFF; any non-NULL pointer
1071 value passed to ldap_set_option() enables this option. When
1072 reading the current setting using ldap_get_option(), a zero
1073 value means OFF and any non-zero value means ON. This option
1074 is useful if an LDAP I/O operation can be interrupted prema-
1075 turely, for example by a timer going off, or other interrupt.
1076 By default, this option is OFF.
1078 LDAP_OPT_PROTOCOL_VERSION (0x11)
1079 Type for invalue parameter: int *
1081 Type for outvalue parameter: int *
1084 This option indicates the version of the LDAP protocol used
1085 when communicating with the primary LDAP server. It SHOULD be
1086 one of the constants LDAP_VERSION2 (2) or LDAP_VERSION3 (3).
1087 If no version is set the default is LDAP_VERSION2 (2).
1089 LDAP_OPT_SERVER_CONTROLS (0x12)
1090 Type for invalue parameter: LDAPControl **
1092 Type for outvalue parameter: LDAPControl ***
1095 A default list of LDAP server controls to be sent with each
1096 request. See the Working With Controls section below.
1098 LDAP_OPT_CLIENT_CONTROLS (0x13)
1099 Type for invalue parameter: LDAPControl **
1101 Type for outvalue parameter: LDAPControl ***
1104 A default list of client controls that affect the LDAP ses-
1105 sion. See the Working With Controls section below.
1107 LDAP_OPT_API_FEATURE_INFO (0x15)
1108 Type for invalue parameter: not applicable (option is READ-ONLY)
1110 Type for outvalue parameter: LDAPAPIFeatureInfo *
1113 Used to retrieve version information about LDAP API extended
1114 features at execution time. See the section "Retrieving
1118 Expires: May 2001 [Page 20]
1120 C LDAP API C LDAP Application Program Interface 17 November 2000
1123 Information About the API Implementation" above for more
1124 information. This option is READ-ONLY and cannot be set.
1126 LDAP_OPT_HOST_NAME (0x30)
1127 Type for invalue parameter: char *
1129 Type for outvalue parameter: char **
1132 The host name (or list of hosts) for the primary LDAP server.
1133 See the definition of the hostname parameter to ldap_init()
1134 for the allowed syntax. Note that if the portno parameter
1135 passed to ldap_init() is a value other than 0 or 389
1136 (LDAP_PORT), this value SHOULD include a string like
1137 ":portno" after each hostname or IP address that did not have
1138 one in the original hostname parameter that was passed to
1139 ldap_init(). For example, if this hostname value was passed
1142 "ldap.example.com:389 ldap2.example.com"
1144 and the portno parameter passed to ldap_init() was 6389, then
1145 the value returned for the LDAP_OPT_HOST_NAME option SHOULD
1148 "ldap.example.com:389 ldap2.example.com:6389"
1151 LDAP_OPT_RESULT_CODE (0x31)
1152 Type for invalue parameter: int *
1154 Type for outvalue parameter: int *
1157 The most recent local (API generated) or server returned LDAP
1158 result code that occurred for this session.
1160 LDAP_OPT_ERROR_STRING (0x32)
1161 Type for invalue parameter: char *
1163 Type for outvalue parameter: char **
1166 The message returned with the most recent LDAP error that
1167 occurred for this session.
1169 LDAP_OPT_MATCHED_DN (0x33)
1170 Type for invalue parameter: char *
1174 Expires: May 2001 [Page 21]
1176 C LDAP API C LDAP Application Program Interface 17 November 2000
1179 Type for outvalue parameter: char **
1182 The matched DN value returned with the most recent LDAP error
1183 that occurred for this session.
1186 outvalue The address of a place to put the value of the option. The
1187 actual type of this parameter depends on the setting of the
1188 option parameter. For outvalues of type char ** and LDAPCon-
1189 trol **, a copy of the data that is associated with the LDAP
1190 session ld is returned; callers should dispose of the memory by
1191 calling ldap_memfree() or ldap_controls_free(), depending on
1192 the type of data returned.
1194 invalue A pointer to the value the option is to be given. The actual
1195 type of this parameter depends on the setting of the option
1196 parameter. The data associated with invalue is copied by the
1197 API implementation to allow callers of the API to dispose of or
1198 otherwise change their copy of the data after a successful call
1199 to ldap_set_option(). If a value passed for invalue is invalid
1200 or cannot be accepted by the implementation, ldap_set_option()
1201 should return -1 to indicate an error.
1203 Both ldap_get_option() and ldap_set_option() return 0 if successful and
1204 -1 if an error occurs. If -1 is returned by either function, a specific
1205 result code MAY be retrieved by calling ldap_get_option() with an option
1206 value of LDAP_OPT_RESULT_CODE. Note that there is no way to retrieve a
1207 more specific result code if a call to ldap_get_option() with an option
1208 value of LDAP_OPT_RESULT_CODE fails.
1210 When a call to ldap_get_option() succeeds, the API implementation MUST
1211 NOT change the state of the LDAP session handle or the state of the
1212 underlying implementation in a way that affects the behavior of future
1213 LDAP API calls. When a call to ldap_get_option() fails, the only ses-
1214 sion handle change permitted is setting the LDAP result code (as
1215 returned by the LDAP_OPT_RESULT_CODE option).
1217 When a call to ldap_set_option() fails, it MUST NOT change the state of
1218 the LDAP session handle or the state of the underlying implementation in
1219 a way that affects the behavior of future LDAP API calls.
1221 Standards track documents that extend this specification and specify new
1222 options SHOULD use values for option macros that are between 0x1000 and
1223 0x3FFF inclusive. Private and experimental extensions SHOULD use values
1224 for the option macros that are between 0x4000 and 0x7FFF inclusive. All
1225 values below 0x1000 and above 0x7FFF that are not defined in this docu-
1226 ment are reserved and SHOULD NOT be used. The following macro MUST be
1230 Expires: May 2001 [Page 22]
1232 C LDAP API C LDAP Application Program Interface 17 November 2000
1235 defined by C LDAP API implementations to aid extension implementors:
1236 #define LDAP_OPT_PRIVATE_EXTENSION_BASE 0x4000 /* to 0x7FFF inclusive */
1240 11.3. Working With Controls
1242 LDAPv3 operations can be extended through the use of controls. Controls
1243 can be sent to a server or returned to the client with any LDAP message.
1244 These controls are referred to as server controls.
1246 The LDAP API also supports a client-side extension mechanism through the
1247 use of client controls. These controls affect the behavior of the LDAP
1248 API only and are never sent to a server. A common data structure is
1249 used to represent both types of controls:
1251 typedef struct ldapcontrol {
1253 struct berval ldctl_value;
1254 char ldctl_iscritical;
1257 The fields in the ldapcontrol structure have the following meanings:
1259 ldctl_oid The control type, represented as a string.
1261 ldctl_value The data associated with the control (if any). To
1262 specify a zero-length value, set ldctl_value.bv_len to
1263 zero and ldctl_value.bv_val to a zero-length string.
1264 To indicate that no data is associated with the con-
1265 trol, set ldctl_value.bv_val to NULL.
1267 ldctl_iscritical Indicates whether the control is critical of not. If
1268 this field is non-zero, the operation will only be car-
1269 ried out if the control is recognized by the server
1270 and/or client. Note that the LDAP unbind and abandon
1271 operations have no server response, so clients SHOULD
1272 NOT mark server controls critical when used with these
1275 Some LDAP API calls allocate an ldapcontrol structure or a NULL-
1276 terminated array of ldapcontrol structures. The following routines can
1277 be used to dispose of a single control or an array of controls:
1279 void ldap_control_free( LDAPControl *ctrl );
1280 void ldap_controls_free( LDAPControl **ctrls );
1281 If the ctrl or ctrls parameter is NULL, these calls do nothing.
1286 Expires: May 2001 [Page 23]
1288 C LDAP API C LDAP Application Program Interface 17 November 2000
1291 A set of controls that affect the entire session can be set using the
1292 ldap_set_option() function (see above). A list of controls can also be
1293 passed directly to some LDAP API calls such as ldap_search_ext(), in
1294 which case any controls set for the session through the use of
1295 ldap_set_option() are ignored. Control lists are represented as a NULL-
1296 terminated array of pointers to ldapcontrol structures.
1298 Server controls are defined by LDAPv3 protocol extension documents; for
1299 example, a control has been proposed to support server-side sorting of
1300 search results [11].
1302 One client control is defined in this document (described in the follow-
1303 ing section). Other client controls MAY be defined in future revisions
1304 of this document or in documents that extend this API.
1307 11.3.1. A Client Control That Governs Referral Processing
1309 As described previously in the section "LDAP Session Handle Options,"
1310 applications can enable and disable automatic chasing of referrals on a
1311 session-wide basic by using the ldap_set_option() function with the
1312 LDAP_OPT_REFERRALS option. It is also useful to govern automatic refer-
1313 ral chasing on per-request basis. A client control with an OID of
1314 1.2.840.113556.1.4.616 exists to provide this functionality.
1316 /* OID for referrals client control */
1317 #define LDAP_CONTROL_REFERRALS "1.2.840.113556.1.4.616"
1319 /* Flags for referrals client control value */
1320 #define LDAP_CHASE_SUBORDINATE_REFERRALS 0x00000020U
1321 #define LDAP_CHASE_EXTERNAL_REFERRALS 0x00000040U
1323 To create a referrals client control, the ldctl_oid field of an LDAPCon-
1324 trol structure MUST be set to LDAP_CONTROL_REFERRALS
1325 ("1.2.840.113556.1.4.616") and the ldctl_value field MUST be set to a
1326 value that contains a set of flags. The ldctl_value.bv_len field MUST
1327 be set to sizeof(ber_uint_t), and the ldctl_value.bv_val field MUST
1328 point to a ber_uint_t which contains the flags value." The ber_uint_t
1329 type is define in the section "BER Data Structures and Types" below.
1331 The flags value can be set to zero to disable automatic chasing of
1332 referrals and LDAPv3 references altogether. Alternatively, the flags
1333 value can be set to the value LDAP_CHASE_SUBORDINATE_REFERRALS
1334 (0x00000020U) to indicate that only LDAPv3 search continuation refer-
1335 ences are to be automatically chased by the API implementation, to the
1336 value LDAP_CHASE_EXTERNAL_REFERRALS (0x00000040U) to indicate that only
1337 LDAPv3 referrals are to be automatically chased, or the logical OR of
1338 the two flag values (0x00000060U) to indicate that both referrals and
1342 Expires: May 2001 [Page 24]
1344 C LDAP API C LDAP Application Program Interface 17 November 2000
1347 references are to be automatically chased.
1350 11.4. Authenticating to the directory
1352 The following functions are used to authenticate an LDAP client to an
1353 LDAP directory server.
1355 The ldap_sasl_bind() and ldap_sasl_bind_s() functions can be used to do
1356 general and extensible authentication over LDAP through the use of the
1357 Simple Authentication Security Layer [12]. The routines both take the
1358 dn to bind as, the method to use, as a dotted-string representation of
1359 an OID identifying the method, and a struct berval holding the creden-
1360 tials. The special constant value LDAP_SASL_SIMPLE (NULL) can be passed
1361 to request simple authentication, or the simplified routines
1362 ldap_simple_bind() or ldap_simple_bind_s() can be used.
1367 const char *mechanism,
1368 const struct berval *cred,
1369 LDAPControl **serverctrls,
1370 LDAPControl **clientctrls,
1374 int ldap_sasl_bind_s(
1377 const char *mechanism,
1378 const struct berval *cred,
1379 LDAPControl **serverctrls,
1380 LDAPControl **clientctrls,
1381 struct berval **servercredp
1384 int ldap_simple_bind(
1390 int ldap_simple_bind_s(
1398 Expires: May 2001 [Page 25]
1400 C LDAP API C LDAP Application Program Interface 17 November 2000
1403 The use of the following routines is deprecated and more complete
1404 descriptions can be found in RFC 1823:
1406 int ldap_bind( LDAP *ld, const char *dn, const char *cred,
1409 int ldap_bind_s( LDAP *ld, const char *dn, const char *cred,
1412 int ldap_kerberos_bind( LDAP *ld, const char *dn );
1414 int ldap_kerberos_bind_s( LDAP *ld, const char *dn );
1418 ld The session handle.
1420 dn The name of the entry to bind as. If NULL, a zero length
1421 DN is sent to the server.
1423 mechanism Either LDAP_SASL_SIMPLE (NULL) to get simple authentica-
1424 tion, or a text string identifying the SASL method.
1426 cred The credentials with which to authenticate. Arbitrary
1427 credentials can be passed using this parameter. The format
1428 and content of the credentials depends on the setting of
1429 the mechanism parameter. If the cred parameter is NULL and
1430 the mechanism is LDAP_SASL_SIMPLE, a zero-length octet
1431 string is sent to the server in the simple credentials
1432 field of the bind request. If the cred parameter is NULL
1433 and the mechanism is anything else, no credentials are sent
1434 to the server in the bind request.
1436 passwd For ldap_simple_bind(), the password that is sent to the
1437 server in the simple credentials field of the bind request.
1438 If NULL, a zero length password is sent to the server.
1440 serverctrls List of LDAP server controls, or NULL if no server controls
1443 clientctrls List of client controls, or NULL if no client controls are
1446 msgidp This result parameter will be set to the message id of the
1447 request if the ldap_sasl_bind() call succeeds. The value
1448 is undefined if a value other than LDAP_SUCCESS is
1454 Expires: May 2001 [Page 26]
1456 C LDAP API C LDAP Application Program Interface 17 November 2000
1459 servercredp This result parameter will be filled in with the creden-
1460 tials passed back by the server for mutual authentication,
1461 if given. An allocated berval structure is returned that
1462 SHOULD be disposed of by calling ber_bvfree(). NULL SHOULD
1463 be passed to ignore this field. If an API error occurs or
1464 the server did not return any credentials, *servercredp is
1467 Additional parameters for the deprecated routines are not described.
1468 Interested readers are referred to RFC 1823.
1470 The ldap_sasl_bind() function initiates an asynchronous bind operation
1471 and returns the constant LDAP_SUCCESS if the request was successfully
1472 sent, or another LDAP result code if not. See the section below on
1473 error handling for more information about possible errors and how to
1474 interpret them. If successful, ldap_sasl_bind() places the message id
1475 of the request in *msgidp. A subsequent call to ldap_result(), described
1476 below, can be used to obtain the result of the bind.
1478 The ldap_simple_bind() function initiates a simple asynchronous bind
1479 operation and returns the message id of the operation initiated. A sub-
1480 sequent call to ldap_result(), described below, can be used to obtain
1481 the result of the bind. In case of error, ldap_simple_bind() will return
1482 -1, setting the session error parameters in the LDAP structure appropri-
1485 The synchronous ldap_sasl_bind_s() and ldap_simple_bind_s() functions
1486 both return the result of the operation, either the constant
1487 LDAP_SUCCESS if the operation was successful, or another LDAP result
1488 code if it was not. See the section below on error handling for more
1489 information about possible errors and how to interpret them.
1491 Note that if an LDAPv2 server is contacted, no other operations over the
1492 connection can be attempted before a bind call has successfully com-
1495 Subsequent bind calls can be used to re-authenticate over the same con-
1496 nection, and multistep SASL sequences can be accomplished through a
1497 sequence of calls to ldap_sasl_bind() or ldap_sasl_bind_s().
1500 11.5. Closing the session
1502 The following functions are used to unbind from the directory, close
1503 open connections, and dispose of the session handle.
1505 int ldap_unbind_ext( LDAP *ld, LDAPControl **serverctrls,
1506 LDAPControl **clientctrls );
1510 Expires: May 2001 [Page 27]
1512 C LDAP API C LDAP Application Program Interface 17 November 2000
1515 int ldap_unbind( LDAP *ld );
1517 int ldap_unbind_s( LDAP *ld );
1521 ld The session handle.
1523 serverctrls List of LDAP server controls, or NULL if no server controls
1526 clientctrls List of client controls, or NULL if no client controls are
1529 The ldap_unbind_ext(), ldap_unbind() and ldap_unbind_s() all work syn-
1530 chronously in the sense that they send an unbind request to the server,
1531 close all open connections associated with the LDAP session handle, and
1532 dispose of all resources associated with the session handle before
1533 returning. Note, however, that there is no server response to an LDAP
1534 unbind operation. All three of the unbind functions return LDAP_SUCCESS
1535 (or another LDAP result code if the request cannot be sent to the LDAP
1536 server). After a call to one of the unbind functions, the session han-
1537 dle ld is invalid and it is illegal to make any further LDAP API calls
1540 The ldap_unbind() and ldap_unbind_s() functions behave identically. The
1541 ldap_unbind_ext() function allows server and client controls to be
1542 included explicitly, but note that since there is no server response to
1543 an unbind request there is no way to receive a response to a server con-
1544 trol sent with an unbind request.
1550 The following functions are used to search the LDAP directory, returning
1551 a requested set of attributes for each entry matched. There are five
1554 int ldap_search_ext(
1561 LDAPControl **serverctrls,
1562 LDAPControl **clientctrls,
1566 Expires: May 2001 [Page 28]
1568 C LDAP API C LDAP Application Program Interface 17 November 2000
1571 struct timeval *timeout,
1576 int ldap_search_ext_s(
1583 LDAPControl **serverctrls,
1584 LDAPControl **clientctrls,
1585 struct timeval *timeout,
1616 struct timeval *timeout,
1622 Expires: May 2001 [Page 29]
1624 C LDAP API C LDAP Application Program Interface 17 November 2000
1629 ld The session handle.
1631 base The dn of the entry at which to start the search. If NULL,
1632 a zero length DN is sent to the server.
1634 scope One of LDAP_SCOPE_BASE (0x00), LDAP_SCOPE_ONELEVEL (0x01),
1635 or LDAP_SCOPE_SUBTREE (0x02), indicating the scope of the
1638 filter A character string as described in [13], representing the
1639 search filter. The value NULL can be passed to indicate
1640 that the filter "(objectclass=*)" which matches all entries
1641 is to be used. Note that if the caller of the API is using
1642 LDAPv2, only a subset of the filter functionality described
1643 in [13] can be successfully used.
1645 attrs A NULL-terminated array of strings indicating which attri-
1646 butes to return for each matching entry. Passing NULL for
1647 this parameter causes all available user attributes to be
1648 retrieved. The special constant string LDAP_NO_ATTRS
1649 ("1.1") MAY be used as the only string in the array to
1650 indicate that no attribute types are to be returned by the
1651 server. The special constant string LDAP_ALL_USER_ATTRS
1652 ("*") can be used in the attrs array along with the names
1653 of some operational attributes to indicate that all user
1654 attributes plus the listed operational attributes are to be
1657 attrsonly A boolean value that MUST be zero if both attribute types
1658 and values are to be returned, and non-zero if only types
1661 timeout For the ldap_search_st() function, this specifies the local
1662 search timeout value (if it is NULL, the timeout is infin-
1663 ite). If a zero timeout (where tv_sec and tv_usec are both
1664 zero) is passed, API implementations SHOULD return
1667 For the ldap_search_ext() and ldap_search_ext_s() func-
1668 tions, the timeout parameter specifies both the local
1669 search timeout value and the operation time limit that is
1670 sent to the server within the search request. Passing a
1671 NULL value for timeout causes the default timeout stored in
1672 the LDAP session handle (set by using ldap_set_option()
1673 with the LDAP_OPT_TIMELIMIT parameter) to be sent to the
1674 server with the request but an infinite local search
1678 Expires: May 2001 [Page 30]
1680 C LDAP API C LDAP Application Program Interface 17 November 2000
1683 timeout to be used. If a zero timeout (where tv_sec and
1684 tv_usec are both zero) is passed in, API implementations
1685 SHOULD return LDAP_PARAM_ERROR. If a zero value for tv_sec
1686 is used but tv_usec is non-zero, an operation time limit of
1687 1 SHOULD be passed to the LDAP server as the operation time
1688 limit. For other values of tv_sec, the tv_sec value itself
1689 SHOULD be passed to the LDAP server.
1691 sizelimit For the ldap_search_ext() and ldap_search_ext_s() calls,
1692 this is a limit on the number of entries to return from the
1693 search. A value of LDAP_NO_LIMIT (0) means no limit. A
1694 value of LDAP_DEFAULT_SIZELIMIT (-1) means use the default
1695 timeout from the LDAP session handle (which is set by cal-
1696 ling ldap_set_option() with the LDAP_OPT_SIZELIMIT parame-
1699 res For the synchronous calls, this is a result parameter which
1700 will contain the results of the search upon completion of
1701 the call. If an API error occurs or no results are
1702 returned, *res is set to NULL.
1704 serverctrls List of LDAP server controls, or NULL if no server controls
1707 clientctrls List of client controls, or NULL if no client controls are
1710 msgidp This result parameter will be set to the message id of the
1711 request if the ldap_search_ext() call succeeds. The value
1712 is undefined if a value other than LDAP_SUCCESS is
1715 There are three options in the session handle ld which potentially
1716 affect how the search is performed. They are:
1722 These options are fully described in the earlier section "LDAP Session
1725 The ldap_search_ext() function initiates an asynchronous search opera-
1726 tion and returns the constant LDAP_SUCCESS if the request was success-
1727 fully sent, or another LDAP result code if not. See the section below
1728 on error handling for more information about possible errors and how to
1729 interpret them. If successful, ldap_search_ext() places the message id
1730 of the request in *msgidp. A subsequent call to ldap_result(), described
1734 Expires: May 2001 [Page 31]
1736 C LDAP API C LDAP Application Program Interface 17 November 2000
1739 below, can be used to obtain the results from the search. These results
1740 can be parsed using the result parsing routines described in detail
1743 Similar to ldap_search_ext(), the ldap_search() function initiates an
1744 asynchronous search operation and returns the message id of the opera-
1745 tion initiated. As for ldap_search_ext(), a subsequent call to
1746 ldap_result(), described below, can be used to obtain the result of the
1747 bind. In case of error, ldap_search() will return -1, setting the ses-
1748 sion error parameters in the LDAP structure appropriately.
1750 The synchronous ldap_search_ext_s(), ldap_search_s(), and
1751 ldap_search_st() functions all return the result of the operation,
1752 either the constant LDAP_SUCCESS if the operation was successful, or
1753 another LDAP result code if it was not. See the section below on error
1754 handling for more information about possible errors and how to interpret
1755 them. Entries returned from the search (if any) are contained in the
1756 res parameter. This parameter is opaque to the caller. Entries, attri-
1757 butes, values, etc., can be extracted by calling the parsing routines
1758 described below. The results contained in res SHOULD be freed when no
1759 longer in use by calling ldap_msgfree(), described later.
1761 The ldap_search_ext() and ldap_search_ext_s() functions support LDAPv3
1762 server controls, client controls, and allow varying size and time limits
1763 to be easily specified for each search operation. The ldap_search_st()
1764 function is identical to ldap_search_s() except that it takes an addi-
1765 tional parameter specifying a local timeout for the search. The local
1766 search timeout is used to limit the amount of time the API implementa-
1767 tion will wait for a search to complete. After the local search timeout
1768 expires, the API implementation will send an abandon operation to abort
1769 the search operation.
1771 11.7. Reading an Entry
1773 LDAP does not support a read operation directly. Instead, this operation
1774 is emulated by a search with base set to the DN of the entry to read,
1775 scope set to LDAP_SCOPE_BASE, and filter set to "(objectclass=*)" or
1776 NULL. attrs contains the list of attributes to return.
1779 11.8. Listing the Children of an Entry
1781 LDAP does not support a list operation directly. Instead, this operation
1782 is emulated by a search with base set to the DN of the entry to list,
1783 scope set to LDAP_SCOPE_ONELEVEL, and filter set to "(objectclass=*)" or
1784 NULL. attrs contains the list of attributes to return for each child
1790 Expires: May 2001 [Page 32]
1792 C LDAP API C LDAP Application Program Interface 17 November 2000
1795 11.9. Comparing a Value Against an Entry
1797 The following routines are used to compare a given attribute value
1798 assertion against an LDAP entry. There are four variations:
1800 int ldap_compare_ext(
1804 const struct berval *bvalue,
1805 LDAPControl **serverctrls,
1806 LDAPControl **clientctrls,
1810 int ldap_compare_ext_s(
1814 const struct berval *bvalue,
1815 LDAPControl **serverctrls,
1816 LDAPControl **clientctrls
1835 ld The session handle.
1837 dn The name of the entry to compare against. If NULL, a zero
1838 length DN is sent to the server.
1840 attr The attribute to compare against.
1842 bvalue The attribute value to compare against those found in the
1846 Expires: May 2001 [Page 33]
1848 C LDAP API C LDAP Application Program Interface 17 November 2000
1851 given entry. This parameter is used in the extended rou-
1852 tines and is a pointer to a struct berval so it is possible
1853 to compare binary values.
1855 value A string attribute value to compare against, used by the
1856 ldap_compare() and ldap_compare_s() functions. Use
1857 ldap_compare_ext() or ldap_compare_ext_s() if you need to
1858 compare binary values.
1860 serverctrls List of LDAP server controls, or NULL if no server controls
1863 clientctrls List of client controls, or NULL if no client controls are
1866 msgidp This result parameter will be set to the message id of the
1867 request if the ldap_compare_ext() call succeeds. The value
1868 is undefined if a value other than LDAP_SUCCESS is
1871 The ldap_compare_ext() function initiates an asynchronous compare opera-
1872 tion and returns the constant LDAP_SUCCESS if the request was success-
1873 fully sent, or another LDAP result code if not. See the section below
1874 on error handling for more information about possible errors and how to
1875 interpret them. If successful, ldap_compare_ext() places the message id
1876 of the request in *msgidp. A subsequent call to ldap_result(), described
1877 below, can be used to obtain the result of the compare.
1879 Similar to ldap_compare_ext(), the ldap_compare() function initiates an
1880 asynchronous compare operation and returns the message id of the opera-
1881 tion initiated. As for ldap_compare_ext(), a subsequent call to
1882 ldap_result(), described below, can be used to obtain the result of the
1883 bind. In case of error, ldap_compare() will return -1, setting the ses-
1884 sion error parameters in the LDAP structure appropriately.
1886 The synchronous ldap_compare_ext_s() and ldap_compare_s() functions both
1887 return the result of the operation: one of the constants
1888 LDAP_COMPARE_TRUE or LDAP_COMPARE_FALSE if the operation was successful,
1889 or another LDAP result code if it was not. See the section below on
1890 error handling for more information about possible errors and how to
1893 The ldap_compare_ext() and ldap_compare_ext_s() functions support LDAPv3
1894 server controls and client controls.
1902 Expires: May 2001 [Page 34]
1904 C LDAP API C LDAP Application Program Interface 17 November 2000
1907 11.10. Modifying an entry
1909 The following routines are used to modify an existing LDAP entry. There
1910 are four variations:
1912 typedef union mod_vals_u {
1913 char **modv_strvals;
1914 struct berval **modv_bvals;
1917 typedef struct ldapmod {
1920 mod_vals_u_t mod_vals;
1922 #define mod_values mod_vals.modv_strvals
1923 #define mod_bvalues mod_vals.modv_bvals
1925 int ldap_modify_ext(
1929 LDAPControl **serverctrls,
1930 LDAPControl **clientctrls,
1934 int ldap_modify_ext_s(
1938 LDAPControl **serverctrls,
1939 LDAPControl **clientctrls
1958 Expires: May 2001 [Page 35]
1960 C LDAP API C LDAP Application Program Interface 17 November 2000
1963 ld The session handle.
1965 dn The name of the entry to modify. If NULL, a zero length DN
1966 is sent to the server.
1968 mods A NULL-terminated array of modifications to make to the
1971 serverctrls List of LDAP server controls, or NULL if no server controls
1974 clientctrls List of client controls, or NULL if no client controls are
1977 msgidp This result parameter will be set to the message id of the
1978 request if the ldap_modify_ext() call succeeds. The value
1979 is undefined if a value other than LDAP_SUCCESS is
1982 The fields in the LDAPMod structure have the following meanings:
1984 mod_op The modification operation to perform. It MUST be one of
1985 LDAP_MOD_ADD (0x00), LDAP_MOD_DELETE (0x01), or
1986 LDAP_MOD_REPLACE (0x02). This field also indicates the
1987 type of values included in the mod_vals union. It is logi-
1988 cally ORed with LDAP_MOD_BVALUES (0x80) to select the
1989 mod_bvalues form. Otherwise, the mod_values form is used.
1991 mod_type The type of the attribute to modify.
1993 mod_vals The values (if any) to add, delete, or replace. Only one of
1994 the mod_values or mod_bvalues variants can be used,
1995 selected by ORing the mod_op field with the constant
1996 LDAP_MOD_BVALUES. mod_values is a NULL-terminated array of
1997 zero-terminated strings and mod_bvalues is a NULL-
1998 terminated array of berval structures that can be used to
1999 pass binary values such as images.
2001 For LDAP_MOD_ADD modifications, the given values are added to the
2002 entry, creating the attribute if necessary.
2004 For LDAP_MOD_DELETE modifications, the given values are deleted from the
2005 entry, removing the attribute if no values remain. If the entire attri-
2006 bute is to be deleted, the mod_vals field can be set to NULL.
2008 For LDAP_MOD_REPLACE modifications, the attribute will have the listed
2009 values after the modification, having been created if necessary, or
2010 removed if the mod_vals field is NULL. All modifications are performed
2014 Expires: May 2001 [Page 36]
2016 C LDAP API C LDAP Application Program Interface 17 November 2000
2019 in the order in which they are listed.
2021 The ldap_modify_ext() function initiates an asynchronous modify opera-
2022 tion and returns the constant LDAP_SUCCESS if the request was success-
2023 fully sent, or another LDAP result code if not. See the section below
2024 on error handling for more information about possible errors and how to
2025 interpret them. If successful, ldap_modify_ext() places the message id
2026 of the request in *msgidp. A subsequent call to ldap_result(), described
2027 below, can be used to obtain the result of the modify.
2029 Similar to ldap_modify_ext(), the ldap_modify() function initiates an
2030 asynchronous modify operation and returns the message id of the opera-
2031 tion initiated. As for ldap_modify_ext(), a subsequent call to
2032 ldap_result(), described below, can be used to obtain the result of the
2033 modify. In case of error, ldap_modify() will return -1, setting the ses-
2034 sion error parameters in the LDAP structure appropriately.
2036 The synchronous ldap_modify_ext_s() and ldap_modify_s() functions both
2037 return the result of the operation, either the constant LDAP_SUCCESS if
2038 the operation was successful, or another LDAP result code if it was not.
2039 See the section below on error handling for more information about pos-
2040 sible errors and how to interpret them.
2042 The ldap_modify_ext() and ldap_modify_ext_s() functions support LDAPv3
2043 server controls and client controls.
2046 11.11. Modifying the Name of an Entry
2048 In LDAPv2, the ldap_modrdn(), ldap_modrdn_s(), ldap_modrdn2(), and
2049 ldap_modrdn2_s() routines were used to change the name of an LDAP entry.
2050 They could only be used to change the least significant component of a
2051 name (the RDN or relative distinguished name). LDAPv3 provides the
2052 Modify DN protocol operation that allows more general name change
2053 access. The ldap_rename() and ldap_rename_s() routines are used to
2054 change the name of an entry, and the use of the ldap_modrdn(),
2055 ldap_modrdn_s(), ldap_modrdn2(), and ldap_modrdn2_s() routines is depre-
2062 const char *newparent,
2064 LDAPControl **serverctrls,
2065 LDAPControl **clientctrls,
2070 Expires: May 2001 [Page 37]
2072 C LDAP API C LDAP Application Program Interface 17 November 2000
2080 const char *newparent,
2082 LDAPControl **serverctrls,
2083 LDAPControl **clientctrls
2086 The use of the following routines is deprecated and more complete
2087 descriptions can be found in RFC 1823:
2114 ld The session handle.
2116 dn The name of the entry whose DN is to be changed. If NULL,
2117 a zero length DN is sent to the server.
2119 newrdn The new RDN to give the entry.
2121 newparent The new parent, or superior entry. If this parameter is
2122 NULL, only the RDN of the entry is changed. The root DN
2126 Expires: May 2001 [Page 38]
2128 C LDAP API C LDAP Application Program Interface 17 November 2000
2131 SHOULD be specified by passing a zero length string, "".
2132 The newparent parameter SHOULD always be NULL when using
2133 version 2 of the LDAP protocol; otherwise the server's
2134 behavior is undefined.
2136 deleteoldrdn This parameter only has meaning on the rename routines if
2137 newrdn is different than the old RDN. It is a boolean
2138 value, if non-zero indicating that the old RDN value(s) is
2139 to be removed, if zero indicating that the old RDN value(s)
2140 is to be retained as non-distinguished values of the entry.
2142 serverctrls List of LDAP server controls, or NULL if no server controls
2145 clientctrls List of client controls, or NULL if no client controls are
2148 msgidp This result parameter will be set to the message id of the
2149 request if the ldap_rename() call succeeds. The value is
2150 undefined if a value other than LDAP_SUCCESS is returned.
2152 The ldap_rename() function initiates an asynchronous modify DN operation
2153 and returns the constant LDAP_SUCCESS if the request was successfully
2154 sent, or another LDAP result code if not. See the section below on
2155 error handling for more information about possible errors and how to
2156 interpret them. If successful, ldap_rename() places the DN message id
2157 of the request in *msgidp. A subsequent call to ldap_result(), described
2158 below, can be used to obtain the result of the rename.
2160 The synchronous ldap_rename_s() returns the result of the operation,
2161 either the constant LDAP_SUCCESS if the operation was successful, or
2162 another LDAP result code if it was not. See the section below on error
2163 handling for more information about possible errors and how to interpret
2166 The ldap_rename() and ldap_rename_s() functions both support LDAPv3
2167 server controls and client controls.
2170 11.12. Adding an entry
2172 The following functions are used to add entries to the LDAP directory.
2173 There are four variations:
2182 Expires: May 2001 [Page 39]
2184 C LDAP API C LDAP Application Program Interface 17 November 2000
2187 LDAPControl **serverctrls,
2188 LDAPControl **clientctrls,
2196 LDAPControl **serverctrls,
2197 LDAPControl **clientctrls
2214 ld The session handle.
2216 dn The name of the entry to add. If NULL, a zero length DN is
2219 attrs The entry's attributes, specified using the LDAPMod struc-
2220 ture defined for ldap_modify(). The mod_type and mod_vals
2221 fields MUST be filled in. The mod_op field is ignored
2222 unless ORed with the constant LDAP_MOD_BVALUES, used to
2223 select the mod_bvalues case of the mod_vals union.
2225 serverctrls List of LDAP server controls, or NULL if no server controls
2228 clientctrls List of client controls, or NULL if no client controls are
2231 msgidp This result parameter will be set to the message id of the
2232 request if the ldap_add_ext() call succeeds. The value is
2233 undefined if a value other than LDAP_SUCCESS is returned.
2238 Expires: May 2001 [Page 40]
2240 C LDAP API C LDAP Application Program Interface 17 November 2000
2243 Note that the parent of the entry being added must already exist or the
2244 parent must be empty (i.e., equal to the root DN) for an add to succeed.
2246 The ldap_add_ext() function initiates an asynchronous add operation and
2247 returns the constant LDAP_SUCCESS if the request was successfully sent,
2248 or another LDAP result code if not. See the section below on error han-
2249 dling for more information about possible errors and how to interpret
2250 them. If successful, ldap_add_ext() places the message id of the
2251 request in *msgidp. A subsequent call to ldap_result(), described below,
2252 can be used to obtain the result of the add.
2254 Similar to ldap_add_ext(), the ldap_add() function initiates an asyn-
2255 chronous add operation and returns the message id of the operation ini-
2256 tiated. As for ldap_add_ext(), a subsequent call to ldap_result(),
2257 described below, can be used to obtain the result of the add. In case of
2258 error, ldap_add() will return -1, setting the session error parameters
2259 in the LDAP structure appropriately.
2261 The synchronous ldap_add_ext_s() and ldap_add_s() functions both return
2262 the result of the operation, either the constant LDAP_SUCCESS if the
2263 operation was successful, or another LDAP result code if it was not.
2264 See the section below on error handling for more information about pos-
2265 sible errors and how to interpret them.
2267 The ldap_add_ext() and ldap_add_ext_s() functions support LDAPv3 server
2268 controls and client controls.
2272 11.13. Deleting an entry
2274 The following functions are used to delete a leaf entry from the LDAP
2275 directory. There are four variations:
2277 int ldap_delete_ext(
2280 LDAPControl **serverctrls,
2281 LDAPControl **clientctrls,
2285 int ldap_delete_ext_s(
2288 LDAPControl **serverctrls,
2289 LDAPControl **clientctrls
2294 Expires: May 2001 [Page 41]
2296 C LDAP API C LDAP Application Program Interface 17 November 2000
2312 ld The session handle.
2314 dn The name of the entry to delete. If NULL, a zero length DN
2315 is sent to the server.
2317 serverctrls List of LDAP server controls, or NULL if no server controls
2320 clientctrls List of client controls, or NULL if no client controls are
2323 msgidp This result parameter will be set to the message id of the
2324 request if the ldap_delete_ext() call succeeds. The value
2325 is undefined if a value other than LDAP_SUCCESS is
2328 Note that the entry to delete must be a leaf entry (i.e., it must have
2329 no children). Deletion of entire subtrees in a single operation is not
2332 The ldap_delete_ext() function initiates an asynchronous delete opera-
2333 tion and returns the constant LDAP_SUCCESS if the request was success-
2334 fully sent, or another LDAP result code if not. See the section below
2335 on error handling for more information about possible errors and how to
2336 interpret them. If successful, ldap_delete_ext() places the message id
2337 of the request in *msgidp. A subsequent call to ldap_result(), described
2338 below, can be used to obtain the result of the delete.
2340 Similar to ldap_delete_ext(), the ldap_delete() function initiates an
2341 asynchronous delete operation and returns the message id of the opera-
2342 tion initiated. As for ldap_delete_ext(), a subsequent call to
2343 ldap_result(), described below, can be used to obtain the result of the
2344 delete. In case of error, ldap_delete() will return -1, setting the ses-
2345 sion error parameters in the LDAP structure appropriately.
2350 Expires: May 2001 [Page 42]
2352 C LDAP API C LDAP Application Program Interface 17 November 2000
2355 The synchronous ldap_delete_ext_s() and ldap_delete_s() functions both
2356 return the result of the operation, either the constant LDAP_SUCCESS if
2357 the operation was successful, or another LDAP result code if it was not.
2358 See the section below on error handling for more information about pos-
2359 sible errors and how to interpret them.
2361 The ldap_delete_ext() and ldap_delete_ext_s() functions support LDAPv3
2362 server controls and client controls.
2365 11.14. Extended Operations
2367 The ldap_extended_operation() and ldap_extended_operation_s() routines
2368 allow extended LDAP operations to be passed to the server, providing a
2369 general protocol extensibility mechanism.
2371 int ldap_extended_operation(
2373 const char *requestoid,
2374 const struct berval *requestdata,
2375 LDAPControl **serverctrls,
2376 LDAPControl **clientctrls,
2380 int ldap_extended_operation_s(
2382 const char *requestoid,
2383 const struct berval *requestdata,
2384 LDAPControl **serverctrls,
2385 LDAPControl **clientctrls,
2387 struct berval **retdatap
2392 ld The session handle.
2394 requestoid The dotted-OID text string naming the request.
2396 requestdata The arbitrary data needed by the operation (if NULL, no
2397 data is sent to the server).
2399 serverctrls List of LDAP server controls, or NULL if no server controls
2402 clientctrls List of client controls, or NULL if no client controls are
2406 Expires: May 2001 [Page 43]
2408 C LDAP API C LDAP Application Program Interface 17 November 2000
2413 msgidp This result parameter will be set to the message id of the
2414 request if the ldap_extended_operation() call succeeds. The
2415 value is undefined if a value other than LDAP_SUCCESS is
2418 retoidp Pointer to a character string that will be set to an allo-
2419 cated, dotted-OID text string returned by the server. This
2420 string SHOULD be disposed of using the ldap_memfree() func-
2421 tion. If an API error occurs or no OID is returned by the
2422 server, *retoidp is set to NULL.
2424 retdatap Pointer to a berval structure pointer that will be set an
2425 allocated copy of the data returned by the server. This
2426 struct berval SHOULD be disposed of using ber_bvfree(). If
2427 an API error occurs or no data is returned by the server,
2428 *retdatap is set to NULL.
2430 The ldap_extended_operation() function initiates an asynchronous
2431 extended operation and returns the constant LDAP_SUCCESS if the request
2432 was successfully sent, or another LDAP result code if not. See the sec-
2433 tion below on error handling for more information about possible errors
2434 and how to interpret them. If successful, ldap_extended_operation()
2435 places the message id of the request in *msgidp. A subsequent call to
2436 ldap_result(), described below, can be used to obtain the result of the
2437 extended operation which can be passed to ldap_parse_extended_result()
2438 to obtain the OID and data contained in the response.
2440 The synchronous ldap_extended_operation_s() function returns the result
2441 of the operation, either the constant LDAP_SUCCESS if the operation was
2442 successful, or another LDAP result code if it was not. See the section
2443 below on error handling for more information about possible errors and
2444 how to interpret them. The retoid and retdata parameters are filled in
2445 with the OID and data from the response.
2447 The ldap_extended_operation() and ldap_extended_operation_s() functions
2448 both support LDAPv3 server controls and client controls.
2451 12. Abandoning An Operation
2453 The following calls are used to abandon an operation in progress:
2455 int ldap_abandon_ext(
2458 LDAPControl **serverctrls,
2462 Expires: May 2001 [Page 44]
2464 C LDAP API C LDAP Application Program Interface 17 November 2000
2467 LDAPControl **clientctrls
2476 ld The session handle.
2478 msgid The message id of the request to be abandoned.
2480 serverctrls List of LDAP server controls, or NULL if no server controls
2483 clientctrls List of client controls, or NULL if no client controls are
2486 ldap_abandon_ext() abandons the operation with message id msgid and
2487 returns the constant LDAP_SUCCESS if the abandon was successful or
2488 another LDAP result code if not. See the section below on error han-
2489 dling for more information about possible errors and how to interpret
2492 ldap_abandon() is identical to ldap_abandon_ext() except that it does
2493 not accept client or server controls and it returns zero if the abandon
2494 was successful, -1 otherwise.
2496 After a successful call to ldap_abandon() or ldap_abandon_ext(), results
2497 with the given message id are never returned from a subsequent call to
2498 ldap_result(). There is no server response to LDAP abandon operations.
2501 13. Obtaining Results and Peeking Inside LDAP Messages
2503 ldap_result() is used to obtain the result of a previous asynchronously
2504 initiated operation. Note that depending on how it is called,
2505 ldap_result() can actually return a list or "chain" of result messages.
2506 The ldap_result() function only returns messages for a single request,
2507 so for all LDAP operations other than search only one result message is
2508 expected; that is, the only time the "result chain" can contain more
2509 than one message is if results from a search operation are returned.
2510 Once a chain of messages has been returned to the caller, it is no
2511 longer tied in any caller-visible way to the LDAP request that produced
2512 it. However, it MAY be tied to the session handle. Therefore, a chain
2513 of messages returned by calling ldap_result() or by calling a synchro-
2514 nous search routine will never be affected by subsequent LDAP API calls
2518 Expires: May 2001 [Page 45]
2520 C LDAP API C LDAP Application Program Interface 17 November 2000
2523 except for ldap_msgfree() (which is used to dispose of a chain of mes-
2524 sages) and the unbind calls (which dispose of a session handle):
2525 ldap_unbind(), ldap_unbind_s(), or ldap_unbind_ext(), or functions
2526 defined by extensions of this API.
2528 ldap_msgfree() frees the result messages (possibly an entire chain of
2529 messages) obtained from a previous call to ldap_result() or from a call
2530 to a synchronous search routine.
2532 ldap_msgtype() returns the type of an LDAP message.
2534 ldap_msgid() returns the message ID of an LDAP message.
2540 struct timeval *timeout,
2544 int ldap_msgfree( LDAPMessage *res );
2546 int ldap_msgtype( LDAPMessage *res );
2548 int ldap_msgid( LDAPMessage *res );
2552 ld The session handle.
2554 msgid The message id of the operation whose results are to be
2555 returned, the constant LDAP_RES_UNSOLICITED (0) if an unsoli-
2556 cited result is desired, or or the constant LDAP_RES_ANY (-1)
2557 if any result is desired.
2559 all Specifies how many messages will be retrieved in a single call
2560 to ldap_result(). This parameter only has meaning for search
2561 results. Pass the constant LDAP_MSG_ONE (0x00) to retrieve one
2562 message at a time. Pass LDAP_MSG_ALL (0x01) to request that
2563 all results of a search be received before returning all
2564 results in a single chain. Pass LDAP_MSG_RECEIVED (0x02) to
2565 indicate that all messages retrieved so far are to be returned
2566 in the result chain.
2568 timeout A timeout specifying how long to wait for results to be
2569 returned. A NULL value causes ldap_result() to block until
2570 results are available. A timeout value of zero seconds
2574 Expires: May 2001 [Page 46]
2576 C LDAP API C LDAP Application Program Interface 17 November 2000
2579 specifies a polling behavior.
2581 res For ldap_result(), a result parameter that will contain the
2582 result(s) of the operation. If an API error occurs or no
2583 results are returned, *res is set to NULL. For ldap_msgfree(),
2584 the result chain to be freed, obtained from a previous call to
2585 ldap_result(), ldap_search_s(), or ldap_search_st(). If res is
2586 NULL, nothing is done and ldap_msgfree() returns zero.
2588 Upon successful completion, ldap_result() returns the type of the first
2589 result returned in the res parameter. This will be one of the following
2592 LDAP_RES_BIND (0x61)
2593 LDAP_RES_SEARCH_ENTRY (0x64)
2594 LDAP_RES_SEARCH_REFERENCE (0x73) -- new in LDAPv3
2595 LDAP_RES_SEARCH_RESULT (0x65)
2596 LDAP_RES_MODIFY (0x67)
2598 LDAP_RES_DELETE (0x6B)
2599 LDAP_RES_MODDN (0x6D)
2600 LDAP_RES_COMPARE (0x6F)
2601 LDAP_RES_EXTENDED (0x78) -- new in LDAPv3
2603 ldap_result() returns 0 if the timeout expired and -1 if an error
2604 occurs, in which case the error parameters of the LDAP session handle
2605 will be set accordingly.
2607 ldap_msgfree() frees each message in the result chain pointed to by res
2608 and returns the type of the last message in the chain. If res is NULL,
2609 nothing is done and the value zero is returned.
2611 ldap_msgtype() returns the type of the LDAP message it is passed as a
2612 parameter. The type will be one of the types listed above, or -1 on
2615 ldap_msgid() returns the message ID associated with the LDAP message
2616 passed as a parameter, or -1 on error.
2619 14. Handling Errors and Parsing Results
2621 The following calls are used to extract information from results and
2622 handle errors returned by other LDAP API routines. Note that
2623 ldap_parse_sasl_bind_result() and ldap_parse_extended_result() must typ-
2624 ically be used in addition to ldap_parse_result() to retrieve all the
2625 result information from SASL Bind and Extended Operations respectively.
2630 Expires: May 2001 [Page 47]
2632 C LDAP API C LDAP Application Program Interface 17 November 2000
2635 int ldap_parse_result(
2642 LDAPControl ***serverctrlsp,
2646 int ldap_parse_sasl_bind_result(
2649 struct berval **servercredp,
2653 int ldap_parse_extended_result(
2657 struct berval **retdatap,
2661 #define LDAP_NOTICE_OF_DISCONNECTION "1.3.6.1.4.1.1466.20036"
2663 char *ldap_err2string( int err );
2665 The use of the following routines is deprecated and more complete
2666 descriptions can be found in RFC 1823:
2668 int ldap_result2error(
2674 void ldap_perror( LDAP *ld, const char *msg );
2678 ld The session handle.
2680 res The result of an LDAP operation as returned by
2681 ldap_result() or one of the synchronous API operation
2686 Expires: May 2001 [Page 48]
2688 C LDAP API C LDAP Application Program Interface 17 November 2000
2691 errcodep This result parameter will be filled in with the LDAP
2692 resultCode field from the LDAPMessage message. This is the
2693 indication from the server of the outcome of the operation.
2694 NULL SHOULD be passed to ignore this field.
2696 matcheddnp If the server returned a matchedDN string to indicate how
2697 much of a name passed in a request was recognized, this
2698 result parameter will be filled in with that matchedDN
2699 string. Otherwise, this field will be set to NULL. NULL
2700 SHOULD be passed to ignore this field. The matched DN
2701 string SHOULD be freed by calling ldap_memfree() which is
2702 described later in this document. Note that the server may
2703 return a zero length matchedDN (in which case *matchednp is
2704 set to an allocated copy of "") which is different than not
2705 returning a value at all (in which case *matcheddnp is set
2708 errmsgp This result parameter will be filled in with the contents
2709 of the error message field from the LDAPMessage message.
2710 The error message string SHOULD be freed by calling
2711 ldap_memfree() which is described later in this document.
2712 NULL SHOULD be passed to ignore this field.
2714 referralsp This result parameter will be filled in with the contents
2715 of the referrals field from the LDAPMessage message, indi-
2716 cating zero or more alternate LDAP servers where the
2717 request is to be retried. The referrals array SHOULD be
2718 freed by calling ldap_value_free() which is described later
2719 in this document. NULL SHOULD be passed to ignore this
2720 field. If no referrals were returned, *referralsp is set
2723 serverctrlsp This result parameter will be filled in with an allocated
2724 array of controls copied out of the LDAPMessage message.
2725 If serverctrlsp is NULL, no controls are returned. The
2726 control array SHOULD be freed by calling
2727 ldap_controls_free() which was described earlier. If no
2728 controls were returned, *serverctrlsp is set to NULL.
2730 freeit A boolean that determines whether the res parameter is
2731 disposed of or not. Pass any non-zero value to have these
2732 routines free res after extracting the requested informa-
2733 tion. This is provided as a convenience; you can also use
2734 ldap_msgfree() to free the result later. If freeit is
2735 non-zero, the entire chain of messages represented by res
2738 servercredp For SASL bind results, this result parameter will be filled
2742 Expires: May 2001 [Page 49]
2744 C LDAP API C LDAP Application Program Interface 17 November 2000
2747 in with the credentials passed back by the server for
2748 mutual authentication, if given. An allocated berval struc-
2749 ture is returned that SHOULD be disposed of by calling
2750 ber_bvfree(). NULL SHOULD be passed to ignore this field.
2752 retoidp For extended results, this result parameter will be filled
2753 in with the dotted-OID text representation of the name of
2754 the extended operation response. This string SHOULD be
2755 disposed of by calling ldap_memfree(). NULL SHOULD be
2756 passed to ignore this field. If no OID was returned,
2757 *retoidp is set to NULL. The LDAP_NOTICE_OF_DISCONNECTION
2758 macro is defined as a convenience for clients that wish to
2759 check an OID to see if it matches the one used for the
2760 unsolicited Notice of Disconnection (defined in RFC 2251[2]
2763 retdatap For extended results, this result parameter will be filled
2764 in with a pointer to a struct berval containing the data in
2765 the extended operation response. It SHOULD be disposed of
2766 by calling ber_bvfree(). NULL SHOULD be passed to ignore
2767 this field. If no data is returned, *retdatap is set to
2770 err For ldap_err2string(), an LDAP result code, as returned by
2771 ldap_parse_result() or another LDAP API call.
2773 Additional parameters for the deprecated routines are not described.
2774 Interested readers are referred to RFC 1823.
2776 The ldap_parse_result(), ldap_parse_sasl_bind_result(), and
2777 ldap_parse_extended_result() functions all skip over messages of type
2778 LDAP_RES_SEARCH_ENTRY and LDAP_RES_SEARCH_REFERENCE when looking for a
2779 result message to parse. They return the constant LDAP_SUCCESS if the
2780 result was successfully parsed and another LDAP API result code if not.
2781 If a value other than LDAP_SUCCESS is returned, the values of all the
2782 result parameters are undefined. Note that the LDAP result code that
2783 indicates the outcome of the operation performed by the server is placed
2784 in the errcodep ldap_parse_result() parameter. If a chain of messages
2785 that contains more than one result message is passed to these routines
2786 they always operate on the first result in the chain.
2788 ldap_err2string() is used to convert a numeric LDAP result code, as
2789 returned by ldap_parse_result(), ldap_parse_sasl_bind_result(),
2790 ldap_parse_extended_result() or one of the synchronous API operation
2791 calls, into an informative zero-terminated character string message
2792 describing the error. It returns a pointer to static data and it MUST
2793 NOT return NULL; the value returned is always a valid null-terminated
2798 Expires: May 2001 [Page 50]
2800 C LDAP API C LDAP Application Program Interface 17 November 2000
2803 15. Stepping Through a List of Results
2805 The ldap_first_message() and ldap_next_message() routines are used to
2806 step through the list of messages in a result chain returned by
2807 ldap_result(). For search operations, the result chain can actually
2808 include referral messages, entry messages, and result messages.
2809 ldap_count_messages() is used to count the number of messages returned.
2810 The ldap_msgtype() function, described above, can be used to distinguish
2811 between the different message types.
2813 LDAPMessage *ldap_first_message( LDAP *ld, LDAPMessage *res );
2815 LDAPMessage *ldap_next_message( LDAP *ld, LDAPMessage *msg );
2817 int ldap_count_messages( LDAP *ld, LDAPMessage *res );
2821 ld The session handle.
2823 res The result chain, as obtained by a call to one of the synchronous
2824 search routines or ldap_result().
2826 msg The message returned by a previous call to ldap_first_message()
2827 or ldap_next_message().
2829 ldap_first_message() and ldap_next_message() will return NULL when no
2830 more messages exist in the result set to be returned. NULL is also
2831 returned if an error occurs while stepping through the entries, in which
2832 case the error parameters in the session handle ld will be set to indi-
2835 If successful, ldap_count_messages() returns the number of messages con-
2836 tained in a chain of results; if an error occurs such as the res parame-
2837 ter being invalid, -1 is returned. The ldap_count_messages() call can
2838 also be used to count the number of messages that remain in a chain if
2839 called with a message, entry, or reference returned by
2840 ldap_first_message(), ldap_next_message(), ldap_first_entry(),
2841 ldap_next_entry(), ldap_first_reference(), ldap_next_reference().
2844 16. Parsing Search Results
2846 The following calls are used to parse the entries and references
2847 returned by ldap_search() and friends. These results are returned in an
2848 opaque structure that MAY be accessed by calling the routines described
2849 below. Routines are provided to step through the entries and references
2850 returned, step through the attributes of an entry, retrieve the name of
2854 Expires: May 2001 [Page 51]
2856 C LDAP API C LDAP Application Program Interface 17 November 2000
2859 an entry, and retrieve the values associated with a given attribute in
2863 16.1. Stepping Through a List of Entries or References
2865 The ldap_first_entry() and ldap_next_entry() routines are used to step
2866 through and retrieve the list of entries from a search result chain.
2867 The ldap_first_reference() and ldap_next_reference() routines are used
2868 to step through and retrieve the list of continuation references from a
2869 search result chain. ldap_count_entries() is used to count the number
2870 of entries returned. ldap_count_references() is used to count the number
2871 of references returned.
2873 LDAPMessage *ldap_first_entry( LDAP *ld, LDAPMessage *res );
2875 LDAPMessage *ldap_next_entry( LDAP *ld, LDAPMessage *entry );
2877 LDAPMessage *ldap_first_reference( LDAP *ld, LDAPMessage *res );
2879 LDAPMessage *ldap_next_reference( LDAP *ld, LDAPMessage *ref );
2881 int ldap_count_entries( LDAP *ld, LDAPMessage *res );
2883 int ldap_count_references( LDAP *ld, LDAPMessage *res );
2887 ld The session handle.
2889 res The search result, as obtained by a call to one of the synchro-
2890 nous search routines or ldap_result().
2892 entry The entry returned by a previous call to ldap_first_entry() or
2895 ref The reference returned by a previous call to
2896 ldap_first_reference() or ldap_next_reference().
2898 ldap_first_entry(), ldap_next_entry(), ldap_first_reference() and
2899 ldap_next_reference() all return NULL when no more entries or references
2900 exist in the result set to be returned. NULL is also returned if an
2901 error occurs while stepping through the entries or references, in which
2902 case the error parameters in the session handle ld will be set to indi-
2905 ldap_count_entries() returns the number of entries contained in a chain
2906 of entries; if an error occurs such as the res parameter being invalid,
2910 Expires: May 2001 [Page 52]
2912 C LDAP API C LDAP Application Program Interface 17 November 2000
2915 -1 is returned. The ldap_count_entries() call can also be used to count
2916 the number of entries that remain in a chain if called with a message,
2917 entry or reference returned by ldap_first_message(),
2918 ldap_next_message(), ldap_first_entry(), ldap_next_entry(),
2919 ldap_first_reference(), ldap_next_reference().
2921 ldap_count_references() returns the number of references contained in a
2922 chain of search results; if an error occurs such as the res parameter
2923 being invalid, -1 is returned. The ldap_count_references() call can
2924 also be used to count the number of references that remain in a chain.
2927 16.2. Stepping Through the Attributes of an Entry
2929 The ldap_first_attribute() and ldap_next_attribute() calls are used to
2930 step through the list of attribute types returned with an entry.
2932 char *ldap_first_attribute(
2938 char *ldap_next_attribute(
2944 void ldap_memfree( char *mem );
2948 ld The session handle.
2950 entry The entry whose attributes are to be stepped through, as returned
2951 by ldap_first_entry() or ldap_next_entry().
2953 ptr In ldap_first_attribute(), the address of a pointer used inter-
2954 nally to keep track of the current position in the entry. In
2955 ldap_next_attribute(), the pointer returned by a previous call to
2956 ldap_first_attribute(). The BerElement type itself is an opaque
2957 structure that is described in more detail later in this document
2958 in the section "Encoded ASN.1 Value Manipulation".
2960 mem A pointer to memory allocated by the LDAP library, such as the
2961 attribute type names returned by ldap_first_attribute() and
2962 ldap_next_attribute, or the DN returned by ldap_get_dn(). If mem
2966 Expires: May 2001 [Page 53]
2968 C LDAP API C LDAP Application Program Interface 17 November 2000
2971 is NULL, the ldap_memfree() call does nothing.
2973 ldap_first_attribute() and ldap_next_attribute() will return NULL when
2974 the end of the attributes is reached, or if there is an error, in which
2975 case the error parameters in the session handle ld will be set to indi-
2978 Both routines return a pointer to an allocated buffer containing the
2979 current attribute name. This SHOULD be freed when no longer in use by
2980 calling ldap_memfree().
2982 ldap_first_attribute() will allocate and return in ptr a pointer to a
2983 BerElement used to keep track of the current position. This pointer MAY
2984 be passed in subsequent calls to ldap_next_attribute() to step through
2985 the entry's attributes. After a set of calls to ldap_first_attribute()
2986 and ldap_next_attribute(), if ptr is non-NULL, it SHOULD be freed by
2987 calling ber_free( ptr, 0 ). Note that it is very important to pass the
2988 second parameter as 0 (zero) in this call, since the buffer associated
2989 with the BerElement does not point to separately allocated memory.
2991 The attribute type names returned are suitable for passing in a call to
2992 ldap_get_values() and friends to retrieve the associated values.
2995 16.3. Retrieving the Values of an Attribute
2997 ldap_get_values() and ldap_get_values_len() are used to retrieve the
2998 values of a given attribute from an entry. ldap_count_values() and
2999 ldap_count_values_len() are used to count the returned values.
3000 ldap_value_free() and ldap_value_free_len() are used to free the values.
3002 char **ldap_get_values(
3008 struct berval **ldap_get_values_len(
3014 int ldap_count_values( char **vals );
3016 int ldap_count_values_len( struct berval **vals );
3018 void ldap_value_free( char **vals );
3022 Expires: May 2001 [Page 54]
3024 C LDAP API C LDAP Application Program Interface 17 November 2000
3027 void ldap_value_free_len( struct berval **vals );
3031 ld The session handle.
3033 entry The entry from which to retrieve values, as returned by
3034 ldap_first_entry() or ldap_next_entry().
3036 attr The attribute whose values are to be retrieved, as returned by
3037 ldap_first_attribute() or ldap_next_attribute(), or a caller-
3038 supplied string (e.g., "mail").
3040 vals The values returned by a previous call to ldap_get_values() or
3041 ldap_get_values_len().
3043 Two forms of the various calls are provided. The first form is only
3044 suitable for use with non-binary character string data. The second _len
3045 form is used with any kind of data.
3047 ldap_get_values() and ldap_get_values_len() return NULL if no values are
3048 found for attr or if an error occurs.
3050 ldap_count_values() and ldap_count_values_len() return -1 if an error
3051 occurs such as the vals parameter being invalid.
3053 If a NULL vals parameter is passed to ldap_value_free() or
3054 ldap_value_free_len(), nothing is done.
3056 Note that the values returned are dynamically allocated and SHOULD be
3057 freed by calling either ldap_value_free() or ldap_value_free_len() when
3061 16.4. Retrieving the name of an entry
3063 ldap_get_dn() is used to retrieve the name of an entry.
3064 ldap_explode_dn() and ldap_explode_rdn() are used to break up a name
3065 into its component parts. ldap_dn2ufn() is used to convert the name into
3066 a more "user friendly" format.
3068 char *ldap_get_dn( LDAP *ld, LDAPMessage *entry );
3070 char **ldap_explode_dn( const char *dn, int notypes );
3072 char **ldap_explode_rdn( const char *rdn, int notypes );
3074 char *ldap_dn2ufn( const char *dn );
3078 Expires: May 2001 [Page 55]
3080 C LDAP API C LDAP Application Program Interface 17 November 2000
3085 ld The session handle.
3087 entry The entry whose name is to be retrieved, as returned by
3088 ldap_first_entry() or ldap_next_entry().
3090 dn The dn to explode, such as returned by ldap_get_dn(). If NULL,
3091 a zero length DN is used.
3093 rdn The rdn to explode, such as returned in the components of the
3094 array returned by ldap_explode_dn(). If NULL, a zero length DN
3097 notypes A boolean parameter, if non-zero indicating that the dn or rdn
3098 components are to have their type information stripped off
3099 (i.e., "cn=Babs" would become "Babs").
3101 ldap_get_dn() will return NULL if there is some error parsing the dn,
3102 setting error parameters in the session handle ld to indicate the error.
3103 It returns a pointer to newly allocated space that the caller SHOULD
3104 free by calling ldap_memfree() when it is no longer in use. Note the
3105 format of the DNs returned is given by [5]. The root DN is returned as
3106 a zero length string ("").
3108 ldap_explode_dn() returns a NULL-terminated char * array containing the
3109 RDN components of the DN supplied, with or without types as indicated by
3110 the notypes parameter. The components are returned in the order they
3111 appear in the dn. The array returned SHOULD be freed when it is no
3112 longer in use by calling ldap_value_free().
3114 ldap_explode_rdn() returns a NULL-terminated char * array containing the
3115 components of the RDN supplied, with or without types as indicated by
3116 the notypes parameter. The components are returned in the order they
3117 appear in the rdn. The array returned SHOULD be freed when it is no
3118 longer in use by calling ldap_value_free().
3120 ldap_dn2ufn() converts the DN into the user friendly format described in
3121 [14]. The UFN returned is newly allocated space that SHOULD be freed by
3122 a call to ldap_memfree() when no longer in use.
3125 16.5. Retrieving controls from an entry
3127 ldap_get_entry_controls() is used to extract LDAP controls from an
3134 Expires: May 2001 [Page 56]
3136 C LDAP API C LDAP Application Program Interface 17 November 2000
3139 int ldap_get_entry_controls(
3142 LDAPControl ***serverctrlsp
3147 ld The session handle.
3149 entry The entry to extract controls from, as returned by
3150 ldap_first_entry() or ldap_next_entry().
3152 serverctrlsp This result parameter will be filled in with an allocated
3153 array of controls copied out of entry. The control array
3154 SHOULD be freed by calling ldap_controls_free(). If ser-
3155 verctrlsp is NULL, no controls are returned. If no con-
3156 trols were returned, *serverctrlsp is set to NULL.
3158 ldap_get_entry_controls() returns an LDAP result code that indicates
3159 whether the reference could be successfully parsed (LDAP_SUCCESS if all
3160 goes well). If ldap_get_entry_controls() returns a value other than
3161 LDAP_SUCCESS, the value of the serverctrlsp output parameter is unde-
3166 16.6. Parsing References
3168 ldap_parse_reference() is used to extract referrals and controls from a
3169 SearchResultReference message.
3172 int ldap_parse_reference(
3176 LDAPControl ***serverctrlsp,
3182 ld The session handle.
3184 ref The reference to parse, as returned by ldap_result(),
3185 ldap_first_reference(), or ldap_next_reference().
3190 Expires: May 2001 [Page 57]
3192 C LDAP API C LDAP Application Program Interface 17 November 2000
3195 referralsp This result parameter will be filled in with an allocated
3196 array of character strings. The elements of the array are
3197 the referrals (typically LDAP URLs) contained in ref. The
3198 array SHOULD be freed when no longer in used by calling
3199 ldap_value_free(). If referralsp is NULL, the referral
3200 URLs are not returned. If no referrals were returned,
3201 *referralsp is set to NULL.
3203 serverctrlsp This result parameter will be filled in with an allocated
3204 array of controls copied out of ref. The control array
3205 SHOULD be freed by calling ldap_controls_free(). If ser-
3206 verctrlsp is NULL, no controls are returned. If no con-
3207 trols were returned, *serverctrlsp is set to NULL.
3209 freeit A boolean that determines whether the ref parameter is
3210 disposed of or not. Pass any non-zero value to have this
3211 routine free ref after extracting the requested informa-
3212 tion. This is provided as a convenience; you can also use
3213 ldap_msgfree() to free the result later.
3215 ldap_parse_reference() returns an LDAP result code that indicates
3216 whether the reference could be successfully parsed (LDAP_SUCCESS if all
3217 goes well). If a value other than LDAP_SUCCESS is returned, the value
3218 of the referralsp and serverctrlsp result parameters are undefined.
3222 17. Encoded ASN.1 Value Manipulation
3224 This section describes routines which MAY be used to encode and decode
3225 BER-encoded ASN.1 values, which are often used inside of control and
3228 With the exceptions of two new functions ber_flatten() and ber_init(),
3229 these functions are compatible with the University of Michigan LDAP 3.3
3230 implementation of BER.
3232 Note that the functions defined in this section all provide a method for
3233 determining success or failure but generally do not provide access to
3234 specific error codes. Therefore, applications that require precise
3235 error information when encoding or decoding ASN.1 values SHOULD NOT use
3239 17.1. BER Data Structures and Types
3241 The following additional integral types are defined for use in manipula-
3242 tion of BER encoded ASN.1 values:
3246 Expires: May 2001 [Page 58]
3248 C LDAP API C LDAP Application Program Interface 17 November 2000
3251 typedef <impl_tag_t> ber_tag_t; /* for BER tags */
3253 typedef <impl_int_t> ber_int_t; /* for BER ints, enums, and Booleans */
3255 typedef <impl_unit_t> ber_uint_t; /* unsigned equivalent of ber_uint_t */
3257 typedef <impl_slen_t> ber_slen_t; /* signed equivalent of ber_len_t */
3259 Note that the actual definition for these four integral types is imple-
3260 mentation specific; that is, `<impl_tag_t>', `<impl_int_t>',
3261 `<impl_uint_t>', and `<impl_slen_t>' MUST each be replaced with an
3262 appropriate implementation-specific type.
3264 The `ber_tag_t' type is an unsigned integral data type that is large
3265 enough to hold the largest BER tag supported by the API implementation.
3266 The width (number of significant bits) of `ber_tag_t' MUST be at least
3267 32, greater than or equal to that of `unsigned int' (so that integer
3268 promotions won't promote it to `int'), and no wider than that of
3271 The `ber_int_t' and `ber_uint_t' types are the signed and unsigned vari-
3272 ants of an integral type that is large enough to hold integers for pur-
3273 poses of BER encoding and decoding. The width of `ber_int_t' MUST be at
3274 least 32 and no larger than that of `long'.
3276 The `ber_slen_t' type is the signed variant of the `ber_len_t' integral
3277 type, i.e. if `ber_len_t' is unsigned long, then `ber_slen_t' is signed
3278 long. The `<impl_slen_t>' in the `ber_len_t' typedef MUST be replaced
3279 with an appropriate type. Note that `ber_slen_t' is not used directly
3280 in the C LDAP API but is provided for the convenience of application
3281 developers and for use by extensions to the API.
3283 typedef struct berval {
3288 As defined earlier in the section "Common Data Structures", a berval
3289 structure contains an arbitrary sequence of bytes and an indication of
3290 its length. The bv_len element is an unsigned integer. The bv_val is
3291 not necessarily zero-terminated. Applications MAY allocate their own
3294 As defined earlier in the section "Common Data Structures", the BerEle-
3295 ment structure is an opaque structure:
3297 typedef struct berelement BerElement;
3302 Expires: May 2001 [Page 59]
3304 C LDAP API C LDAP Application Program Interface 17 November 2000
3307 It contains not only a copy of the encoded value, but also state infor-
3308 mation used in encoding or decoding. Applications cannot allocate their
3309 own BerElement structures. The internal state is neither thread-
3310 specific nor locked, so two threads SHOULD NOT manipulate the same
3311 BerElement value simultaneously.
3313 A single BerElement value cannot be used for both encoding and decoding.
3315 17.2. Memory Disposal and Utility Functions
3317 void ber_bvfree( struct berval *bv );
3319 ber_bvfree() frees a berval structure returned from this API. Both the
3320 bv->bv_val string and the berval structure itself are freed. If bv is
3321 NULL, this call does nothing.
3323 void ber_bvecfree( struct berval **bv );
3325 ber_bvecfree() frees an array of berval structures returned from this
3326 API. Each of the berval structures in the array are freed using
3327 ber_bvfree(), then the array itself is freed. If bv is NULL, this call
3330 struct berval *ber_bvdup( const struct berval *bv );
3332 ber_bvdup() returns a copy of a berval structure. The bv_val field in
3333 the returned berval structure points to a different area of memory than
3334 the bv_val field in the bv argument. The NULL pointer is returned on
3335 error (e.g. out of memory).
3337 void ber_free( BerElement *ber, int fbuf );
3339 ber_free() frees a BerElement which is returned from the API calls
3340 ber_alloc_t() or ber_init(). Each BerElement SHOULD be freed by the
3341 caller. The second argument fbuf SHOULD always be set to 1 to ensure
3342 that the internal buffer used by the BER functions is freed as well as
3343 the BerElement container itself. If ber is NULL, this call does noth-
3349 BerElement *ber_alloc_t( int options );
3351 ber_alloc_t() constructs and returns BerElement. The NULL pointer is
3352 returned on error. The options field contains a bitwise-or of options
3353 which are to be used when generating the encoding of this BerElement.
3354 One option is defined and SHOULD always be supplied:
3358 Expires: May 2001 [Page 60]
3360 C LDAP API C LDAP Application Program Interface 17 November 2000
3363 #define LBER_USE_DER 0x01
3365 When this option is present, lengths will always be encoded in the
3366 minimum number of octets. Note that this option does not cause values
3367 of sets to be rearranged in tag and byte order or default values to be
3368 removed, so these functions are not sufficient for generating DER output
3369 as defined in X.509 and X.680. If the caller takes responsibility for
3370 ordering values of sets correctly and removing default values, DER out-
3371 put as defined in X.509 and X.680 can be produced.
3373 Unrecognized option bits are ignored.
3375 The BerElement returned by ber_alloc_t() is initially empty. Calls to
3376 ber_printf() will append bytes to the end of the ber_alloc_t().
3378 int ber_printf( BerElement *ber, const char *fmt, ... );
3380 The ber_printf() routine is used to encode a BER element in much the
3381 same way that sprintf() works. One important difference, though, is
3382 that state information is kept in the ber argument so that multiple
3383 calls can be made to ber_printf() to append to the end of the BER ele-
3384 ment. ber MUST be a pointer to a BerElement returned by ber_alloc_t().
3385 ber_printf() interprets and formats its arguments according to the for-
3386 mat string fmt. ber_printf() returns -1 if there is an error during
3387 encoding and a non-negative number if successful. As with sprintf(),
3388 each character in fmt refers to an argument to ber_printf().
3390 The format string can contain the following format characters:
3392 't' Tag. The next argument is a ber_tag_t specifying the tag to
3393 override the next element to be written to the ber. This works
3394 across calls. The integer tag value SHOULD contain the tag
3395 class, constructed bit, and tag value. For example, a tag of
3396 "[3]" for a constructed type is 0xA3U. All implementations MUST
3397 support tags that fit in a single octet (i.e., where the tag
3398 value is less than 32) and they MAY support larger tags.
3400 'b' Boolean. The next argument is an ber_int_t, containing either 0
3401 for FALSE or 0xff for TRUE. A boolean element is output. If
3402 this format character is not preceded by the 't' format modif-
3403 ier, the tag 0x01U is used for the element.
3405 'e' Enumerated. The next argument is a ber_int_t, containing the
3406 enumerated value in the host's byte order. An enumerated ele-
3407 ment is output. If this format character is not preceded by the
3408 't' format modifier, the tag 0x0AU is used for the element.
3410 'i' Integer. The next argument is a ber_int_t, containing the
3414 Expires: May 2001 [Page 61]
3416 C LDAP API C LDAP Application Program Interface 17 November 2000
3419 integer in the host's byte order. An integer element is output.
3420 If this format character is not preceded by the 't' format
3421 modifier, the tag 0x02U is used for the element.
3423 'B' Bitstring. The next two arguments are a char * pointer to the
3424 start of the bitstring, followed by a ber_len_t containing the
3425 number of bits in the bitstring. A bitstring element is output,
3426 in primitive form. If this format character is not preceded by
3427 the 't' format modifier, the tag 0x03U is used for the element.
3429 'X' Reserved and not to be used. In older revisions of this specif-
3432 'n' Null. No argument is needed. An ASN.1 NULL element is output.
3433 If this format character is not preceded by the 't' format
3434 modifier, the tag 0x05U is used for the element.
3436 'o' Octet string. The next two arguments are a char *, followed by
3437 a ber_len_t with the length of the string. The string MAY con-
3438 tain null bytes and are do not have to be zero-terminated. An
3439 octet string element is output, in primitive form. If this for-
3440 mat character is not preceded by the 't' format modifier, the
3441 tag 0x04U is used for the element.
3443 's' Octet string. The next argument is a char * pointing to a
3444 zero-terminated string. An octet string element in primitive
3445 form is output, which does not include the trailing '\0' (null)
3446 byte. If this format character is not preceded by the 't' format
3447 modifier, the tag 0x04U is used for the element.
3449 'v' Several octet strings. The next argument is a char **, an array
3450 of char * pointers to zero-terminated strings. The last element
3451 in the array MUST be a NULL pointer. The octet strings do not
3452 include the trailing '\0' (null) byte. Note that a construct
3453 like '{v}' is used to get an actual SEQUENCE OF octet strings.
3454 The 't' format modifier cannot be used with this format charac-
3457 'V' Several octet strings. A NULL-terminated array of struct berval
3458 *'s is supplied. Note that a construct like '{V}' is used to
3459 get an actual SEQUENCE OF octet strings. The 't' format modifier
3460 cannot be used with this format character.
3462 '{' Begin sequence. No argument is needed. If this format charac-
3463 ter is not preceded by the 't' format modifier, the tag 0x30U is
3466 '}' End sequence. No argument is needed. The 't' format modifier
3470 Expires: May 2001 [Page 62]
3472 C LDAP API C LDAP Application Program Interface 17 November 2000
3475 cannot be used with this format character.
3477 '[' Begin set. No argument is needed. If this format character is
3478 not preceded by the 't' format modifier, the tag 0x31U is used.
3480 ']' End set. No argument is needed. The 't' format modifier cannot
3481 be used with this format character.
3483 Each use of a '{' format character SHOULD be matched by a '}' character,
3484 either later in the format string, or in the format string of a subse-
3485 quent call to ber_printf() for that BerElement. The same applies to the
3486 '[' and ']' format characters.
3488 Sequences and sets nest, and implementations of this API MUST maintain
3489 internal state to be able to properly calculate the lengths.
3491 int ber_flatten( BerElement *ber, struct berval **bvPtr );
3493 The ber_flatten routine allocates a struct berval whose contents are a
3494 BER encoding taken from the ber argument. The bvPtr pointer points to
3495 the returned berval structure, which SHOULD be freed using ber_bvfree().
3496 This routine returns 0 on success and -1 on error.
3498 The ber_flatten API call is not present in U-M LDAP 3.3.
3500 The use of ber_flatten on a BerElement in which all '{' and '}' format
3501 modifiers have not been properly matched is an error (i.e., -1 will be
3502 returned by ber_flatten() if this situation is exists).
3505 17.4. Encoding Example
3507 The following is an example of encoding the following ASN.1 data type:
3509 Example1Request ::= SEQUENCE {
3510 s OCTET STRING, -- must be printable
3512 val2 [0] INTEGER DEFAULT 0
3516 int encode_example1(const char *s, ber_int_t val1, ber_int_t val2,
3517 struct berval **bvPtr)
3522 *bvPtr = NULL; /* in case of error */
3526 Expires: May 2001 [Page 63]
3528 C LDAP API C LDAP Application Program Interface 17 November 2000
3531 ber = ber_alloc_t(LBER_USE_DER);
3533 if (ber == NULL) return -1;
3535 if (ber_printf(ber,"{si",s,val1) == -1) {
3540 if (ber_printf(ber,"ti",(ber_tag_t)0x80,val2) == -1) {
3545 if (ber_printf(ber,"}") == -1) {
3549 rc = ber_flatten(ber,bvPtr);
3559 The following two macros are available to applications: LBER_ERROR and
3560 LBER_DEFAULT. Both of these macros MUST be #define'd as ber_tag_t
3561 integral values that are treated as invalid tags by the API implementa-
3562 tion. It is RECOMMENDED that the values of LBER_ERROR and LBER_DEFAULT
3563 be the same and that they be defined as values where all octets have the
3564 value 0xFF. ISO C guarantees that these definitions will work:
3566 #define LBER_ERROR ((ber_tag_t)-1)
3567 #define LBER_DEFAULT ((ber_tag_t)-1)
3569 The intent is that LBER_ERROR and LBER_DEFAULT are both defined as the
3570 integer value that has all octets set to 0xFF, as such a value is not a
3573 BerElement *ber_init( const struct berval *bv );
3575 The ber_init function constructs a BerElement and returns a new BerEle-
3576 ment containing a copy of the data in the bv argument. ber_init returns
3577 the NULL pointer on error.
3582 Expires: May 2001 [Page 64]
3584 C LDAP API C LDAP Application Program Interface 17 November 2000
3587 ber_tag_t ber_scanf( BerElement *ber, const char *fmt, ... );
3589 The ber_scanf() routine is used to decode a BER element in much the same
3590 way that sscanf() works. One important difference, though, is that some
3591 state information is kept with the ber argument so that multiple calls
3592 can be made to ber_scanf() to sequentially read from the BER element.
3593 The ber argument SHOULD be a pointer to a BerElement returned by
3594 ber_init(). ber_scanf interprets the bytes according to the format
3595 string fmt, and stores the results in its additional arguments.
3596 ber_scanf() returns LBER_ERROR on error, and a different value on suc-
3597 cess. If an error occurred, the values of all the result parameters are
3600 The format string contains conversion specifications which are used to
3601 direct the interpretation of the BER element. The format string can
3602 contain the following characters:
3604 'a' Octet string. A char ** argument MUST be supplied. Memory is
3605 allocated, filled with the contents of the octet string, zero-
3606 terminated, and the pointer to the string is stored in the argu-
3607 ment. The returned value SHOULD be freed using ldap_memfree.
3608 The tag of the element MUST indicate the primitive form (con-
3609 structed strings are not supported) but is otherwise ignored and
3610 discarded during the decoding. This format cannot be used with
3611 octet strings which could contain null bytes.
3613 'O' Octet string. A struct berval ** argument MUST be supplied,
3614 which upon return points to an allocated struct berval contain-
3615 ing the octet string and its length. ber_bvfree() SHOULD be
3616 called to free the allocated memory. The tag of the element
3617 MUST indicate the primitive form (constructed strings are not
3618 supported) but is otherwise ignored during the decoding.
3620 'b' Boolean. A pointer to a ber_int_t MUST be supplied. The
3621 ber_int_t value stored will be 0 for FALSE or nonzero for TRUE.
3622 The tag of the element MUST indicate the primitive form but is
3623 otherwise ignored during the decoding.
3625 'e' Enumerated. A pointer to a ber_int_t MUST be supplied. The
3626 enumerated value stored will be in host byte order. The tag of
3627 the element MUST indicate the primitive form but is otherwise
3628 ignored during the decoding. ber_scanf() will return an error
3629 if the value of the enumerated value cannot be stored in a
3632 'i' Integer. A pointer to a ber_int_t MUST be supplied. The
3633 ber_int_t value stored will be in host byte order. The tag of
3634 the element MUST indicate the primitive form but is otherwise
3638 Expires: May 2001 [Page 65]
3640 C LDAP API C LDAP Application Program Interface 17 November 2000
3643 ignored during the decoding. ber_scanf() will return an error
3644 if the integer cannot be stored in a ber_int_t.
3646 'B' Bitstring. A char ** argument MUST be supplied which will point
3647 to the allocated bits, followed by a ber_len_t * argument, which
3648 will point to the length (in bits) of the bitstring returned.
3649 ldap_memfree SHOULD be called to free the bitstring. The tag of
3650 the element MUST indicate the primitive form (constructed bit-
3651 strings are not supported) but is otherwise ignored during the
3654 'n' Null. No argument is needed. The element is verified to have a
3655 zero-length value and is skipped. The tag is ignored.
3657 't' Tag. A pointer to a ber_tag_t MUST be supplied. The ber_tag_t
3658 value stored will be the tag of the next element in the BerEle-
3659 ment ber, represented so it can be written using the 't' format
3660 of ber_printf(). The decoding position within the ber argument
3661 is unchanged by this; that is, the fact that the tag has been
3662 retrieved does not affect future use of ber.
3664 'v' Several octet strings. A char *** argument MUST be supplied,
3665 which upon return points to an allocated NULL-terminated array
3666 of char *'s containing the octet strings. NULL is stored if the
3667 sequence is empty. ldap_memfree SHOULD be called to free each
3668 element of the array and the array itself. The tag of the
3669 sequence and of the octet strings are ignored.
3671 'V' Several octet strings (which could contain null bytes). A
3672 struct berval *** MUST be supplied, which upon return points to
3673 a allocated NULL-terminated array of struct berval *'s contain-
3674 ing the octet strings and their lengths. NULL is stored if the
3675 sequence is empty. ber_bvecfree() can be called to free the
3676 allocated memory. The tag of the sequence and of the octet
3677 strings are ignored.
3679 'x' Skip element. The next element is skipped. No argument is
3682 '{' Begin sequence. No argument is needed. The initial sequence
3683 tag and length are skipped.
3685 '}' End sequence. No argument is needed.
3687 '[' Begin set. No argument is needed. The initial set tag and
3690 ']' End set. No argument is needed.
3694 Expires: May 2001 [Page 66]
3696 C LDAP API C LDAP Application Program Interface 17 November 2000
3699 ber_tag_t ber_peek_tag( BerElement *ber,
3700 ber_len_t *lenPtr );
3702 ber_peek_tag() returns the tag of the next element to be parsed in the
3703 BerElement argument. The length of this element is stored in the
3704 *lenPtr argument. LBER_DEFAULT is returned if there is no further data
3705 to be read. The decoding position within the ber argument is unchanged
3706 by this call; that is, the fact that ber_peek_tag() has been called does
3707 not affect future use of ber.
3709 ber_tag_t ber_skip_tag( BerElement *ber, ber_len_t *lenPtr );
3711 ber_skip_tag() is similar to ber_peek_tag(), except that the state
3712 pointer in the BerElement argument is advanced past the first tag and
3713 length, and is pointed to the value part of the next element. This rou-
3714 tine SHOULD only be used with constructed types and situations when a
3715 BER encoding is used as the value of an OCTET STRING. The length of the
3716 value is stored in *lenPtr.
3718 ber_tag_t ber_first_element( BerElement *ber,
3719 ber_len_t *lenPtr, char **opaquePtr );
3721 ber_tag_t ber_next_element( BerElement *ber,
3722 ber_len_t *lenPtr, char *opaque );
3724 ber_first_element() and ber_next_element() are used to traverse a SET,
3725 SET OF, SEQUENCE or SEQUENCE OF data value. ber_first_element() calls
3726 ber_skip_tag(), stores internal information in *lenPtr and *opaquePtr,
3727 and calls ber_peek_tag() for the first element inside the constructed
3728 value. LBER_DEFAULT is returned if the constructed value is empty.
3729 ber_next_element() positions the state at the start of the next element
3730 in the constructed type. LBER_DEFAULT is returned if there are no
3733 The len and opaque values SHOULD NOT be used by applications other than
3734 as arguments to ber_next_element(), as shown in the example below.
3737 17.6. Decoding Example
3739 The following is an example of decoding an ASN.1 data type:
3741 Example2Request ::= SEQUENCE {
3742 dn OCTET STRING, -- must be printable
3743 scope ENUMERATED { b (0), s (1), w (2) },
3744 ali ENUMERATED { n (0), s (1), f (2), a (3) },
3750 Expires: May 2001 [Page 67]
3752 C LDAP API C LDAP Application Program Interface 17 November 2000
3756 attrs SEQUENCE OF OCTET STRING, -- must be printable
3757 [0] SEQUENCE OF SEQUENCE {
3758 type OCTET STRING -- must be printable,
3759 crit BOOLEAN DEFAULT FALSE,
3763 #define TAG_CONTROL_LIST 0xA0U /* context specific cons 0 */
3765 int decode_example2(struct berval *bv)
3770 ber_int_t scope, ali, size, time, tonly;
3771 char *dn = NULL, **attrs = NULL;
3776 fputs("ERROR ber_init failed\n", stderr);
3780 res = ber_scanf(ber,"{aiiiib{v}",&dn,&scope,&ali,
3781 &size,&time,&tonly,&attrs);
3783 if (res == LBER_ERROR) {
3784 fputs("ERROR ber_scanf failed\n", stderr);
3792 for (i = 0; attrs != NULL && attrs[i] != NULL; i++) {
3793 /* *** use attrs[i] */
3794 ldap_memfree(attrs[i]);
3796 ldap_memfree((char *)attrs);
3798 if (ber_peek_tag(ber,&len) == TAG_CONTROL_LIST) {
3802 for (tag = ber_first_element(ber,&len,&opaque);
3806 Expires: May 2001 [Page 68]
3808 C LDAP API C LDAP Application Program Interface 17 November 2000
3811 tag != LBER_DEFAULT;
3812 tag = ber_next_element (ber,&len,opaque)) {
3818 struct berval *value;
3820 if (ber_scanf(ber,"{a",&type) == LBER_ERROR) {
3821 fputs("ERROR cannot parse type\n", stderr);
3827 ttag = ber_peek_tag(ber,&tlen);
3828 if (ttag == 0x01U) { /* boolean */
3829 if (ber_scanf(ber,"b",
3830 &crit) == LBER_ERROR) {
3831 fputs("ERROR cannot parse crit\n",
3836 } else if (ttag == 0x04U) { /* octet string */
3839 fputs("ERROR extra field in controls\n",
3844 if (ber_scanf(ber,"O}",&value) == LBER_ERROR) {
3845 fputs("ERROR cannot parse value\n", stderr);
3854 if ( rc == 0 ) { /* no errors so far */
3855 if (ber_scanf(ber,"}") == LBER_ERROR) {
3862 Expires: May 2001 [Page 69]
3864 C LDAP API C LDAP Application Program Interface 17 November 2000
3874 18. Security Considerations
3876 LDAPv2 supports security through protocol-level authentication using
3877 clear-text passwords. LDAPv3 adds support for SASL [12] (Simple Authen-
3878 tication Security Layer) methods. LDAPv3 also supports operation over a
3879 secure transport layer using Transport Layer Security TLS [9]. Readers
3880 are referred to the protocol documents for discussion of related secu-
3881 rity considerations.
3883 Implementations of this API SHOULD be cautious when handling authentica-
3884 tion credentials. In particular, keeping long-lived copies of creden-
3885 tials without the application's knowledge is discouraged.
3888 19. Acknowledgements
3890 Many members of the IETF ASID and LDAPEXT working groups as well as
3891 members of the Internet at large have provided useful comments and
3892 suggestions that have been incorporated into this document. Chris
3893 Weider deserves special mention for his contributions as co-author of
3894 earlier revisions of this document.
3896 The original material upon which this specification is based was sup-
3897 ported by the National Science Foundation under Grant No. NCR-9416667.
3902 Copyright (C) The Internet Society (1997-2000). All Rights Reserved.
3904 This document and translations of it may be copied and furnished to oth-
3905 ers, and derivative works that comment on or otherwise explain it or
3906 assist in its implementation may be prepared, copied, published and dis-
3907 tributed, in whole or in part, without restriction of any kind, provided
3908 that the above copyright notice and this paragraph are included on all
3909 such copies and derivative works. However, this document itself may not
3910 be modified in any way, such as by removing the copyright notice or
3911 references to the Internet Society or other Internet organizations,
3912 except as needed for the purpose of developing Internet standards in
3913 which case the procedures for copyrights defined in the Internet Stan-
3914 dards process must be followed, or as required to translate it into
3918 Expires: May 2001 [Page 70]
3920 C LDAP API C LDAP Application Program Interface 17 November 2000
3923 languages other than English.
3925 The limited permissions granted above are perpetual and will not be
3926 revoked by the Internet Society or its successors or assigns.
3928 This document and the information contained herein is provided on an "AS
3929 IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING TASK
3930 FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT
3931 LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT
3932 INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FIT-
3933 NESS FOR A PARTICULAR PURPOSE.
3938 [1] Bradner, S., "Key words for use in RFCs to Indicate Requirement
3939 Levels", RFC 2119, March 1997.
3941 [2] M. Wahl, T. Howes, S. Kille, "Lightweight Directory Access Protocol
3942 (v3)", RFC 2251, December 1997.
3944 [3] M. Wahl, A. Coulbeck, T. Howes, S. Kille, W. Yeong, C. Robbins,
3945 "Lightweight Directory Access Protocol (v3): Attribute Syntax
3946 Definitions", RFC 2252, December 1997.
3948 [4] The Directory: Selected Attribute Syntaxes. CCITT, Recommendation
3951 [5] M. Wahl, S. Kille, T. Howes, "Lightweight Directory Access Protocol
3952 (v3): A UTF-8 String Representation of Distinguished Names", RFC
3953 2253, December 1997.
3955 [6] F. Yergeau, "UTF-8, a transformation format of Unicode and ISO
3956 10646", RFC 2044, October 1996.
3958 [7] K. Simonsen, "Character Mnemonics and Character Sets," RFC 1345,
3961 [8] "Programming Languages - C", ANSI/ISO Standard 9899, revised 1997.
3963 [9] J. Hodges, R. Morgan, M. Wahl, "Lightweight Directory Access Proto-
3964 col (v3): Extension for Transport Layer Security", INTERNET-DRAFT
3965 (work in progress) <draft-ietf-ldapext-ldapv3-tls-05.txt>, June
3968 [10] R. Hinden, S. Deering, "IP Version 6 Addressing Architecture," RFC
3969 1884, December 1995.
3974 Expires: May 2001 [Page 71]
3976 C LDAP API C LDAP Application Program Interface 17 November 2000
3979 [11] A. Herron, T. Howes, M. Wahl, A. Anantha, "LDAP Control Extension
3980 for Server Side Sorting of Search Results", INTERNET-DRAFT (work in
3981 progress) <draft-ietf-ldapext-sorting-02.txt>, 5 April 1999.
3983 [12] J. Meyers, "Simple Authentication and Security Layer (SASL)", RFC
3986 [13] T. Howes, "The String Representation of LDAP Search Filters," RFC
3987 2254, December 1997.
3989 [14] S. Kille, "Using the OSI Directory to Achieve User Friendly Nam-
3990 ing," RFC 1781, March 1995.
3993 22. Authors' Addresses
3995 Mark Smith (document editor)
3996 Netscape Communications Corp.
3998 Palo Alto, CA 94303-4900
3999 Mail Stop SCA17 - 201
4006 599 N. Mathilda Avenue
4018 andyhe@microsoft.com
4021 Sun Microsystems, Inc.
4022 8911 Capital of Texas Hwy, Suite 4140
4030 Expires: May 2001 [Page 72]
4032 C LDAP API C LDAP Application Program Interface 17 November 2000
4041 anoopa@microsoft.com
4044 23. Appendix A - Sample C LDAP API Code
4052 LDAPMessage *res, *e;
4058 /* open an LDAP session */
4059 if ( (ld = ldap_init( "dotted.host.name", LDAP_PORT )) == NULL )
4062 /* authenticate as nobody */
4063 if (( rc = ldap_simple_bind_s( ld, NULL, NULL )) != LDAP_SUCCESS ) {
4064 fprintf( stderr, "ldap_simple_bind_s: %s\n",
4065 ldap_err2string( rc ));
4070 /* search for entries with cn of "Babs Jensen", return all attrs */
4071 if (( rc = ldap_search_s( ld, "o=University of Michigan, c=US",
4072 LDAP_SCOPE_SUBTREE, "(cn=Babs Jensen)", NULL, 0, &res ))
4074 fprintf( stderr, "ldap_search_s: %s\n",
4075 ldap_err2string( rc ));
4076 if ( res == NULL ) {
4082 /* step through each entry returned */
4086 Expires: May 2001 [Page 73]
4088 C LDAP API C LDAP Application Program Interface 17 November 2000
4091 for ( e = ldap_first_entry( ld, res ); e != NULL;
4092 e = ldap_next_entry( ld, e ) ) {
4093 /* print its name */
4094 dn = ldap_get_dn( ld, e );
4095 printf( "dn: %s\n", dn );
4098 /* print each attribute */
4099 for ( a = ldap_first_attribute( ld, e, &ptr ); a != NULL;
4100 a = ldap_next_attribute( ld, e, ptr ) ) {
4101 printf( "\tattribute: %s\n", a );
4103 /* print each value */
4104 vals = ldap_get_values( ld, e, a );
4105 for ( i = 0; vals[i] != NULL; i++ ) {
4106 printf( "\t\tvalue: %s\n", vals[i] );
4108 ldap_value_free( vals );
4111 if ( ptr != NULL ) {
4115 /* free the search results */
4116 ldap_msgfree( res );
4118 /* close and free connection resources */
4125 24. Appendix B - Namespace Consumed By This Specification
4127 The following 2 prefixes are used in this specification to name func-
4132 The following 6 prefixes are used in this specification to name struc-
4133 tures, unions, and typedefs:
4142 Expires: May 2001 [Page 74]
4144 C LDAP API C LDAP Application Program Interface 17 November 2000
4149 The following 3 prefixes are used in this specification to name #defined
4156 25. Appendix C - Summary of Requirements for API Extensions
4158 As the LDAP protocol is extended, this C LDAP API will need to be
4159 extended as well. For example, an LDAPv3 control extension has already
4160 been defined for server-side sorting of search results [7]. This appen-
4161 dix summarizes the requirements for extending this API.
4165 Extensions to this document SHOULD NOT, by default, alter the behavior
4166 of any of the APIs specified in this document. If an extension option-
4167 ally changes the behavior of any existing C LDAP API function calls, the
4168 behavior change MUST be well documented. If an extension that operates
4169 on an LDAP session affects a chain of messages that was previously
4170 obtained by a call to ldap_result() or by calling a synchronous search
4171 routine, this MUST be well documented.
4175 Extensions to this API SHOULD follow the general style and naming con-
4176 ventions used in this document. For example, function names SHOULD
4177 start with "ldap_" or "ber_" and consist entirely of lowercase letters,
4178 digits, and underscore ('_') characters. It is RECOMMENDED that private
4179 and experimental extensions use only the following prefixes for macros,
4180 types, and function names:
4185 and that these prefixes not be used by standard extensions.
4187 25.3. Dependence on Externally Defined Types
4189 Extensions to this API SHOULD minimize dependencies on types and macros
4190 that are defined in system headers and generally use only intrinsic
4191 types that are part of the C language, types defined in this specifica-
4192 tion, or types defined in the extension document itself.
4198 Expires: May 2001 [Page 75]
4200 C LDAP API C LDAP Application Program Interface 17 November 2000
4203 25.4. Compile Time Information
4205 Extensions to this API SHOULD conform to the requirements contained in
4206 the "Retrieving Information at Compile Time" section of this document.
4207 That is, extensions SHOULD define a macro of the form:
4209 #define LDAP_API_FEATURE_x level
4211 so that applications can detect the presence or absence of the extension
4212 at compile time and also test the version or level of the extension pro-
4213 vided by an API implementation.
4215 25.5. Runtime Information
4217 Extensions to this API SHOULD conform to the requirements contained in
4218 the "Retrieving Information During Execution" section of this document.
4219 That is, each extension SHOULD be given a character string name and that
4220 name SHOULD appear in the ldapai_extensions array field of the LDAPAPI-
4221 Info structure following a successful call to ldap_get_option() with an
4222 option parameter value of LDAP_OPT_API_INFO. In addition, information
4223 about the extension SHOULD be available via a call to ldap_get_option()
4224 with an option parameter value of LDAP_OPT_API_FEATURE_INFO.
4226 25.6. Values Used for Session Handle Options
4228 Extensions to this API that add new session options (for use with the
4229 ldap_get_option() and ldap_set_option() functions) SHOULD meet the
4230 requirements contained in the last paragraph of the "LDAP Session Handle
4231 Options" section of this document. Specifically, standards track docu-
4232 ments MUST use values for option macros that are between 0x1000 and
4233 0x3FFF inclusive and private and experimental extensions MUST use values
4234 for the option macros that are between 0x4000 and 0x7FFF inclusive.
4237 26. Appendix D - Known Incompatibilities with RFC 1823
4239 This appendix lists known incompatibilities between this API specifica-
4240 tion and the one contained in RFC 1823, beyond the additional API func-
4241 tions added in support of LDAPv3.
4244 26.1. Opaque LDAP Structure
4246 In RFC 1823, some fields in the LDAP structure were exposed to applica-
4247 tion programmers. To provide a cleaner interface and to make it easier
4248 for implementations to evolve over time without sacrificing binary com-
4249 patibility with older applications, the LDAP structure is now entirely
4250 opaque. The new ldap_set_option() and ldap_get_option() calls can be
4254 Expires: May 2001 [Page 76]
4256 C LDAP API C LDAP Application Program Interface 17 November 2000
4259 used to manipulate per-session and global options.
4262 26.2. Additional Result Codes
4264 The following new result code macros were introduced to support LDAPv3:
4266 LDAP_ADMINLIMIT_EXCEEDED
4267 LDAP_UNAVAILABLE_CRITICAL_EXTENSION
4268 LDAP_CONFIDENTIALITY_REQUIRED
4269 LDAP_SASL_BIND_IN_PROGRESS
4270 LDAP_AFFECTS_MULTIPLE_DSAS
4273 LDAP_CONTROL_NOT_FOUND
4274 LDAP_NO_RESULTS_RETURNED
4275 LDAP_MORE_RESULTS_TO_RETURN
4277 LDAP_REFERRAL_LIMIT_EXCEEDED
4280 26.3. Freeing of String Data with ldap_memfree()
4282 All strings received from the API (e.g., those returned by the
4283 ldap_get_dn() or ldap_dn2ufn() functions) SHOULD be freed by calling
4284 ldap_memfree() not free(). RFC 1823 did not define an ldap_memfree()
4288 26.4. Changes to ldap_result()
4290 The meaning of the all parameter to ldap_result has changed slightly.
4291 Nonzero values from RFC 1823 correspond to LDAP_MSG_ALL (0x01). There
4292 is also a new possible value, LDAP_MSG_RECEIVED (0x02).
4294 The result type LDAP_RES_MODDN is now returned where RFC 1823 returned
4295 LDAP_RES_MODRDN. The actual value for these two macros is the same
4299 26.5. Changes to ldap_first_attribute() and ldap_next_attribute
4301 Each non-NULL return value SHOULD be freed by calling ldap_memfree()
4302 after use. In RFC 1823, these two functions returned a pointer to a
4303 per-session buffer, which was not very thread-friendly.
4305 After the last call to ldap_first_attribute() or ldap_next_attribute(),
4306 the value set in the ptr parameter SHOULD be freed by calling ber_free(
4310 Expires: May 2001 [Page 77]
4312 C LDAP API C LDAP Application Program Interface 17 November 2000
4315 ptr, 0 ). RFC 1823 did not mention that the ptr value SHOULD be freed.
4317 The type of the ptr parameter was changed from void * to BerElement *.
4320 26.6. Changes to ldap_modrdn() and ldap_modrdn_s() Functions
4322 In RFC 1823, the ldap_modrdn() and ldap_modrdn_s() functions include a
4323 parameter called deleteoldrdn. This does not match the great majority
4324 of implementations, so in this specification the deleteoldrdn parameter
4325 was removed from ldap_modrdn() and ldap_modrdn_s(). Two additional
4326 functions that support deleteoldrdn and are widely implemented as well
4327 were added to this specification: ldap_modrdn2() and ldap_modrdn2_s().
4330 26.7. Changes to the berval structure
4332 In RFC 1823, the bv_len element of the berval structure was defined as
4333 an `unsigned long'. In this specification, the type is implementation-
4334 specific, although it MUST be an unsigned integral type that is at least
4335 32 bits in size. See the appendix "Data Types and Legacy Implementa-
4336 tions" for additional considerations.
4339 26.8. API Specification Clarified
4341 RFC 1823 left many things unspecified, including behavior of various
4342 memory disposal functions when a NULL pointer is presented, requirements
4343 for headers, values of many macros, and so on. This specification is
4344 more complete and generally tighter than the one in RFC 1823.
4347 26.9. Deprecated Functions
4349 A number of functions that are in RFC 1823 are labeled as "deprecated"
4350 in this specification. In most cases, a replacement that provides
4351 equivalent functionality has been defined. The deprecated functions
4355 Use ldap_simple_bind() or ldap_sasl_bind() instead.
4358 Use ldap_simple_bind_s() or ldap_sasl_bind_s() instead.
4360 ldap_kerberos_bind() and ldap_kerberos_bind_s()
4361 No equivalent functions are provided.
4366 Expires: May 2001 [Page 78]
4368 C LDAP API C LDAP Application Program Interface 17 November 2000
4371 ldap_modrdn() and ldap_modrdn2()
4372 Use ldap_rename() instead.
4374 ldap_modrdn_s() and ldap_modrdn2_s()
4375 Use ldap_rename_s() instead.
4378 Use ldap_init() instead.
4381 Use ldap_get_option( ld, LDAP_OPT_RESULT_CODE, &rc ) followed
4382 by fprintf( stderr, "%s: %s", msg, ldap_err2string( rc ))
4386 Use ldap_parse_result() instead.
4389 27. Appendix E - Data Types and Legacy Implementations
4391 The data types associated with the length of a ber value (ber_len_t),
4392 and the tag (ber_tag_t) have been defined in this specification as
4393 unsigned integral types of implementation-specific size. The data type
4394 used for encoding and decoding ber integer, enumerated, and boolean
4395 values has been defined in this specification as a signed integral type
4396 of implementation-specific size. This was done so that source and
4397 binary compatibility of the C LDAP API can be maintained across ILP32
4398 environments (where int, long, and pointers are all 32 bits in size) and
4399 LP64 environments (where ints remain 32 bits but longs and pointers grow
4402 In older implementations of the C LDAP API, such as those based on RFC
4403 1823, implementors may have chosen to use an `unsigned long' for length
4404 and tag values. If a long data type was used for either of these items,
4405 a port of an application to a 64-bit operating system using the LP64
4406 data model would find the size of the types used by the C LDAP API to
4407 increase. Also, if the legacy implementation had chosen to implement
4408 the tag and types as an unsigned int, adoption of a specification that
4409 mandated use of unsigned longs would cause a source incompatibility in
4410 an LP64 application. By using implementation-specific data types, the C
4411 LDAP API implementation is free to choose the correct data type and the
4412 ability to maintain source compatibility.
4414 For example, suppose a legacy implementation chose to define the return
4415 value of ber_skip_tag() as an unsigned long but wishes to have the
4416 library return a 32-bit quantity in both ILP32 and LP64 data models.
4417 The following typedefs for ber_tag_t will provide a fixed sized data
4418 structure while preserving existing ILP32 source -- all without
4422 Expires: May 2001 [Page 79]
4424 C LDAP API C LDAP Application Program Interface 17 November 2000
4427 generating compiler warnings:
4428 #include <limits.h> /* provides UINT_MAX in ISO C */
4429 #if UINT_MAX >= 0xffffffffU
4430 typedef unsigned int ber_tag_t;
4432 typedef unsigned long ber_tag_t;
4435 Similar code can be used to define appropriate ber_len_t, ber_int_t,
4436 ber_slen_t and ber_uint_t types.
4439 28. Appendix F - Changes Made Since Last Document Revision
4441 The previous version of this document was draft-ietf-ldapext-ldap-c-
4442 api-04.txt, dated 8 October 1999. This appendix lists all of the
4443 changes made to that document to produce this one.
4447 "Header Requirements" section: added requirement that the simple pro-
4448 gram provided must execute as well as compile without errors.
4450 "LDAP Session Handle Options" section: changed the name of the
4451 LDAP_OPT_ERROR_NUMBER option to LDAP_OPT_RESULT_CODE. Allow
4452 LDAP_OPT_ON to be defined as an implementation specific value (to
4453 avoid problems on architectures where the value ((void *)1) is not
4456 "Initializing an LDAP Session" section: allow use of the value zero
4457 for the `portno' parameter to mean "use port 389."
4459 "Searching" section: added LDAP_DEFAULT_SIZELIMIT (-1) to allow
4460 application programmers to use the sizelimit from the LDAP session
4461 handle with ldap_search_ext() and ldap_search_ext_s().
4463 "Modifying an entry" section: moved mod_vals union out of LDAPMod and
4464 added mod_vals_u_t typedef so users of the API can declare variables
4465 using the union type. "Handling Errors and Parsing Results" section:
4466 added text to require that ldap_err2string() MUST NOT return NULL.
4468 "A Client Control That Governs Referral Processing" section: modified
4469 the text to specify that a ber_uint_t value should be used to hold
4478 Expires: May 2001 [Page 80]
4480 C LDAP API C LDAP Application Program Interface 17 November 2000
4483 28.2. Editorial Changes and Clarifications
4485 "Overview of LDAP API Use and General Requirements" section: added
4486 text to clarify our use of the term "asynchronous."
4488 "Retrieving Information During Execution" section: added text
4489 describing the `ldapai_vendor_name' and `ldapai_vendor_version'
4490 fields (text was accidently deleted during a previous round of
4493 "LDAP Session Handle Options" section: improved the text that
4494 describes the LDAP_OPT_TIMELIMIT, LDAP_OPT_SIZELIMIT, and
4495 LDAP_OPT_RESULT_CODE options. Provided details and an example of the
4496 correct LDAP_OPT_HOST_NAME string to return when the `portno' passed
4497 to ldap_init() is not zero or 389.
4499 "Result Codes" section: renamed section (was "LDAP Error Codes").
4501 "Authenticating to the directory" section: clarified that the `dn',
4502 `cred', and `passwd' parameters can be NULL. Added text indicate
4503 that the `servercredp' is set to NULL if an API error occurs.
4505 "Performing LDAP Operations" section: replaced "All functions take a
4506 session handle" with "Most functions...."
4508 "Search" section: removed the detailed discussion of the session han-
4509 dle options (already covered in the "Retrieving Information During
4510 Execution" section). Also removed the word "global" when discussing
4511 the session default value for the `timeout' parameter. Also clari-
4512 fied that a NULL `base' parameter means use a zero-length string for
4515 "Comparing a Value Against an Entry" section: corrected the "success-
4516 ful" return codes for ldap_compare_ext_s() and ldap_compare_s() (was
4517 LDAP_SUCCESS; changed to LDAP_COMPARE_TRUE or LDAP_COMPARE_FALSE).
4519 "Extended Operations" section: added text to indicate that the
4520 `retoidp' and `retdatap' result parameters are set to NULL if an API
4521 error occurs in ldap_extended_operation_s().
4523 "Handling Errors and Parsing Results" section: added text to say that
4524 the `matcheddnp' result parameter will be set to NULL if the server
4525 does not return a matched DN string. Added text to indicate that
4526 serverctrlsp can be NULL. Added text to indicate that *retoidpp,
4527 *retdatap, *referralsp, and *serverctrlsp will be set to NULL if no
4528 items of that type are returned. Removed specific reference to
4529 LDAP_NO_SUCH_OBJECT result code when discussing the `matcheddnp'
4530 result parameter and added clarifying note about "" vs. NULL.
4534 Expires: May 2001 [Page 81]
4536 C LDAP API C LDAP Application Program Interface 17 November 2000
4539 "Parsing References" section: added text to indicate that *refer-
4540 ralsp, and *serverctrlsp will be set to NULL if no items of that type
4543 "Obtaining Results and Peeking Inside LDAP Messages" section: added
4544 text to say that LDAPMessage chains MAY be tied to a session handle.
4546 "BER Data Structures and Types" section: removed note about
4547 ber_uint_t not being used in this document (it is now). Changed text
4548 to simplify the description of ber_slen_t. Removed misleading sen-
4549 tence about the width of ber_uint_t.
4551 "Encoded ASN.1 Value Manipulation / Encoding" section: added note
4552 that 'X' is reserved. Also fixed a few small bugs in the example
4555 "Encoded ASN.1 Value Manipulation / Decoding" section: clarified the
4556 requirements for LBER_ERROR and LBER_DEFAULT (expressed using octets
4557 instead of bits). Also fixed a few small bugs in the example code.
4559 Added the following text to all descriptions of the `serverctrls' and
4560 `clientctrls' parameters: ", or NULL if no <server/client> controls
4563 Added the following text to the description of all `dn' and `rdn'
4564 parameters: "If NULL, a zero length DN is sent to the server."
4566 Replaced many occurrences of the phrase "error code" with "result
4567 code" throughout the document.
4569 Added text to indicate that the value of the `msgidp' result parame-
4570 ter is undefined if an error occurs in the following functions:
4571 ldap_sasl_bind(), ldap_search_ext(), ldap_compare_ext(),
4572 ldap_modify_ext(), ldap_add_ext(), ldap_delete_ext(),
4573 ldap_extended_operation().
4575 Added text to indicate that the `res' result parameter is set to NULL
4576 if an API error occurs in the following functions: ldap_result(),
4577 ldap_search_s(), ldap_search_st().
4579 Added text to indicate that all result parameters have undefined
4580 values if an API error is returned by the following functions:
4581 ldap_parse_result(), ldap_parse_sasl_bind_result(),
4582 ldap_parse_extended_result(), ldap_parse_reference(), ber_scanf().
4584 Added angle brackets around ficticious impl_XXX_t types to make it
4585 more obvious that these are not real "C" types, e.g., typedef
4586 <impl_len_t> ber_len_t'.
4590 Expires: May 2001 [Page 82]
4592 C LDAP API C LDAP Application Program Interface 17 November 2000
4595 Appendix B: Added mod_vals_u and removed PLDAP from the struct,
4596 unions, and typedefs prefix list.
4598 Appendix C: Added note in "Compatibility" section about extensions
4599 possible affecting chains of messages and the fact that that must be
4600 well documented. Appendix D: Improved text for ldap_perror() (what
4603 "Authors" section: updated contact information for Mark Smith, Tim
4604 Howes, and Mark Wahl.
4606 Fixed a few obvious typos, improved indentation, added missing blank
4646 Expires: May 2001 [Page 83]