Apache Portable Runtime
Loading...
Searching...
No Matches
apr_ldap.h
Go to the documentation of this file.
1/* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/**
18 * @file apr_ldap.h
19 * @brief APR-UTIL LDAP routines
20 */
21#ifndef APU_LDAP_H
22#define APU_LDAP_H
23
24/**
25 * @defgroup APR_Util_LDAP LDAP routines
26 *
27 * The APR LDAP routines provide a common, cross platform, ability to connect
28 * to and search an LDAP server.
29 *
30 * The goals of the API are:
31 *
32 * - Work within the functionality of APR pools. Requests from different pools
33 * can make LDAP requests of a common connection, and when the connection
34 * pool or the request pool goes away, the connection and/or LDAP requests
35 * are cleaned up gracefully.
36 *
37 * - Offer an asynchronous API that can be used for non blocking access to an
38 * LDAP server. The responses APR_WANT_READ and APR_WANT_WRITE make it clear
39 * whether the API wants to read or write to the LDAP server in the next API
40 * call.
41 *
42 * - Be as simple as possible. Data is returned fully processed in callbacks,
43 * removing the need for API calls to access data, and intermediate data
44 * structures.
45 *
46 * In typical use, the following calls are used:
47 *
48 * - apr_ldap_initialise() - create a handle to keep track of a connection.
49 * - apr_ldap_option_set() - set the URL, or the socket descriptor for the
50 * connextion to the server.
51 * - apr_ldap_connect() - if an URL was specified, connect to the server and
52 * confirm success.
53 * - apr_ldap_bind() - initiate a bind, and specify a callback when done.
54 *
55 * Enter the event loop, where we do the following until the connection is
56 * closed.
57 *
58 * - apr_ldap_process() - when writable, perform tasks that require writing to
59 * the LDAP server.
60 * - apr_ldap_result() - when readable, perform tasks that require reading from
61 * the LDAP server.
62 *
63 * Respond appropriately to callbacks, lining up calls to apr_ldap_compare() and
64 * apr_ldap_search() as needed.
65 *
66 * @ingroup APR
67 * @{
68 */
69
70#include "apr.h"
71
72/*
73 * Handle the case when LDAP is enabled
74 */
75#if APR_HAS_LDAP || defined(DOXYGEN)
76
77#include "apu.h"
78#include "apr_poll.h"
79#include "apr_pools.h"
80#include "apr_network_io.h"
81#include "apu_errno.h"
82#include "apr_escape.h"
83#include "apr_buffer.h"
84#include "apr_hash.h"
85
86/*
87 * LDAP URL handling
88 */
89
90/**
91 * Individual fields accessible within an LDAP URL.
92 * @see apr_ldap_url_parse */
93typedef struct apr_ldap_url_desc_t {
94 /** Next URL in a sequence of URLs */
96 /** URL scheme (ldap, ldaps, ldapi) */
98 /** Host part of the URL */
99 char *lud_host;
100 /** Port, if appropriate */
102 /** Base distinguished name of the search */
103 char *lud_dn;
104 /** Attributes to be returned during a search */
105 char **lud_attrs;
106 /** Scope of the search */
108 /** Search filter */
110 /** Extensions */
111 char **lud_exts;
112 /** Critical extensions */
115
116#ifndef APR_LDAP_URL_SUCCESS
117/**
118 * URL was successfully parsed.
119 * @see apr_ldap_url_parse()
120 */
121#define APR_LDAP_URL_SUCCESS 0x00
122/**
123 * Can't allocate memory space
124 * @see apr_ldap_url_parse()
125 */
126#define APR_LDAP_URL_ERR_MEM 0x01
127/**
128 * Parameter is bad
129 * @see apr_ldap_url_parse()
130 */
131#define APR_LDAP_URL_ERR_PARAM 0x02
132/**
133 * URL doesn't begin with "ldap[si]://"
134 * @see apr_ldap_url_parse()
135 */
136#define APR_LDAP_URL_ERR_BADSCHEME 0x03
137/**
138 * URL is missing trailing ">"
139 * @see apr_ldap_url_parse()
140 */
141#define APR_LDAP_URL_ERR_BADENCLOSURE 0x04
142/**
143 * URL is bad
144 * @see apr_ldap_url_parse()
145 */
146#define APR_LDAP_URL_ERR_BADURL 0x05
147/**
148 * Host port is bad
149 * @see apr_ldap_url_parse()
150 */
151#define APR_LDAP_URL_ERR_BADHOST 0x06
152/**
153 * Bad (or missing) attributes
154 * @see apr_ldap_url_parse()
155 */
156#define APR_LDAP_URL_ERR_BADATTRS 0x07
157/**
158 * Scope string is invalid (or missing)
159 * @see apr_ldap_url_parse()
160 */
161#define APR_LDAP_URL_ERR_BADSCOPE 0x08
162/**
163 * Bad or missing filter
164 * @see apr_ldap_url_parse()
165 */
166#define APR_LDAP_URL_ERR_BADFILTER 0x09
167/**
168 * Bad or missing extensions
169 * @see apr_ldap_url_parse()
170 */
171#define APR_LDAP_URL_ERR_BADEXTS 0x0a
172#endif
173
174/**
175 * Is this URL an ldap url? ldap://
176 * @param url The url to test
177 */
178APR_DECLARE(int) apr_ldap_is_ldap_url(const char *url);
179
180/**
181 * Is this URL an SSL ldap url? ldaps://
182 * @param url The url to test
183 */
184APR_DECLARE(int) apr_ldap_is_ldaps_url(const char *url);
185
186/**
187 * Is this URL an ldap socket url? ldapi://
188 * @param url The url to test
189 */
190APR_DECLARE(int) apr_ldap_is_ldapi_url(const char *url);
191
192/**
193 * Parse an LDAP URL.
194 * @param pool The pool to use
195 * @param url_in The URL to parse
196 * @param ludpp The structure to return the exploded URL
197 * @param result_err The result structure of the operation
198 */
200 const char *url_in,
201 apr_ldap_url_desc_t **ludpp,
202 apu_err_t **result_err);
203
204/**
205 * Parse an LDAP URL.
206 * @param pool The pool to use
207 * @param url_in The URL to parse
208 * @param ludpp The structure to return the exploded URL
209 * @param result_err The result structure of the operation
210 */
212 const char *url_in,
213 apr_ldap_url_desc_t **ludpp,
214 apu_err_t **result_err);
215
216
217
218
219
220
221
222
223
224/* These symbols are not actually exported in a DSO build, but mapped into
225 * a private exported function array for apr_ldap_stub to bind dynamically.
226 * Rename them appropriately to protect the global namespace.
227 */
228#if defined(APU_DSO_LDAP_BUILD)
229
230#define apr_ldap_info apr__ldap_info
231#define apr_ldap_initialise apr__ldap_initialise
232#define apr_ldap_option_get apr__ldap_option_get
233#define apr_ldap_option_set apr__ldap_option_set
234#define apr_ldap_connect apr__ldap_connect
235#define apr_ldap_prepare apr__ldap_prepare
236#define apr_ldap_process apr__ldap_process
237#define apr_ldap_result apr__ldap_result
238#define apr_ldap_poll apr__ldap_poll
239#define apr_ldap_bind apr__ldap_bind
240#define apr_ldap_compare apr__ldap_compare
241#define apr_ldap_search apr__ldap_search
242#define apr_ldap_add apr__ldap_add
243#define apr_ldap_modify apr__ldap_modify
244#define apr_ldap_delete apr__ldap_delete
245#define apr_ldap_rename apr__ldap_rename
246#define apr_ldap_extended apr__ldap_extended
247#define apr_ldap_unbind apr__ldap_unbind
248
249#define APU_DECLARE_LDAP(type) type
250#else
251/** @see APR_DECLARE */
252#define APU_DECLARE_LDAP(type) APR_DECLARE(type)
253#endif
254
255/**
256 * Opaque structure representing the LDAP driver.
257 * @see apr_ldap_get_driver
258 */
260
261
262/** apr_ldap_get_driver: get the driver struct for a name
263 *
264 * The LDAP driver is unique in that LDAP libraries are almost exclusively
265 * derived from RFC1823 "The LDAP Application Program Interface".
266 *
267 * As a result, unlike other drivers for other subsystems in APR, two
268 * different drivers cannot be loaded at once, as the underlying libraries
269 * share common symbols with one another.
270 *
271 * For this reason we have exactly one driver available at a time.
272 *
273 * This function loads the library, and registers a cleanup with the pool
274 * provided to unload the library.
275 *
276 * This function can be called multiple times by independent code, cleanups
277 * are reference counted so the last pool cleanup unloads the library.
278 *
279 * Calling this function explicitly is optional, and would be done to have
280 * complete control over the lifetime of the driver.
281 *
282 * If this function is not called explicitly, this function will be called
283 * if needed before the apr_ldap_info(), apr_ldap_initialise(),
284 * apr_ldap_option_get(), and apr_ldap_option_set() functions,
285 * registering cleanups in the pools provided to those functions if needed.
286 *
287 * @param pool (process) pool to register cleanup that will unload the
288 * library. Cleanup is reference counted so the driver is
289 * unloaded on last access.
290 * @param driver Pointer to driver struct. Can be NULL.
291 * @param err Human readable error messages
292 * @return APR_SUCCESS for success
293 * @return APR_ENOTIMPL for no driver (when DSO not enabled)
294 * @return APR_EDSOOPEN if DSO driver file can't be opened
295 * @return APR_ESYMNOTFOUND if the driver file doesn't contain a driver
296 */
298 const apr_ldap_driver_t **driver,
299 apu_err_t *err)
300 __attribute__((nonnull(1,3)));
301
302
303
304/**
305 * Opaque structure tracking the state of an LDAP connection.
306 *
307 * @see apr_ldap_initialise
308 */
309typedef struct apr_ldap_t apr_ldap_t;
310
311
312/**
313 * APR LDAP info function
314 *
315 * This function returns a string describing the LDAP toolkit
316 * currently in use. The string is placed inside result_err->reason.
317 * @param pool The pool to use
318 * @param result_err The returned result
319 */
321 apu_err_t **result_err)
322 __attribute__((nonnull(1,2)));
323
324
325
326/**
327 * Ports used by LDAP.
328 */
329/** ldap:/// default LDAP port */
330#define APR_LDAP_PORT 389
331/** ldaps:/// default LDAP over TLS port */
332#define APR_LDAPS_PORT 636
333
334
335/**
336 * APR LDAP initialise function
337 *
338 * This function is responsible for initialising an LDAP
339 * connection in a toolkit independant way. It does the
340 * job of ldap_initialize() from the C api.
341 *
342 * The setting of the LDAP server to connect is made after
343 * this function returns, using the apr_ldap_option_set()
344 * call with APR_LDAP_OPT_DESC or APR_LDAP_OPT_URI.
345 *
346 * A cleanup for the connection is registered in the given pool.
347 *
348 * @param pool The pool to use
349 * @param ldap The ldap context returned
350 * @param err On error, error details are written to the
351 * structure.
352 * @see apr_ldap_option_set
353 * @see APR_LDAP_OPT_DESC
354 * @see APR_LDAP_OPT_URI
355 */
357 apr_ldap_t **ldap,
358 apu_err_t *err)
359 __attribute__((nonnull(1,2,3)));
360
361
362/*
363 * LDAP options.
364 */
365
366/**
367 * Structure returned by passing APR_LDAP_OPT_API_INFO to
368 * apr_ldap_option_get().
369 *
370 * Use to return information about the underlying LDAP API.
371 *
372 * @see apr_ldap_option_get
373 * @see APR_LDAP_OPT_API_INFO
374 */
375typedef struct apr_ldap_apiinfo_t {
376 /** revision of API supported */
378 /** highest LDAP version supported */
380 /** names of API extensions */
381 const char **extensions;
382 /** name of supplier */
383 const char *vendor_name;
384 /** supplier-specific version * 100 */
387
388
389/**
390 * Structure returned by passing APR_LDAP_OPT_API_FEATURE_INFO to
391 * apr_ldap_option_get().
392 *
393 * Use to return details of extensions supported by the underlying API.
394 *
395 * @see apr_ldap_option_get
396 * @see APR_LDAP_OPT_API_FEATURE_INFO
397 */
399 /** LDAP_API_FEATURE_* (less prefix) */
400 const char *name;
401 /** value of LDAP_API_FEATURE_... */
404
405/**
406 * LDAP Protocol Versions.
407 *
408 * @see apr_ldap_option_set
409 * @see APR_LDAP_OPT_PROTOCOL_VERSION
410 */
411typedef enum {
412 /** LDAP version 1 */
414 /** LDAP version 2 */
416 /** LDAP version 3 */
419
420/**
421 * LDAP debug settings
422 *
423 * @see apr_ldap_option_get
424 * @see apr_ldap_option_set
425 * @see APR_LDAP_OPT_DEBUG_LEVEL
426 */
427typedef enum {
428 /** LDAP trace debug */
430 /** LDAP packet debug */
432 /** LDAP arguments debug */
434 /** LDAP connections debug */
436 /** LDAP BER debug */
438 /** LDAP filter debug */
440 /** LDAP configuration debug */
442 /** LDAP acl debug */
444 /** LDAP statistics debug */
446 /** LDAP more statistics debug */
448 /** LDAP shell debug */
450 /** LDAP parse debug */
452 /** LDAP synchronise debug */
454 /** LDAP no debug */
456 /** LDAP all debug */
457 LDAP_DEBUG_ANY = (-1)
459
460/**
461 * LDAP deref settings
462 *
463 * @see apr_ldap_option_set
464 * @see APR_LDAP_OPT_DEREF
465 */
466typedef enum {
467 APR_LDAP_DEREF_NEVER = 0, /**< Aliases should never be dereferenced */
468 APR_LDAP_DEREF_SEARCHING = 1, /**< Aliases should be dereferenced during the search, but not when locating the base object of the search. */
469 APR_LDAP_DEREF_FINDING = 2, /**< Aliases should be dereferenced when locating the base object, but not during the search. */
470 APR_LDAP_DEREF_ALWAYS = 3 /**< Aliases should always be dereferenced */
472
473/**
474 * LDAP options on or off
475 *
476 * @see apr_ldap_option_set
477 * @see APR_LDAP_OPT_REFERRALS
478 */
479typedef enum {
480 APR_LDAP_OPT_OFF = 0, /**< Option set off */
481 APR_LDAP_OPT_ON = 1 /**< Option set on */
483
484
485/**
486 * Set SSL mode to one of APR_LDAP_NONE, APR_LDAP_SSL, APR_LDAP_STARTTLS
487 * or APR_LDAP_STOPTLS.
488 * @see apr_ldap_option_set
489 * @see apr_ldap_option_get
490 * @see apr_ldap_tls_e
491 */
492#define APR_LDAP_OPT_TLS 0x6fff
493/**
494 * Set zero or more CA certificates, client certificates or private
495 * keys globally, or per connection (where supported).
496 *
497 * @see apr_ldap_option_set
498 * @see apr_ldap_opt_tls_cert_t
499 */
500#define APR_LDAP_OPT_TLS_CERT 0x6ffe
501/**
502 * Set the LDAP library to not verify the server certificate. This means
503 * all servers are considered trusted.
504 * @see apr_ldap_option_set
505 * @see apr_ldap_verify_e
506 */
507#define APR_LDAP_OPT_VERIFY_CERT 0x6ffd
508/**
509 * Set the LDAP library to indicate if referrals should be chased during
510 * LDAP searches.
511 * @see apr_ldap_option_get
512 * @see apr_ldap_option_set
513 * @see apr_ldap_switch_e
514 */
515#define APR_LDAP_OPT_REFERRALS 0x6ffc
516/**
517 * Set the LDAP library to indicate a maximum number of referral hops to
518 * chase before giving up on the search.
519 * @see apr_ldap_option_get
520 * @see apr_ldap_option_set
521 */
522#define APR_LDAP_OPT_REFHOPLIMIT 0x6ffb
523/**
524 * Get the underlying native LDAP handle.
525 * @see apr_ldap_option_get
526 */
527#define APR_LDAP_OPT_HANDLE 0x6ffa
528/**
529 * Get/Set the LDAP protocol version.
530 * @see apr_ldap_option_get
531 * @see apr_ldap_option_set
532 * @see apr_ldap_protocol_version_e
533 */
534#define APR_LDAP_OPT_PROTOCOL_VERSION 0x6ff9
535/**
536 * Get the LDAP API info.
537 * @see apr_ldap_option_get
538 * @see apr_ldap_apiinfo_t
539 */
540#define APR_LDAP_OPT_API_INFO 0x6ff8
541/**
542 * Get the LDAP API feature info.
543 * @see apr_ldap_option_get
544 * @see apr_ldap_apifeature_info_t
545 */
546#define APR_LDAP_OPT_API_FEATURE_INFO 0x6ff7
547/**
548 * Get or set the debug level.
549 * @see apr_ldap_option_get
550 * @see apr_ldap_option_set
551 * @see apr_ldap_debug_e
552 */
553#define APR_LDAP_OPT_DEBUG_LEVEL 0x5001
554/**
555 * Get the dereference setting.
556 * @see apr_ldap_option_get
557 * @see apr_ldap_option_set
558 * @see apr_ldap_deref_e
559 */
560#define APR_LDAP_OPT_DEREF 0x6ff6
561/**
562 * Get the most recent result code.
563 * @see apr_ldap_option_get
564 */
565#define APR_LDAP_OPT_RESULT_CODE 0x6ff5
566/**
567 * Get or set the underlying socket.
568 *
569 * Use this to get the underlying socket so as to perform select/poll
570 * before attempting to read or write.
571 *
572 * Note that LDAP libraries like OpenLDAP will successfully return an
573 * invalid socket if a previous attempt to connect failed. In this
574 * case, you will obtain an error the next time you use the socket.
575 *
576 * This option can also be used to set the underlying socket, as an
577 * alternative to specifying a URI. This is typically done to perform
578 * non blocking DNS lookups, or non blocking TLS negotiation, neither
579 * of which is supported natively by LDAP APIs.
580 *
581 * @warning Either APR_LDAP_OPT_DESC or APR_LDAP_OPT_URI must be set
582 * before any other options are set, for the LDAP handle to be
583 * initialised internally.
584 * @see apr_ldap_option_get
585 * @see apr_ldap_option_set
586 * @see apr_socket_t
587 */
588#define APR_LDAP_OPT_DESC 0x6ff4
589/**
590 * Set the URI to connect to.
591 *
592 * @warning This option (or APR_LDAP_OPT_DESC) must be set before other options,
593 * as this initialises the underlying LDAP API.
594 * @see apr_ldap_option_set
595 */
596#define APR_LDAP_OPT_URI 0x5006
597/**
598 * Get/set the network timeout.
599 * @see apr_ldap_option_get
600 * @see apr_ldap_option_set
601 */
602#define APR_LDAP_OPT_NETWORK_TIMEOUT 0x5005
603/**
604 * Get/set the timeout.
605 * @see apr_ldap_option_get
606 * @see apr_ldap_option_set
607 */
608#define APR_LDAP_OPT_TIMEOUT 0x5002
609
610/**
611 * CA certificate type unknown
612 * @see APR_LDAP_OPT_TLS_CERT
613 * @see apr_ldap_opt_tls_cert_t
614 */
615#define APR_LDAP_CA_TYPE_UNKNOWN 0
616/**
617 * Binary DER encoded CA certificate
618 * @see APR_LDAP_OPT_TLS_CERT
619 * @see apr_ldap_opt_tls_cert_t
620 */
621#define APR_LDAP_CA_TYPE_DER 1
622/**
623 * PEM encoded CA certificate
624 * @see APR_LDAP_OPT_TLS_CERT
625 * @see apr_ldap_opt_tls_cert_t
626 */
627#define APR_LDAP_CA_TYPE_BASE64 2
628/**
629 * Openldap directory full of base64-encoded cert
630 * authorities with hashes in corresponding .0 directory
631 * @see APR_LDAP_OPT_TLS_CERT
632 * @see apr_ldap_opt_tls_cert_t
633 */
634#define APR_LDAP_CA_TYPE_CACERTDIR_BASE64 15
635/**
636 * CA Certificate at the given URI
637 * @see APR_LDAP_OPT_TLS_CERT
638 * @see apr_ldap_opt_tls_cert_t
639 */
640#define APR_LDAP_CA_TYPE_URI 18
641/**
642 * Client certificate type unknown
643 * @see APR_LDAP_OPT_TLS_CERT
644 * @see apr_ldap_opt_tls_cert_t
645 */
646#define APR_LDAP_CERT_TYPE_UNKNOWN 5
647/**
648 * Binary DER encoded client certificate
649 * @see APR_LDAP_OPT_TLS_CERT
650 * @see apr_ldap_opt_tls_cert_t
651 */
652#define APR_LDAP_CERT_TYPE_DER 6
653/**
654 * PEM encoded client certificate
655 * @see APR_LDAP_OPT_TLS_CERT
656 * @see apr_ldap_opt_tls_cert_t
657 */
658#define APR_LDAP_CERT_TYPE_BASE64 7
659/**
660 * PKCS#12 encoded client certificate
661 * @see APR_LDAP_OPT_TLS_CERT
662 * @see apr_ldap_opt_tls_cert_t
663 */
664#define APR_LDAP_CERT_TYPE_PFX 13
665/**
666 * Certificate at the given URI
667 * @see APR_LDAP_OPT_TLS_CERT
668 * @see apr_ldap_opt_tls_cert_t
669 */
670#define APR_LDAP_CERT_TYPE_URI 16
671/**
672 * Private key type unknown
673 * @see APR_LDAP_OPT_TLS_CERT
674 * @see apr_ldap_opt_tls_cert_t
675 */
676#define APR_LDAP_KEY_TYPE_UNKNOWN 10
677/**
678 * Binary DER encoded private key
679 * @see APR_LDAP_OPT_TLS_CERT
680 * @see apr_ldap_opt_tls_cert_t
681 */
682#define APR_LDAP_KEY_TYPE_DER 11
683/**
684 * PEM encoded private key
685 * @see APR_LDAP_OPT_TLS_CERT
686 * @see apr_ldap_opt_tls_cert_t
687 */
688#define APR_LDAP_KEY_TYPE_BASE64 12
689/**
690 * PKCS#12 encoded private key
691 * @see APR_LDAP_OPT_TLS_CERT
692 * @see apr_ldap_opt_tls_cert_t
693 */
694#define APR_LDAP_KEY_TYPE_PFX 14
695/**
696 * Private key at the given URI
697 * @see APR_LDAP_OPT_TLS_CERT
698 * @see apr_ldap_opt_tls_cert_t
699 */
700#define APR_LDAP_KEY_TYPE_URI 17
701
702
703
704/**
705 * Certificate structure.
706 *
707 * This structure is used to store certificate details. An array of
708 * these structures is passed to apr_ldap_option_set() with the option
709 * APR_LDAP_OPT_TLS_CERT to set CA and client certificates.
710 *
711 * @see apr_ldap_option_set
712 * @see APR_LDAP_OPT_TLS_CERT
713 */
715 /** Type of certificate APR_LDAP_*_TYPE_* */
716 int type;
717 /** Path, file, uri or nickname of the certificate */
718 const char *path;
719 /** Optional password, can be NULL */
720 const char *password;
722
723
724/**
725 * APR_LDAP_OPT_TLS
726 *
727 * This sets the SSL level on the LDAP handle.
728 *
729 * @see APR_LDAP_OPT_TLS
730 * @see apr_ldap_option_set
731 */
732typedef enum {
733 APR_LDAP_TLS_NONE = 0, /**< No encryption */
734 APR_LDAP_TLS_SSL = 1, /**< SSL encryption (ldaps://) */
735 APR_LDAP_TLS_STARTTLS = 2, /**< TLS encryption (STARTTLS) */
736 APR_LDAP_TLS_STOPTLS = 3 /**< end TLS encryption (STOPTLS) */
738
739
740/**
741 * LDAP TLS verify options
742 *
743 * @see APR_LDAP_OPT_VERIFY_CERT
744 * @see apr_ldap_option_set
745 */
746typedef enum {
747 /** Disable TLS verification (this is an insecure setting) */
749 /** Enable TLS verification */
752
753
754/**
755 * Union of all possible options to be passed to apr_ldap_option_get()
756 * and apr_ldap_option_set().
757 *
758 * @see apr_ldap_option_set
759 * @see apr_ldap_option_get
760 */
761typedef union apr_ldap_opt_t {
762 /**
763 * LDAP native handle
764 * @see APR_LDAP_OPT_HANDLE
765 */
766 void *handle;
767 /**
768 * LDAP native option
769 */
770 void *opt;
771 /**
772 * LDAP underlying socket
773 *
774 * @see APR_LDAP_OPT_DESC
775 */
777 /**
778 * LDAP uri
779 *
780 * @see APR_LDAP_OPT_URI
781 */
782 const char *uri;
783 /**
784 * LDAP API information
785 *
786 * @see APR_LDAP_OPT_API_INFO
787 */
789 /**
790 * LDAP API feature information
791 *
792 * @see APR_LDAP_OPT_API_FEATURE_INFO
793 */
795 /**
796 * Protocol version
797 *
798 * @see APR_LDAP_OPT_PROTOCOL_VERSION
799 */
801 /**
802 * TLS certificates
803 *
804 * @see APR_LDAP_OPT_TLS_CERT
805 */
807 /**
808 * Timeouts
809 *
810 * @see APR_LDAP_OPT_NETWORK_TIMEOUT
811 * @see APR_LDAP_OPT_TIMEOUT
812 */
814 /**
815 * TLS on/off/starttls
816 *
817 * @see APR_LDAP_OPT_TLS
818 */
820 /**
821 * TLS verification
822 *
823 * @see APR_LDAP_OPT_VERIFY_CERT
824 */
826 /**
827 * Alias dereference
828 *
829 * @see APR_LDAP_OPT_DEREF
830 */
832 /**
833 * Referrals chased
834 *
835 * @see APR_LDAP_OPT_REFERRALS
836 */
838 /**
839 * Referral hop limit
840 *
841 * @see APR_LDAP_OPT_REFHOPLIMIT
842 */
844 /**
845 * Result code
846 *
847 * @see APR_LDAP_OPT_RESULT_CODE
848 */
850 /**
851 * Debug level
852 *
853 * @see APR_LDAP_OPT_DEBUG_LEVEL
854 */
857
858
859/**
860 * APR LDAP get option function
861 *
862 * This function gets option values from a given LDAP session if
863 * one was specified. It maps to the native ldap_get_option() function.
864 * @param pool The pool to use where needed
865 * @param ldap The LDAP handle
866 * @param option The LDAP_OPT_* option to return
867 * @param outvalue The value returned (if any)
868 * @param result_err On error, error details are written to the
869 * structure.
870 * @see APR_LDAP_OPT_API_FEATURE_INFO
871 * @see APR_LDAP_OPT_API_INFO
872 * @see APR_LDAP_OPT_DEBUG_LEVEL
873 * @see APR_LDAP_OPT_DEREF
874 * @see APR_LDAP_OPT_DESC
875 * @see APR_LDAP_OPT_HANDLE
876 * @see APR_LDAP_OPT_NETWORK_TIMEOUT
877 * @see APR_LDAP_OPT_PROTOCOL_VERSION
878 * @see APR_LDAP_OPT_REFERRALS
879 * @see APR_LDAP_OPT_REFHOPLIMIT
880 * @see APR_LDAP_OPT_RESULT_CODE
881 * @see APR_LDAP_OPT_TIMEOUT
882 */
884 int option,
885 apr_ldap_opt_t *outvalue,
886 apu_err_t *result_err)
887 __attribute__((nonnull(1,4,5)));
888
889/**
890 * APR LDAP set option function
891 *
892 * This function sets option values to a given LDAP session if
893 * one was specified. It maps to the native ldap_set_option() function.
894 *
895 * Where an option is not supported by an LDAP toolkit, this function
896 * will try and apply legacy functions to achieve the same effect,
897 * depending on the platform.
898 * @param pool The pool to use where needed
899 * @param ldap The LDAP handle
900 * @param option The LDAP_OPT_* option to set
901 * @param invalue The value to set
902 * @param result_err On error, error details are written to the
903 * structure.
904 * @see APR_LDAP_OPT_DEBUG_LEVEL
905 * @see APR_LDAP_OPT_DEREF
906 * @see APR_LDAP_OPT_DESC
907 * @see APR_LDAP_OPT_NETWORK_TIMEOUT
908 * @see APR_LDAP_OPT_PROTOCOL_VERSION
909 * @see APR_LDAP_OPT_REFERRALS
910 * @see APR_LDAP_OPT_REFHOPLIMIT
911 * @see APR_LDAP_OPT_TIMEOUT
912 * @see APR_LDAP_OPT_TLS
913 * @see APR_LDAP_OPT_TLS_CERT
914 * @see APR_LDAP_OPT_URI
915 * @see APR_LDAP_OPT_VERIFY_CERT
916 */
918 int option,
919 const apr_ldap_opt_t *invalue,
920 apu_err_t *result_err)
921 __attribute__((nonnull(1,5)));
922
923
924/**
925 * LDAP control types.
926 *
927 * This enumeration represents the controls processed by
928 * the library.
929 *
930 * Most controls are simple, consisting of an OID and a
931 * binary or text value. These controls need no special
932 * processing.
933 *
934 * Some controls have values consisting of BER structures.
935 * For convenience, three such controls are understood by
936 * the library, paged control, sort control, and the vlv
937 * control.
938 *
939 * Controls not specifically recognised can be created
940 * using APR_LDAP_CONTROL_OID and the binary control value,
941 * and will be parsed to APR_LDAP_CONTROL_OID and the binary
942 * control value.
943 */
944typedef enum {
945 /** Control specified by OID */
947 /** Sort request control RFC 2891 */
949 /** Sort response control RFC 2891 */
951 /** Page request control RFC 2696 */
953 /** Page response control RFC 2696 */
955 /** VLV request control draft-ietf-ldapext-ldapv3-vlv-09 */
957 /** VLV response control draft-ietf-ldapext-ldapv3-vlv-09 */
960
961
962/**
963 * RFC 2696 Paged control OID.
964 */
965#define APR_LDAP_CONTROL_PAGE_OID "1.2.840.113556.1.4.319" /* RFC 2696 */
966
967/**
968 * RFC 2891 Sort request control OID.
969 */
970#define APR_LDAP_CONTROL_SORT_REQUEST_OID "1.2.840.113556.1.4.473" /* RFC 2891 */
971
972/**
973 * RFC 2891 Sort response control OID.
974 */
975#define APR_LDAP_CONTROL_SORT_RESPONSE_OID "1.2.840.113556.1.4.474" /* RFC 2891 */
976
977/**
978 * VLV request control OID.
979 */
980#define APR_LDAP_CONTROL_VLV_REQUEST_OID "2.16.840.1.113730.3.4.9"
981
982/**
983 * VLV response control OID.
984 */
985#define APR_LDAP_CONTROL_VLV_RESPONSE_OID "2.16.840.1.113730.3.4.10"
986
987/**
988 * Control specified by OID and value.
989 *
990 * All controls unrecognised by this API can be parsed
991 * and returned as this type.
992 */
994 /** The OID of the control */
995 const char *oid;
996 /** The raw value of the control */
999
1000/**
1001 * Sort request control RFC 2891.
1002 */
1007
1008typedef enum {
1009 /** Sort forwards */
1011 /** Sort backwards */
1014
1015/**
1016 * Sort key list.
1017 */
1019 /** The attribute to sort by */
1020 const char *attribute;
1021 /** The ordering rule to use */
1022 const char *order;
1023 /** Reverse or forward order */
1026
1027/**
1028 * Sort Response Control RFC 2891.
1029 */
1031 /** The attribute involved in a sort failure */
1032 const char *attribute;
1033 /** Result of the sort */
1036
1037/**
1038 * Page request control RFC 2696.
1039 */
1041 /** The page size */
1042 apr_size_t size;
1043 /** The opaque cookie identifing this page */
1046
1047/**
1048 * Page Response Control RFC 2696.
1049 */
1051 /** The total count */
1052 apr_size_t count;
1053 /** The opaque cookie identifing this page */
1056
1057/**
1058 * VLV request control draft-ietf-ldapext-ldapv3-vlv-09.
1059 */
1061 /** Before count */
1062 apr_size_t before;
1063 /** After count */
1064 apr_size_t after;
1065 /** Offset */
1066 apr_size_t offset;
1067 /** Count */
1068 apr_size_t count;
1069 /** Optional search value as an alternative to offset */
1071 /** The opaque cookie identifing this vlv result */
1074
1075/**
1076 * VLV Response Control draft-ietf-ldapext-ldapv3-vlv-09.
1077 */
1079 /** Offset */
1080 apr_size_t offset;
1081 /** Count */
1082 apr_size_t count;
1083 /** Result of the sort */
1085 /** The opaque cookie identifing this page */
1088
1089
1090
1091
1092/**
1093 * LDAP parsed control structures.
1094 *
1095 * Use this structure to pass or receive the parameters
1096 * required when creating or parsing a control.
1097 *
1098 * Unrecognised controls can be created or parsed using the
1099 * APR_LDAP_CONTROL_OID type and a raw binary value.
1100 *
1101 * @see apr_ldap_bind_cb
1102 * @see apr_ldap_compare_cb
1103 * @see apr_ldap_search_result_cb
1104 * @see apr_ldap_compare
1105 * @see apr_ldap_search
1106 * @see apr_ldap_add
1107 * @see apr_ldap_modify
1108 * @see apr_ldap_rename
1109 * @see apr_ldap_delete
1110 * @see apr_ldap_extended
1111 */
1112typedef struct apr_ldap_control_t {
1113 /** The type of the control. */
1115 /** Is the control critical */
1117 /** Control specified by OID and value */
1119 /** Details of each control, based on the control type. */
1120 union {
1121 /** Sort request control */
1123 /** Sort response control */
1125 /** Page request control */
1127 /** Page response control */
1129 /** VLV request control */
1131 /** VLV response control */
1133 } c;
1135
1136
1137
1138/**
1139 * LDAP interaction identifiers during LDAP binding
1140 *
1141 * @see apr_ldap_bind_interact_t
1142 * @see apr_ldap_bind
1143 */
1144typedef enum {
1145 APR_LDAP_INTERACT_DN = 0, /**< Distinguished name to use for simple bind */
1146 APR_LDAP_INTERACT_GETREALM = 0x4008, /**< SASL realm for the authentication attempt */
1147 APR_LDAP_INTERACT_AUTHNAME = 0x4002, /**< SASL username to authenticate */
1148 APR_LDAP_INTERACT_USER = 0x4001, /**< SASL username to use for proxy authorization */
1149 APR_LDAP_INTERACT_PASS = 0x4004, /**< SASL password for the provided username / Simple password for a simple bind */
1150 APR_LDAP_INTERACT_NOECHOPROMPT = 0x4006, /**< SASL generic prompt for input with input echoing disabled */
1151 APR_LDAP_INTERACT_ECHOPROMPT = 0x4005, /**< SASL generic prompt for input with input echoing enabled */
1153
1154
1155/**
1156 * During apr_ldap_bind(), a callback is passed this structure
1157 * requesting authentication and authorisation details. The callback
1158 * is expected to fill the buffer with the information requested.
1159 *
1160 * This is used to obtain the information needed for SASL binds.
1161 *
1162 * @see apr_ldap_bind_interact_e
1163 * @see apr_ldap_bind
1164 */
1166 /** An enum indicating what information is requested. */
1168 /** Presented to user (e.g. OTP challenge) */
1169 const char *challenge;
1170 /** Presented to user (e.g. "Username: ") */
1171 const char *prompt;
1172 /** Default result string */
1173 const char *defresult;
1174 /** Buffer to be filled in by the callback with the information requested */
1177
1178/**
1179 * Bind SASL interact callback.
1180 *
1181 * Depending on the type of SASL mechanism chosen, this callback is called
1182 * to request details needed for each bind.
1183 *
1184 * @see apr_ldap_bind_interact_t
1185 * @see apr_ldap_bind
1186 */
1188 apr_ldap_t *ld, unsigned int flags, apr_ldap_bind_interact_t *interact, void *ctx);
1189
1190
1191
1192
1193
1194#if 0
1195
1196typedef struct apr_ldap_rebind_t {
1197 /** presented to user (e.g. OTP challenge) */
1198 const char *challenge;
1199 /** presented to user (e.g. "Username: ") */
1200 const char *prompt;
1201} apr_ldap_rebind_t;
1202
1203typedef apr_status_t (apr_ldap_rebind_proc)(
1204 apr_ldap_t *ld, apr_ldap_rebind_t *rebind, void *ctx);
1205
1206#endif
1207
1208
1209
1210/**
1211 * APR LDAP connect function.
1212 *
1213 * This function makes an attempt to connect to the server initialised
1214 * by apr_ldap_initialise().
1215 *
1216 * While other functions will connect if not connected, use this
1217 * function to explicitly handle errors in the connect case.
1218 *
1219 * This function will synchronously perform DNS lookups and TLS negotiation
1220 * and will block if needed.
1221 *
1222 * If you need asynchronous handling, perform the DNS and TLS handling
1223 * yourself, and then pass the socket with APR_LDAP_OPT_DESC.
1224 *
1225 * @return APR_SUCCESS means that the connection connected successfully.
1226 * Other error codes indicate that the connect was not successful.
1227 */
1229 apr_ldap_t *ldap,
1230 apr_interval_time_t timeout,
1231 apu_err_t *result_err)
1232 __attribute__((nonnull(1,2,4)));
1233
1234/**
1235 * Callback to prepare an LDAP request.
1236 *
1237 * This callback is scheduled to be fired when the LDAP socket is next
1238 * writable, from within apr_ldap_process().
1239 *
1240 * When complete, return APR_SUCCESS to indicate you want to continue, or
1241 * a different code if you want the event loop to give up. This code will
1242 * be returned from apr_ldap_process().
1243 * @see apr_ldap_prepare
1244 * @see apr_ldap_process
1245 */
1247 void *ctx, apu_err_t *err);
1248
1249
1250/**
1251 * APR LDAP prepare function
1252 *
1253 * This function schedules a generic callback, fired the next time the LDAP
1254 * socket is writable.
1255 *
1256 * This callback can be used to prepare the initial LDAP request, or to
1257 * prepare additional requests as needed without blocking.
1258 *
1259 * @param pool The pool that keeps track of the lifetime of the callback.
1260 * If this pool is cleaned up, the callback will be will be gracefully
1261 * removed without affecting other LDAP requests in progress. This pool need
1262 * not have any relationship with the LDAP connection pool.
1263 * @param ldap The ldap handle
1264 * @param prepare_cb The prepare callback function. When apr_ldap_process() is
1265 * next called this callback will be triggered in the expectation of the next
1266 * LDAP request.
1267 * @param prepare_ctx Context passed to the prepare callback.
1268 *
1269 * @return APR_SUCCESS means the callback was successfully prepared. Other error
1270 * codes indicate that the attept to send the cancellation was not successful.
1271 */
1273 apr_ldap_t *ldap,
1274 apr_ldap_prepare_cb prepare_cb,
1275 void *prepare_ctx)
1276 __attribute__((nonnull(1,2,3)));
1277
1278
1279/**
1280 * APR process function.
1281 *
1282 * This function performs outstanding processing of any LDAP conversations
1283 * currently in progress.
1284 *
1285 * When a request tells you that further processing is needed, schedule this
1286 * call the next time the socket is writable.
1287 *
1288 * Most callbacks are fired from within apr_ldap_process() so that we are
1289 * ready to write the next LDAP query should that be needed.
1290 *
1291 * @param pool The pool to use
1292 * @param ldap The LDAP handle
1293 * @param timeout The timeout to use for writes.
1294 * @param err Error structure for reporting detailed results.
1295 *
1296 * @return APR_WANT_WRITE means that at least one further process is outstanding
1297 * and a further write callback should be scheduled. APR_WANTS_READ indicates
1298 * the a request has been sent and we're waiting for the response. APR_SUCCESS
1299 * means that no further processing is needed. Other error codes indicate that
1300 * the processing of outstanding conversations was not successful.
1301 */
1303 apr_ldap_t *ldap,
1304 apr_interval_time_t timeout,
1305 apu_err_t *err)
1306 __attribute__((nonnull(1,2,4)));
1307
1308
1309/**
1310 * APR result function.
1311 *
1312 * This function returns the result of a previous request, ready for further
1313 * processing.
1314 *
1315 * @param pool The pool to use
1316 * @param ldap The LDAP handle
1317 * @param timeout The timeout to use for writes.
1318 * @param err Error structure for reporting detailed results.
1319 *
1320 * @return APR_WANT_WRITE means that at least one further process is outstanding
1321 * and a further write callback should be scheduled. APR_WANTS_READ indicates
1322 * more responses are expected and we're waiting for the response. APR_SUCCESS
1323 * means that no further processing is needed. Other error codes indicate that
1324 * the processing of outstanding conversations was not successful.
1325 */
1327 apr_ldap_t *ldap,
1328 apr_interval_time_t timeout,
1329 apu_err_t *err)
1330 __attribute__((nonnull(1,2,4)));
1331
1332
1333/**
1334 * APR LDAP poll function.
1335 *
1336 * For applications that need simple set of queries, this function provides
1337 * an event loop that can handle a series of LDAP requests.
1338 *
1339 * This function calls apr_ldap_process() and apr_ldap_result() as needed.
1340 *
1341 * @param pool The pool to use
1342 * @param ldap The LDAP handle
1343 * @param timeout The timeout to use for reads and writes.
1344 * @param err Error structure for reporting detailed results.
1345 *
1346 * @return APR_SUCCESS means that no further processing is needed. Other error
1347 * codes indicate that processing was not successful.
1348 */
1350 apr_ldap_t *ldap,
1351 apr_pollcb_t *poll,
1352 apr_interval_time_t timeout,
1353 apu_err_t *err)
1354 __attribute__((nonnull(1,2,3,5)));
1355
1356
1357/**
1358 * Callback to receive the results of a bind operation.
1359 *
1360 * When a bind is successful, this function is called with a status of
1361 * APR_SUCCESS.
1362 *
1363 * Bind success is returned from within apr_ldap_process(), and therefore
1364 * it can be safely assumed that the underlying socket is writable ready
1365 * for exactly one further LDAP operation like apr_ldap_search() or
1366 * apr_ldap_compare().
1367 *
1368 * If the bind fails, status will carry the error code, and err will return
1369 * the human readable details.
1370 *
1371 * If the underlying LDAP connection has failed, status will return details
1372 * of the error, allowing an opportunity to clean up.
1373 *
1374 * When complete, return APR_SUCCESS to indicate you want to continue, or
1375 * a different code if you want the event loop to give up. This code will
1376 * be returned from apr_ldap_process().
1377 *
1378 * If this callback was called during a pool cleanup, the return value is
1379 * ignored.
1380 * @see apr_ldap_bind
1381 * @see apr_ldap_process
1382 * @see apr_ldap_result
1383 */
1385 const char *matcheddn,
1386 apr_ldap_control_t **serverctrls,
1387 void *ctx, apu_err_t *err);
1388
1389
1390#if 0
1391/**
1392 * Function called to report cancel results.
1393 */
1394typedef void (*apr_ldap_cancel_cb)(apr_ldap_t *ldap, apr_ldap_message_t *msg, void *ctx);
1395
1396/**
1397 * APR LDAP cancel function
1398 *
1399 * This function cancels a previously sent LDAP operation, identified by
1400 * the callback function and callback context.
1401 *
1402 * Cancellations are attempted asynchronously. The result of the cancellation
1403 * will be retrieved and handled by the apr_ldap_result() function, and the
1404 * outcome is passed to the callback provided.
1405 *
1406 * @return APR_INCOMPLETE means that the cancellation was sent, and the message
1407 * in reply needs to be fetched using apr_ldap_result(). Other error
1408 * codes indicate that the attept to send the cancellation was not successful.
1409 */
1410APU_DECLARE_LDAP(apr_status_t) apr_ldap_cancel(apr_pool_t *pool,
1411 apr_ldap_t *ldap,
1412 apr_ldap_control_t **serverctrls,
1413 apr_ldap_control_t **clientctrls,
1414 apr_interval_time_t timeout,
1415 apr_ldap_cancel_cb cancel_cb, void *cancel_ctx,
1416 apu_err_t *err)
1417 __attribute__((nonnull(1,2,6,8)));
1418#endif
1419
1420/**
1421 * APR LDAP bind function
1422 *
1423 * This function initiates a bind on a previously initialised LDAP connection
1424 * to the directory.
1425 *
1426 * Pass the required SASL mechanism in mech, or set to NULL for a simple
1427 * bind.
1428 *
1429 * Unlike the native LDAP APIs, this function muct be called just once.
1430 * The job of binding is done inside apr_ldap_process() and apr_ldap_result().
1431 *
1432 * Binds are attempted asynchronously. For non blocking behaviour, this function
1433 * must be called after the underlying socket has indicated that it is ready to
1434 * write.
1435 *
1436 * In the absence of an error, apr_ldap_bind will return APR_WANT_READ to
1437 * indicate that the next message in the conversation be retrieved using
1438 * apr_ldap_result().
1439 *
1440 * The outcome of the bind will be retrieved and handled by the
1441 * apr_ldap_process() function, and the outcome is passed to the
1442 * apr_ldap_bind_cb provided.
1443 *
1444 * @param pool The pool that keeps track of the lifetime of the bind conversation.
1445 * If this pool is cleaned up, the bind conversation will be gracefully
1446 * abandoned without affecting other LDAP requests in progress. This pool need
1447 * not have any relationship with the LDAP connection pool.
1448 * @param ldap The ldap handle
1449 * @param mech The SASL mechanism. Pass NULL for simple bind.
1450 * @param interact_cb The SASL interactive callback function. This function is
1451 * is called to request credentials for the bind, depending on the mechanism.
1452 * @param interact_ctx Context passed to the interactive callback.
1453 * @param timeout The timeout to use for writes.
1454 * @param bind_cb The bind result callback function. When the bind process has
1455 * completed the success or failure of the bind is returned here. The callback
1456 * is triggered from inside apr_ldap_process() so that it is safe to write the
1457 * next LDAP request.
1458 * @param bind_ctx Context passed to the bind callback.
1459 * @param err Error structure for reporting detailed results.
1460 * @return APR_WANT_READ means that processing has occurred, and
1461 * the message in reply needs to be fetched using apr_ldap_result().
1462 * APR_WANT_WRITE means that processing has occurred, and the
1463 * conversation needs to be continued with a call to apr_ldap_process().
1464 * APR_SUCCESS means that the processing is complete, and the bind
1465 * has been successful. Other error codes indicate that the bind
1466 * was not successful.
1467 * @see apr_ldap_bind_interact_cb
1468 * @see apr_ldap_bind_cb
1469 * @see apr_ldap_process
1470 * @see apr_ldap_result
1471 */
1473 const char *mech,
1474 apr_ldap_bind_interact_cb *interact_cb,
1475 void *interact_ctx,
1476 apr_interval_time_t timeout,
1477 apr_ldap_bind_cb bind_cb, void *bind_ctx,
1478 apu_err_t *err)
1479 __attribute__((nonnull(1,2,4,9)));
1480
1481
1482/**
1483 * Callback to receive the results of a compare operation.
1484 *
1485 * When a compare is successful, this function is called with a status of
1486 * APR_COMPARE_TRUE or APR_COMPARE_FALSE.
1487 *
1488 * If the compare fails, status will carry the error code, and err will return
1489 * the human readable details.
1490 *
1491 * If the underlying LDAP connection has failed, status will return details
1492 * of the error, allowing an opportunity to clean up.
1493 *
1494 * When complete, return APR_SUCCESS to indicate you want to continue, or
1495 * a different code if you want the event loop to give up. This code will
1496 * be returned from apr_ldap_result().
1497 *
1498 * If this callback was called during a pool cleanup, the return value is
1499 * ignored.
1500 * @see apr_ldap_compare
1501 * @see apr_ldap_result
1502 */
1504 const char *matcheddn,
1505 apr_ldap_control_t **serverctrls,
1506 void *ctx, apu_err_t *err);
1507
1508
1509
1510/**
1511 * APR LDAP compare function
1512 *
1513 * This function compares a string or binary value of an attribute
1514 * within an entry described by the given distinguished name against
1515 * a previously initialised LDAP connection to the directory.
1516 *
1517 * Compares are attempted asynchronously. For non blocking behaviour, this function
1518 * must be called after the underlying socket has indicated that it is ready to
1519 * write.
1520 *
1521 * In the absence of an error, apr_ldap_compare will return APR_WANT_READ to
1522 * indicate that the next message in the conversation be retrieved using
1523 * apr_ldap_result().
1524 *
1525 * The outcome of the compare will be retrieved and handled by the
1526 * apr_ldap_process() function, and the outcome is passed to the
1527 * apr_ldap_compare_cb provided.
1528 *
1529 * @param pool The pool that keeps track of the lifetime of the compare conversation.
1530 * If this pool is cleaned up, the compare conversation will be gracefully
1531 * abandoned without affecting other LDAP requests in progress. This pool need
1532 * not have any relationship with the LDAP connection pool.
1533 * @param ldap The ldap handle
1534 * @param dn The distinguished named of the object to compare.
1535 * @param attr The attribute of the object to compare.
1536 * @param val The value to be compared to the attribute. The value can be zero
1537 * terminated text, or binary.
1538 * @param serverctrls NULL terminated array of server controls.
1539 * @param clientctrls NULL terminated array of client controls.
1540 * @param timeout The timeout to use for writes.
1541 * @param compare_cb The compare result callback function. When the compare process has
1542 * completed the success or failure of the compare is returned here. The callback
1543 * is triggered from inside apr_ldap_process() so that it is safe to write the
1544 * next LDAP request.
1545 * @param ctx Context passed to the compare callback.
1546 * @param err Error structure for reporting detailed results.
1547 *
1548 * @return APR_WANT_READ means that processing has occurred, and
1549 * the message in reply needs to be fetched using apr_ldap_result().
1550 * APR_SUCCESS means that the processing is complete, and the bind
1551 * has been successful. Other error codes indicate that the bind
1552 * was not successful.
1553 * @see apr_ldap_compare_cb
1554 * @see apr_ldap_process
1555 * @see apr_ldap_result
1556 */
1558 apr_ldap_t *ldap,
1559 const char *dn,
1560 const char *attr,
1561 const apr_buffer_t *val,
1562 apr_array_header_t *serverctrls,
1563 apr_array_header_t *clientctrls,
1564 apr_interval_time_t timeout,
1565 apr_ldap_compare_cb compare_cb, void *ctx,
1566 apu_err_t *err)
1567 __attribute__((nonnull(1,2,3,4,5,11)));
1568
1569
1570/**
1571 * APR search scopes
1572 *
1573 * @see apr_ldap_search
1574 */
1575typedef enum {
1576 /** base object search */
1578 /** one-level search */
1580 /** subtree search */
1582 /** subordinate search */
1585
1586
1587/**
1588 * Callback to receive the results of a search operation.
1589 *
1590 * This callback is fired once for every search.
1591 *
1592 * When a search is complete, this function is called with a status of
1593 * APR_SUCCESS or APR_NO_RESULTS_RETURNED.
1594 *
1595 * If the search fails, status will carry the error code, and err will return
1596 * the human readable details.
1597 *
1598 * If the underlying LDAP connection has failed, status will return details
1599 * of the error, allowing an opportunity to clean up.
1600 *
1601 * When complete, return APR_SUCCESS to indicate you want to continue, or
1602 * a different code if you want the event loop to give up. This code will
1603 * be returned from apr_ldap_result().
1604 *
1605 * If this callback was called during a pool cleanup, the return value is
1606 * ignored.
1607 * @see apr_ldap_search
1608 * @see apr_ldap_result
1609 */
1611 apr_size_t count, const char *matcheddn,
1612 apr_hash_t *serverctrls,
1613 void *ctx, apu_err_t *err);
1614
1615/**
1616 * Search entry attribute value callback structure.
1617 *
1618 * The callback is passed a pointer to the following structure
1619 * containing the current state of the attribute values being
1620 * returned.
1621 *
1622 * @see apr_ldap_search
1623 */
1625 /** Total number of attributes */
1626 apr_size_t nattrs;
1627 /** Attribute index - counts up for each attribute returned */
1628 apr_size_t aidx;
1629 /** Attribute */
1630 const char *attr;
1631 /** Total number of values */
1632 apr_size_t nvals;
1633 /** Value index - counts up for each value returned */
1634 apr_size_t vidx;
1635 /** Value */
1637 /** Flags */
1640
1641/**
1642 * Callback to receive the entries of a search operation.
1643 *
1644 * This callback is fired once for every attribute and value combination,
1645 * and then once for each entry to indicate the entry is complete.
1646 *
1647 * When complete, return APR_SUCCESS to indicate you want to continue, or
1648 * a different code if you want the event loop to give up. This code will
1649 * be returned from apr_ldap_result().
1650 *
1651 * @see apr_ldap_search
1652 * @see apr_ldap_result
1653 */
1654typedef apr_status_t (*apr_ldap_search_entry_cb)(apr_ldap_t *ldap, const char *dn,
1655 apr_size_t eidx,
1657 void *ctx, apu_err_t *err);
1658
1659
1660/**
1661 * APR LDAP search function
1662 *
1663 * This function searches a previously initialised LDAP connection to the directory.
1664 *
1665 * Searches are attempted asynchronously. For non blocking behaviour, this function
1666 * must be called after the underlying socket has indicated that it is ready to
1667 * write.
1668 *
1669 * In the absence of an error, apr_ldap_search will return APR_WANT_READ to
1670 * indicate that the next message in the conversation be retrieved using
1671 * apr_ldap_result().
1672 *
1673 * The outcome of the search will be retrieved and handled by the
1674 * apr_ldap_result() function as each result arrives.
1675 *
1676 * If one or more results are returned, the apr_ldap_search_entry_cb callback
1677 * is called once for each attribute and value combination.
1678 *
1679 * At the end of each entry, apr_ldap_search_entry_cb will be called with no
1680 * attribute or value, giving code an opportunity to perform any processing only
1681 * possible after all of the entries have been retrieved.
1682 *
1683 * Once all entries have been processed, apr_ldap_search_result_cb is called to
1684 * indicate the final result of the search.
1685 *
1686 * If no entries are returned, only apr_ldap_search_result_cb will be called.
1687 *
1688 * @param pool The pool that keeps track of the lifetime of the search conversation.
1689 * If this pool is cleaned up, the search conversation will be gracefully
1690 * abandoned without affecting other LDAP requests in progress. This pool need
1691 * not have any relationship with the LDAP connection pool.
1692 * @param ldap The ldap handle
1693 * @param dn The base distinguished named of the search.
1694 * @param scope The scope of the search.
1695 * @param filter The search filter string.
1696 * @param attrs NULL terminated array of attributes to return.
1697 * @param attrsonly If on, attributes will be returned without values.
1698 * @param serverctrls NULL terminated array of server controls.
1699 * @param clientctrls NULL terminated array of client controls.
1700 * @param timeout The timeout to use for writes.
1701 * @param sizelimit The maximum number of entries to return in the search.
1702 * @param search_result_cb The search result callback function. When the search
1703 * process has completed the success or failure of the search is returned here.
1704 * The callback is triggered from inside apr_ldap_process() so that it is safe to
1705 * write the next LDAP request.
1706 * @param search_entry_cb The search entry callback function. For each value of
1707 * each attribute of each entry, this callback is called with each value. This
1708 * callback is then fired off one more time at the end of each entry, giving the
1709 * chance to handle that entry. The callback is triggered from inside
1710 * apr_ldap_result().
1711 * @param ctx Context passed to the search result and search entry callbacks.
1712 * @param err Error structure for reporting detailed results.
1713 *
1714 * @return APR_WANT_READ means that processing has occurred, and
1715 * the message in reply needs to be fetched using apr_ldap_result().
1716 * Other error codes indicate that the search attempt was not successful.
1717 * @see apr_ldap_search_entry_cb
1718 * @see apr_ldap_search_result_cb
1719 * @see apr_ldap_result
1720 */
1722 apr_ldap_t *ldap,
1723 const char *dn,
1725 const char *filter,
1726 const char **attrs,
1727 apr_ldap_switch_e attrsonly,
1728 apr_array_header_t *serverctrls,
1729 apr_array_header_t *clientctrls,
1730 apr_interval_time_t timeout,
1731 apr_ssize_t sizelimit,
1732 apr_ldap_search_result_cb search_result_cb,
1733 apr_ldap_search_entry_cb search_entry_cb,
1734 void *ctx,
1735 apu_err_t *err)
1736 __attribute__((nonnull(1,2,3,15)));
1737
1738/**
1739 * Attribute-value pair.
1740 *
1741 * An array of pairs is passed to apr_ldap_add(), and
1742 * a pair forms part of the apr_ldap_modify_t that is
1743 * passed to apr_ldap_modify().
1744 *
1745 * @see apr_ldap_add
1746 * @see apr_ldap_modify
1747 */
1748typedef struct apr_ldap_pair_t {
1749 /** Attribute to perform the operation on */
1750 const char *attr;
1751 /** Array of apr_buffer_t values */
1754
1755/**
1756 * Callback to receive the results of an add operation.
1757 *
1758 * When an addition is successful, this function is called with a status of
1759 * APR_SUCCESS.
1760 *
1761 * If the addition fails, status will carry the error code, and err will return
1762 * the human readable details.
1763 *
1764 * If the underlying LDAP connection has failed, status will return details
1765 * of the error, allowing an opportunity to clean up.
1766 *
1767 * When complete, return APR_SUCCESS to indicate you want to continue, or
1768 * a different code if you want the event loop to give up. This code will
1769 * be returned from apr_ldap_result().
1770 *
1771 * If this callback was called during a pool cleanup, the return value is
1772 * ignored.
1773 * @see apr_ldap_add
1774 * @see apr_ldap_result
1775 */
1777 const char *matcheddn,
1778 apr_ldap_control_t **serverctrls,
1779 void *ctx, apu_err_t *err);
1780
1781
1782/**
1783 * APR LDAP add function
1784 *
1785 * This function allows addition of an entry containing attributes and values
1786 * described by the given distinguished name stored in the directory.
1787 *
1788 * Additions are attempted asynchronously. For non blocking
1789 * behaviour, this function must be called after the underlying
1790 * socket has indicated that it is ready to write.
1791 *
1792 * In the absence of an error, apr_ldap_add will return
1793 * APR_WANT_READ or APR_WANT_WRITE to indicate that the next message
1794 * in the conversation be retrieved using apr_ldap_result().
1795 *
1796 * The outcome of the addition will be retrieved and handled by
1797 * the apr_ldap_process() function, and the outcome is passed to the
1798 * apr_ldap_add_cb provided.
1799 *
1800 * @param pool The pool that keeps track of the lifetime of the add conversation.
1801 * If this pool is cleaned up, the add conversation will be gracefully
1802 * abandoned without affecting other LDAP requests in progress. This pool need
1803 * not have any relationship with the LDAP connection pool.
1804 * @param ldap The ldap handle
1805 * @param dn The distinguished named of the object to add.
1806 * @param adds Array of apr_ldap_pair_t attributes and values.
1807 * @param serverctrls NULL terminated array of server controls.
1808 * @param clientctrls NULL terminated array of client controls.
1809 * @param timeout The timeout to use for writes.
1810 * @param add_cb The addition result callback function. When the add process has
1811 * completed the success or failure of the addition is returned here. The callback
1812 * is triggered from inside apr_ldap_process() so that it is safe to write the
1813 * next LDAP request.
1814 * @param ctx Context passed to the add callback.
1815 * @param err Error structure for reporting detailed results.
1816 *
1817 * @return APR_WANT_READ means that processing has occurred, and
1818 * the message in reply needs to be fetched using apr_ldap_result().
1819 * APR_SUCCESS means that the processing is complete, and the addition
1820 * has been successful. Other error codes indicate that the addition
1821 * was not successful.
1822 * @see apr_ldap_add_cb
1823 * @see apr_ldap_process
1824 * @see apr_ldap_result
1825 */
1827 apr_ldap_t *ldap,
1828 const char *dn,
1829 apr_array_header_t *adds,
1830 apr_array_header_t *serverctrls,
1831 apr_array_header_t *clientctrls,
1832 apr_interval_time_t timeout,
1833 apr_ldap_add_cb add_cb, void *ctx,
1834 apu_err_t *err)
1835 __attribute__((nonnull(1,2,3,4,10)));
1836
1837
1838/**
1839 * LDAP modification operations
1840 *
1841 * @see apr_ldap_modify
1842 */
1843typedef enum {
1844 /** Add an attribute or entry */
1846 /** Remove an attribute or entry */
1848 /** Replace an attribute or entry */
1850 /** Increment an attribute, see RFC4525 */
1853
1854/**
1855 * Modification to be performed by apr_ldap_modify().
1856 *
1857 * Modifications can take the form of additions, deletions, or
1858 * the in place modification or increment of an attribute.
1859 *
1860 * @see apr_ldap_pair_t
1861 * @see apr_ldap_modify
1862 */
1863typedef struct apr_ldap_modify_t {
1864 /** Operation to be performed */
1866 /** Attribute-value pair to perform the operation on */
1869
1870
1871/**
1872 * Callback to receive the results of a modify operation.
1873 *
1874 * When a modification is successful, this function is called with a status of
1875 * APR_SUCCESS.
1876 *
1877 * If the modify fails, status will carry the error code, and err will return
1878 * the human readable details.
1879 *
1880 * If the underlying LDAP connection has failed, status will return details
1881 * of the error, allowing an opportunity to clean up.
1882 *
1883 * When complete, return APR_SUCCESS to indicate you want to continue, or
1884 * a different code if you want the event loop to give up. This code will
1885 * be returned from apr_ldap_result().
1886 *
1887 * If this callback was called during a pool cleanup, the return value is
1888 * ignored.
1889 * @see apr_ldap_modify
1890 * @see apr_ldap_result
1891 */
1893 const char *matcheddn,
1894 apr_ldap_control_t **serverctrls,
1895 void *ctx, apu_err_t *err);
1896
1897
1898
1899/**
1900 * APR LDAP modify function
1901 *
1902 * This function allows modification of attributes and values
1903 * within an entry described by the given distinguished name stored
1904 * in the directory.
1905 *
1906 * Modifications are attempted asynchronously. For non blocking
1907 * behaviour, this function must be called after the underlying
1908 * socket has indicated that it is ready to write.
1909 *
1910 * In the absence of an error, apr_ldap_modify will return
1911 * APR_WANT_READ or APR_WANT_WRITE to indicate that the next message
1912 * in the conversation be retrieved using apr_ldap_result().
1913 *
1914 * The outcome of the modification will be retrieved and handled by
1915 * the apr_ldap_process() function, and the outcome is passed to the
1916 * apr_ldap_modify_cb provided.
1917 *
1918 * @param pool The pool that keeps track of the lifetime of the modify conversation.
1919 * If this pool is cleaned up, the modify conversation will be gracefully
1920 * abandoned without affecting other LDAP requests in progress. This pool need
1921 * not have any relationship with the LDAP connection pool.
1922 * @param ldap The ldap handle
1923 * @param dn The distinguished named of the object to modify.
1924 * @param mods Array of apr_ldap_modify_t operations.
1925 * @param serverctrls NULL terminated array of server controls.
1926 * @param clientctrls NULL terminated array of client controls.
1927 * @param timeout The timeout to use for writes.
1928 * @param modify_cb The modify result callback function. When the modify process has
1929 * completed the success or failure of the modification is returned here. The callback
1930 * is triggered from inside apr_ldap_process() so that it is safe to write the
1931 * next LDAP request.
1932 * @param ctx Context passed to the modify callback.
1933 * @param err Error structure for reporting detailed results.
1934 *
1935 * @return APR_WANT_READ means that processing has occurred, and
1936 * the message in reply needs to be fetched using apr_ldap_result().
1937 * APR_SUCCESS means that the processing is complete, and the modify
1938 * has been successful. Other error codes indicate that the modify
1939 * was not successful.
1940 * @see apr_ldap_modify_cb
1941 * @see apr_ldap_process
1942 * @see apr_ldap_result
1943 */
1945 apr_ldap_t *ldap,
1946 const char *dn,
1947 apr_array_header_t *mods,
1948 apr_array_header_t *serverctrls,
1949 apr_array_header_t *clientctrls,
1950 apr_interval_time_t timeout,
1951 apr_ldap_modify_cb modify_cb, void *ctx,
1952 apu_err_t *err)
1953 __attribute__((nonnull(1,2,3,4,10)));
1954
1955/**
1956 * LDAP rename flags
1957 *
1958 * @see apr_ldap_rename
1959 */
1960typedef enum {
1961 /** No flags */
1963 /** Delete the old relative distinguished name from the entry */
1966
1967/**
1968 * Callback to receive the results of a rename operation.
1969 *
1970 * When a rename is successful, this function is called with a status of
1971 * APR_SUCCESS.
1972 *
1973 * If the rename fails, status will carry the error code, and err will return
1974 * the human readable details.
1975 *
1976 * If the underlying LDAP connection has failed, status will return details
1977 * of the error, allowing an opportunity to clean up.
1978 *
1979 * When complete, return APR_SUCCESS to indicate you want to continue, or
1980 * a different code if you want the event loop to give up. This code will
1981 * be returned from apr_ldap_result().
1982 *
1983 * If this callback was called during a pool cleanup, the return value is
1984 * ignored.
1985 * @see apr_ldap_rename
1986 * @see apr_ldap_result
1987 */
1989 const char *matcheddn,
1990 apr_ldap_control_t **serverctrls,
1991 void *ctx, apu_err_t *err);
1992
1993
1994
1995/**
1996 * APR LDAP rename function
1997 *
1998 * This function allows moving or renaming of an entry from the given
1999 * distinguished name, to a new relative distinguished name, a new
2000 * parent object, or both.
2001 *
2002 * Renamed are attempted asynchronously. For non blocking
2003 * behaviour, this function must be called after the underlying
2004 * socket has indicated that it is ready to write.
2005 *
2006 * In the absence of an error, apr_ldap_rename will return
2007 * APR_WANT_READ or APR_WANT_WRITE to indicate that the next message
2008 * in the conversation be retrieved using apr_ldap_result().
2009 *
2010 * The outcome of the deletion will be retrieved and handled by
2011 * the apr_ldap_process() function, and the outcome is passed to the
2012 * apr_ldap_rename_cb provided.
2013 *
2014 * @param pool The pool that keeps track of the lifetime of the rename conversation.
2015 * If this pool is cleaned up, the rename conversation will be gracefully
2016 * abandoned without affecting other LDAP requests in progress. This pool need
2017 * not have any relationship with the LDAP connection pool.
2018 * @param ldap The ldap handle
2019 * @param dn The distinguished named of the object to rename.
2020 * @param newrdn The new relative distinguished named of the object.
2021 * @param newparent The distinguished named of the parent object to move to.
2022 * @param flags If APR_LDAP_RENAME_DELETEOLDRDN is passed, the old RDN in the entry will be removed.
2023 * @param serverctrls NULL terminated array of server controls.
2024 * @param clientctrls NULL terminated array of client controls.
2025 * @param timeout The timeout to use for writes.
2026 * @param rename_cb The rename result callback function. When the rename process has
2027 * completed the success or failure of the rename is returned here. The callback
2028 * is triggered from inside apr_ldap_process() so that it is safe to write the
2029 * next LDAP request.
2030 * @param ctx Context passed to the rename callback.
2031 * @param err Error structure for reporting detailed results.
2032 *
2033 * @return APR_WANT_READ means that processing has occurred, and
2034 * the message in reply needs to be fetched using apr_ldap_result().
2035 * APR_SUCCESS means that the processing is complete, and the rename
2036 * has been successful. Other error codes indicate that the rename
2037 * was not successful.
2038 * @see apr_ldap_rename_cb
2039 * @see apr_ldap_process
2040 * @see apr_ldap_result
2041 */
2043 apr_ldap_t *ldap,
2044 const char *dn, const char *newrdn, const char *newparent,
2045 apr_ldap_rename_e flags,
2046 apr_array_header_t *serverctrls,
2047 apr_array_header_t *clientctrls,
2048 apr_interval_time_t timeout,
2049 apr_ldap_rename_cb rename_cb, void *ctx,
2050 apu_err_t *err)
2051 __attribute__((nonnull(1,2,3,4,12)));
2052
2053/**
2054 * Callback to receive the results of a delete operation.
2055 *
2056 * When a deletion is successful, this function is called with a status of
2057 * APR_SUCCESS.
2058 *
2059 * If the delete fails, status will carry the error code, and err will return
2060 * the human readable details.
2061 *
2062 * If the underlying LDAP connection has failed, status will return details
2063 * of the error, allowing an opportunity to clean up.
2064 *
2065 * When complete, return APR_SUCCESS to indicate you want to continue, or
2066 * a different code if you want the event loop to give up. This code will
2067 * be returned from apr_ldap_result().
2068 *
2069 * If this callback was called during a pool cleanup, the return value is
2070 * ignored.
2071 * @see apr_ldap_delete
2072 * @see apr_ldap_result
2073 */
2075 const char *matcheddn,
2076 apr_ldap_control_t **serverctrls,
2077 void *ctx, apu_err_t *err);
2078
2079
2080
2081/**
2082 * APR LDAP delete function
2083 *
2084 * This function allows deletion of an entry described by the given
2085 * distinguished name stored in the directory.
2086 *
2087 * Deletions are attempted asynchronously. For non blocking
2088 * behaviour, this function must be called after the underlying
2089 * socket has indicated that it is ready to write.
2090 *
2091 * In the absence of an error, apr_ldap_delete will return
2092 * APR_WANT_READ or APR_WANT_WRITE to indicate that the next message
2093 * in the conversation be retrieved using apr_ldap_result().
2094 *
2095 * The outcome of the deletion will be retrieved and handled by
2096 * the apr_ldap_process() function, and the outcome is passed to the
2097 * apr_ldap_modify_cb provided.
2098 *
2099 * @param pool The pool that keeps track of the lifetime of the delete conversation.
2100 * If this pool is cleaned up, the delete conversation will be gracefully
2101 * abandoned without affecting other LDAP requests in progress. This pool need
2102 * not have any relationship with the LDAP connection pool.
2103 * @param ldap The ldap handle
2104 * @param dn The distinguished named of the object to delete.
2105 * @param serverctrls NULL terminated array of server controls.
2106 * @param clientctrls NULL terminated array of client controls.
2107 * @param timeout The timeout to use for writes.
2108 * @param delete_cb The delete result callback function. When the delete process has
2109 * completed the success or failure of the deletion is returned here. The callback
2110 * is triggered from inside apr_ldap_process() so that it is safe to write the
2111 * next LDAP request.
2112 * @param ctx Context passed to the delete callback.
2113 * @param err Error structure for reporting detailed results.
2114 *
2115 * @return APR_WANT_READ means that processing has occurred, and
2116 * the message in reply needs to be fetched using apr_ldap_result().
2117 * APR_SUCCESS means that the processing is complete, and the delete
2118 * has been successful. Other error codes indicate that the delete
2119 * was not successful.
2120 * @see apr_ldap_delete_cb
2121 * @see apr_ldap_process
2122 * @see apr_ldap_result
2123 */
2125 apr_ldap_t *ldap,
2126 const char *dn,
2127 apr_array_header_t *serverctrls,
2128 apr_array_header_t *clientctrls,
2129 apr_interval_time_t timeout,
2130 apr_ldap_delete_cb delete_cb, void *ctx,
2131 apu_err_t *err)
2132 __attribute__((nonnull(1,2,3,9)));
2133
2134/**
2135 * Callback to receive the results of an extended operation.
2136 *
2137 * When an extended operation is successful, this function is called with a
2138 * status of APR_SUCCESS.
2139 *
2140 * If the extended operation fails, status will carry the error code, and err
2141 * will return the human readable details.
2142 *
2143 * If the underlying LDAP connection has failed, status will return details
2144 * of the error, allowing an opportunity to clean up.
2145 *
2146 * When complete, return APR_SUCCESS to indicate you want to continue, or
2147 * a different code if you want the event loop to give up. This code will
2148 * be returned from apr_ldap_result().
2149 *
2150 * If this callback was called during a pool cleanup, the return value is
2151 * ignored.
2152 * @see apr_ldap_extended
2153 * @see apr_ldap_result
2154 */
2156 const char *roid,
2157 apr_buffer_t *rdata,
2158 void *ctx, apu_err_t *err);
2159
2160
2161
2162/**
2163 * APR LDAP extended operation function
2164 *
2165 * This function allows extended operations to be performed on
2166 * the directory.
2167 *
2168 * Extended operations are attempted asynchronously. For non blocking
2169 * behaviour, this function must be called after the underlying
2170 * socket has indicated that it is ready to write.
2171 *
2172 * In the absence of an error, apr_ldap_extended_operation will return
2173 * APR_WANT_READ or APR_WANT_WRITE to indicate that the next message
2174 * in the conversation be retrieved using apr_ldap_result().
2175 *
2176 * The outcome of the extended operation will be retrieved and handled by
2177 * the apr_ldap_process() function, and the outcome is passed to the
2178 * apr_ldap_extended_operation_cb provided.
2179 *
2180 * @param pool The pool that keeps track of the lifetime of the extended operation conversation.
2181 * If this pool is cleaned up, the extended operation conversation will be gracefully
2182 * abandoned without affecting other LDAP requests in progress. This pool need
2183 * not have any relationship with the LDAP connection pool.
2184 * @param ldap The ldap handle
2185 * @param oid The OID of the extended operation.
2186 * @param data The data used by the extended operation.
2187 * @param serverctrls NULL terminated array of server controls.
2188 * @param clientctrls NULL terminated array of client controls.
2189 * @param timeout The timeout to use for writes.
2190 * @param ext_cb The extended operation result callback function. When the extended operation process has
2191 * completed the success or failure of the extended operation is returned here. The callback
2192 * is triggered from inside apr_ldap_process() so that it is safe to write the
2193 * next LDAP request.
2194 * @param ctx Context passed to the delete callback.
2195 * @param err Error structure for reporting detailed results.
2196 *
2197 * @return APR_WANT_READ means that processing has occurred, and
2198 * the message in reply needs to be fetched using apr_ldap_result().
2199 * APR_SUCCESS means that the processing is complete, and the
2200 * extended operation has been successful. Other error codes indicate
2201 * that the extended operation was not successful.
2202 * @see apr_ldap_extended_cb
2203 * @see apr_ldap_process
2204 * @see apr_ldap_result
2205 */
2207 apr_ldap_t *ldap,
2208 const char *oid,
2209 apr_buffer_t *data,
2210 apr_array_header_t *serverctrls,
2211 apr_array_header_t *clientctrls,
2212 apr_interval_time_t timeout,
2213 apr_ldap_extended_cb ext_cb, void *ctx,
2214 apu_err_t *err)
2215 __attribute__((nonnull(1,2,3,10)));
2216
2217/**
2218 * APR LDAP unbind function
2219 *
2220 * This function unbinds from the LDAP server, and frees the connection handle.
2221 *
2222 * Calling this function is optional, the same effect can be achieved by cleaning up
2223 * the pool passed to apr_ldap_initialise().
2224 *
2225 * @see apr_ldap_initialise
2226 */
2228 apr_array_header_t *serverctrls,
2229 apr_array_header_t *clientctrls,
2230 apu_err_t *err)
2231 __attribute__((nonnull(1,4)));
2232
2233
2234#endif /* APU_HAS_LDAP */
2235/** @} */
2236#endif /* APU_LDAP_H */
APR Platform Definitions.
APR-UTIL Buffer.
APR-UTIL Escaping.
APR Hash Tables.
APR Network library.
APR Poll interface.
APR memory allocation.
APR-Util Error Codes.
apr_ldap_operation_e
Definition apr_ldap.h:1843
struct apr_ldap_driver_t apr_ldap_driver_t
Definition apr_ldap.h:259
apr_status_t apr_ldap_modify(apr_pool_t *pool, apr_ldap_t *ldap, const char *dn, apr_array_header_t *mods, apr_array_header_t *serverctrls, apr_array_header_t *clientctrls, apr_interval_time_t timeout, apr_ldap_modify_cb modify_cb, void *ctx, apu_err_t *err)
apr_ldap_rename_e
Definition apr_ldap.h:1960
#define APU_DECLARE_LDAP(type)
Definition apr_ldap.h:252
apr_status_t apr_ldap_process(apr_pool_t *pool, apr_ldap_t *ldap, apr_interval_time_t timeout, apu_err_t *err)
apr_status_t apr_ldap_search(apr_pool_t *pool, apr_ldap_t *ldap, const char *dn, apr_ldap_search_scope_e scope, const char *filter, const char **attrs, apr_ldap_switch_e attrsonly, apr_array_header_t *serverctrls, apr_array_header_t *clientctrls, apr_interval_time_t timeout, apr_ssize_t sizelimit, apr_ldap_search_result_cb search_result_cb, apr_ldap_search_entry_cb search_entry_cb, void *ctx, apu_err_t *err)
apr_status_t(* apr_ldap_add_cb)(apr_ldap_t *ldap, apr_status_t status, const char *matcheddn, apr_ldap_control_t **serverctrls, void *ctx, apu_err_t *err)
Definition apr_ldap.h:1776
apr_status_t apr_ldap_extended(apr_pool_t *pool, apr_ldap_t *ldap, const char *oid, apr_buffer_t *data, apr_array_header_t *serverctrls, apr_array_header_t *clientctrls, apr_interval_time_t timeout, apr_ldap_extended_cb ext_cb, void *ctx, apu_err_t *err)
apr_status_t apr_ldap_delete(apr_pool_t *pool, apr_ldap_t *ldap, const char *dn, apr_array_header_t *serverctrls, apr_array_header_t *clientctrls, apr_interval_time_t timeout, apr_ldap_delete_cb delete_cb, void *ctx, apu_err_t *err)
apr_status_t(* apr_ldap_search_entry_cb)(apr_ldap_t *ldap, const char *dn, apr_size_t eidx, apr_ldap_search_entry_t *entry, void *ctx, apu_err_t *err)
Definition apr_ldap.h:1654
apr_status_t apr_ldap_compare(apr_pool_t *pool, apr_ldap_t *ldap, const char *dn, const char *attr, const apr_buffer_t *val, apr_array_header_t *serverctrls, apr_array_header_t *clientctrls, apr_interval_time_t timeout, apr_ldap_compare_cb compare_cb, void *ctx, apu_err_t *err)
apr_status_t apr_ldap_initialise(apr_pool_t *pool, apr_ldap_t **ldap, apu_err_t *err)
apr_status_t apr_ldap_result(apr_pool_t *pool, apr_ldap_t *ldap, apr_interval_time_t timeout, apu_err_t *err)
int apr_ldap_is_ldap_url(const char *url)
apr_status_t apr_ldap_rename(apr_pool_t *pool, apr_ldap_t *ldap, const char *dn, const char *newrdn, const char *newparent, apr_ldap_rename_e flags, apr_array_header_t *serverctrls, apr_array_header_t *clientctrls, apr_interval_time_t timeout, apr_ldap_rename_cb rename_cb, void *ctx, apu_err_t *err)
int apr_ldap_is_ldapi_url(const char *url)
apr_ldap_deref_e
Definition apr_ldap.h:466
apr_status_t apr_ldap_prepare(apr_pool_t *pool, apr_ldap_t *ldap, apr_ldap_prepare_cb prepare_cb, void *prepare_ctx)
apr_status_t apr_ldap_add(apr_pool_t *pool, apr_ldap_t *ldap, const char *dn, apr_array_header_t *adds, apr_array_header_t *serverctrls, apr_array_header_t *clientctrls, apr_interval_time_t timeout, apr_ldap_add_cb add_cb, void *ctx, apu_err_t *err)
apr_ldap_bind_interact_e
Definition apr_ldap.h:1144
apr_ldap_search_scope_e
Definition apr_ldap.h:1575
apr_status_t() apr_ldap_bind_interact_cb(apr_ldap_t *ld, unsigned int flags, apr_ldap_bind_interact_t *interact, void *ctx)
Definition apr_ldap.h:1187
apr_ldap_verify_e
Definition apr_ldap.h:746
apr_status_t apr_ldap_get_driver(apr_pool_t *pool, const apr_ldap_driver_t **driver, apu_err_t *err)
apr_status_t(* apr_ldap_delete_cb)(apr_ldap_t *ldap, apr_status_t status, const char *matcheddn, apr_ldap_control_t **serverctrls, void *ctx, apu_err_t *err)
Definition apr_ldap.h:2074
apr_status_t apr_ldap_poll(apr_pool_t *pool, apr_ldap_t *ldap, apr_pollcb_t *poll, apr_interval_time_t timeout, apu_err_t *err)
apr_status_t apr_ldap_info(apr_pool_t *pool, apu_err_t **result_err)
int apr_ldap_is_ldaps_url(const char *url)
apr_status_t apr_ldap_bind(apr_pool_t *pool, apr_ldap_t *ldap, const char *mech, apr_ldap_bind_interact_cb *interact_cb, void *interact_ctx, apr_interval_time_t timeout, apr_ldap_bind_cb bind_cb, void *bind_ctx, apu_err_t *err)
int apr_ldap_url_parse_ext(apr_pool_t *pool, const char *url_in, apr_ldap_url_desc_t **ludpp, apu_err_t **result_err)
apr_status_t apr_ldap_option_get(apr_pool_t *pool, apr_ldap_t *ldap, int option, apr_ldap_opt_t *outvalue, apu_err_t *result_err)
apr_ldap_control_sortkey_e
Definition apr_ldap.h:1008
apr_status_t apr_ldap_option_set(apr_pool_t *pool, apr_ldap_t *ldap, int option, const apr_ldap_opt_t *invalue, apu_err_t *result_err)
apr_status_t(* apr_ldap_extended_cb)(apr_ldap_t *ldap, apr_status_t status, const char *roid, apr_buffer_t *rdata, void *ctx, apu_err_t *err)
Definition apr_ldap.h:2155
apr_ldap_control_e
Definition apr_ldap.h:944
apr_status_t(* apr_ldap_compare_cb)(apr_ldap_t *ldap, apr_status_t status, const char *matcheddn, apr_ldap_control_t **serverctrls, void *ctx, apu_err_t *err)
Definition apr_ldap.h:1503
apr_status_t(* apr_ldap_search_result_cb)(apr_ldap_t *ldap, apr_status_t status, apr_size_t count, const char *matcheddn, apr_hash_t *serverctrls, void *ctx, apu_err_t *err)
Definition apr_ldap.h:1610
apr_status_t apr_ldap_connect(apr_pool_t *pool, apr_ldap_t *ldap, apr_interval_time_t timeout, apu_err_t *result_err)
struct apr_ldap_t apr_ldap_t
Definition apr_ldap.h:309
apr_status_t(* apr_ldap_bind_cb)(apr_ldap_t *ldap, apr_status_t status, const char *matcheddn, apr_ldap_control_t **serverctrls, void *ctx, apu_err_t *err)
Definition apr_ldap.h:1384
apr_status_t apr_ldap_unbind(apr_ldap_t *ldap, apr_array_header_t *serverctrls, apr_array_header_t *clientctrls, apu_err_t *err)
apr_status_t(* apr_ldap_prepare_cb)(apr_ldap_t *ldap, apr_status_t status, void *ctx, apu_err_t *err)
Definition apr_ldap.h:1246
apr_ldap_debug_e
Definition apr_ldap.h:427
apr_ldap_switch_e
Definition apr_ldap.h:479
apr_ldap_protocol_version_e
Definition apr_ldap.h:411
apr_ldap_tls_e
Definition apr_ldap.h:732
int apr_ldap_url_parse(apr_pool_t *pool, const char *url_in, apr_ldap_url_desc_t **ludpp, apu_err_t **result_err)
apr_status_t(* apr_ldap_modify_cb)(apr_ldap_t *ldap, apr_status_t status, const char *matcheddn, apr_ldap_control_t **serverctrls, void *ctx, apu_err_t *err)
Definition apr_ldap.h:1892
apr_status_t(* apr_ldap_rename_cb)(apr_ldap_t *ldap, apr_status_t status, const char *matcheddn, apr_ldap_control_t **serverctrls, void *ctx, apu_err_t *err)
Definition apr_ldap.h:1988
@ APR_LDAP_MOD_DELETE
Definition apr_ldap.h:1847
@ APR_LDAP_MOD_REPLACE
Definition apr_ldap.h:1849
@ APR_LDAP_MOD_ADD
Definition apr_ldap.h:1845
@ APR_LDAP_MOD_INCREMENT
Definition apr_ldap.h:1851
@ APR_LDAP_RENAME_DELETEOLDRDN
Definition apr_ldap.h:1964
@ APR_LDAP_RENAME_NONE
Definition apr_ldap.h:1962
@ APR_LDAP_DEREF_NEVER
Definition apr_ldap.h:467
@ APR_LDAP_DEREF_SEARCHING
Definition apr_ldap.h:468
@ APR_LDAP_DEREF_FINDING
Definition apr_ldap.h:469
@ APR_LDAP_DEREF_ALWAYS
Definition apr_ldap.h:470
@ APR_LDAP_INTERACT_GETREALM
Definition apr_ldap.h:1146
@ APR_LDAP_INTERACT_AUTHNAME
Definition apr_ldap.h:1147
@ APR_LDAP_INTERACT_USER
Definition apr_ldap.h:1148
@ APR_LDAP_INTERACT_DN
Definition apr_ldap.h:1145
@ APR_LDAP_INTERACT_ECHOPROMPT
Definition apr_ldap.h:1151
@ APR_LDAP_INTERACT_NOECHOPROMPT
Definition apr_ldap.h:1150
@ APR_LDAP_INTERACT_PASS
Definition apr_ldap.h:1149
@ APR_LDAP_SCOPE_ONELEVEL
Definition apr_ldap.h:1579
@ APR_LDAP_SCOPE_SUBORDINATE
Definition apr_ldap.h:1583
@ APR_LDAP_SCOPE_SUBTREE
Definition apr_ldap.h:1581
@ APR_LDAP_SCOPE_BASE
Definition apr_ldap.h:1577
@ APR_LDAP_VERIFY_OFF
Definition apr_ldap.h:748
@ APR_LDAP_VERIFY_ON
Definition apr_ldap.h:750
@ APR_LDAP_CONTROL_SORT_FORWARD
Definition apr_ldap.h:1010
@ APR_LDAP_CONTROL_SORT_REVERSE
Definition apr_ldap.h:1012
@ APR_LDAP_CONTROL_PAGE_RESPONSE
Definition apr_ldap.h:954
@ APR_LDAP_CONTROL_VLV_REQUEST
Definition apr_ldap.h:956
@ APR_LDAP_CONTROL_PAGE_REQUEST
Definition apr_ldap.h:952
@ APR_LDAP_CONTROL_VLV_RESPONSE
Definition apr_ldap.h:958
@ APR_LDAP_CONTROL_SORT_REQUEST
Definition apr_ldap.h:948
@ APR_LDAP_CONTROL_SORT_RESPONSE
Definition apr_ldap.h:950
@ APR_LDAP_CONTROL_OID
Definition apr_ldap.h:946
@ LDAP_DEBUG_SHELL
Definition apr_ldap.h:449
@ LDAP_DEBUG_ARGS
Definition apr_ldap.h:433
@ LDAP_DEBUG_PACKETS
Definition apr_ldap.h:431
@ LDAP_DEBUG_STATS
Definition apr_ldap.h:445
@ LDAP_DEBUG_PARSE
Definition apr_ldap.h:451
@ LDAP_DEBUG_STATS2
Definition apr_ldap.h:447
@ LDAP_DEBUG_CONFIG
Definition apr_ldap.h:441
@ LDAP_DEBUG_SYNC
Definition apr_ldap.h:453
@ LDAP_DEBUG_BER
Definition apr_ldap.h:437
@ LDAP_DEBUG_ANY
Definition apr_ldap.h:457
@ LDAP_DEBUG_ACL
Definition apr_ldap.h:443
@ LDAP_DEBUG_FILTER
Definition apr_ldap.h:439
@ LDAP_DEBUG_NONE
Definition apr_ldap.h:455
@ LDAP_DEBUG_TRACE
Definition apr_ldap.h:429
@ LDAP_DEBUG_CONNS
Definition apr_ldap.h:435
@ APR_LDAP_OPT_ON
Definition apr_ldap.h:481
@ APR_LDAP_OPT_OFF
Definition apr_ldap.h:480
@ APR_LDAP_VERSION1
Definition apr_ldap.h:413
@ APR_LDAP_VERSION2
Definition apr_ldap.h:415
@ APR_LDAP_VERSION3
Definition apr_ldap.h:417
@ APR_LDAP_TLS_STOPTLS
Definition apr_ldap.h:736
@ APR_LDAP_TLS_NONE
Definition apr_ldap.h:733
@ APR_LDAP_TLS_SSL
Definition apr_ldap.h:734
@ APR_LDAP_TLS_STARTTLS
Definition apr_ldap.h:735
int apr_status_t
Definition apr_errno.h:44
struct apr_hash_t apr_hash_t
Definition apr_hash.h:52
struct apr_socket_t apr_socket_t
Definition apr_network_io.h:219
#define APR_DECLARE(type)
Definition apr.h:523
struct apr_pollcb_t apr_pollcb_t
Definition apr_poll.h:318
struct apr_pool_t apr_pool_t
Definition apr_pools.h:60
apr_int64_t apr_interval_time_t
Definition apr_time.h:55
Definition apr_tables.h:62
Definition apr_buffer.h:69
Definition apr_ldap.h:398
const char * name
Definition apr_ldap.h:400
int version
Definition apr_ldap.h:402
Definition apr_ldap.h:375
int protocol_version
Definition apr_ldap.h:379
int vendor_version
Definition apr_ldap.h:385
int api_version
Definition apr_ldap.h:377
const char * vendor_name
Definition apr_ldap.h:383
const char ** extensions
Definition apr_ldap.h:381
Definition apr_ldap.h:1165
const char * defresult
Definition apr_ldap.h:1173
apr_ldap_bind_interact_e id
Definition apr_ldap.h:1167
const char * prompt
Definition apr_ldap.h:1171
apr_buffer_t result
Definition apr_ldap.h:1175
const char * challenge
Definition apr_ldap.h:1169
Definition apr_ldap.h:993
apr_buffer_t val
Definition apr_ldap.h:997
const char * oid
Definition apr_ldap.h:995
Definition apr_ldap.h:1040
apr_size_t size
Definition apr_ldap.h:1042
apr_buffer_t cookie
Definition apr_ldap.h:1044
Definition apr_ldap.h:1050
apr_buffer_t cookie
Definition apr_ldap.h:1054
apr_size_t count
Definition apr_ldap.h:1052
Definition apr_ldap.h:1018
const char * attribute
Definition apr_ldap.h:1020
const char * order
Definition apr_ldap.h:1022
apr_ldap_control_sortkey_e direction
Definition apr_ldap.h:1024
Definition apr_ldap.h:1003
apr_array_header_t * keys
Definition apr_ldap.h:1005
Definition apr_ldap.h:1030
apr_status_t result
Definition apr_ldap.h:1034
const char * attribute
Definition apr_ldap.h:1032
Definition apr_ldap.h:1112
apr_ldap_control_e type
Definition apr_ldap.h:1114
apr_ldap_control_sortresponse_t sortrs
Definition apr_ldap.h:1124
union apr_ldap_control_t::@6 c
apr_ldap_control_vlvrequest_t vlvrq
Definition apr_ldap.h:1130
apr_ldap_control_pagerequest_t pagerq
Definition apr_ldap.h:1126
apr_ldap_control_sortrequest_t sortrq
Definition apr_ldap.h:1122
apr_ldap_control_pageresponse_t pagers
Definition apr_ldap.h:1128
apr_ldap_control_vlvresponse_t vlvrs
Definition apr_ldap.h:1132
int critical
Definition apr_ldap.h:1116
apr_ldap_control_oid_t oid
Definition apr_ldap.h:1118
Definition apr_ldap.h:1060
apr_size_t offset
Definition apr_ldap.h:1066
apr_size_t after
Definition apr_ldap.h:1064
apr_size_t before
Definition apr_ldap.h:1062
apr_buffer_t attrvalue
Definition apr_ldap.h:1070
apr_buffer_t context
Definition apr_ldap.h:1072
apr_size_t count
Definition apr_ldap.h:1068
Definition apr_ldap.h:1078
apr_size_t count
Definition apr_ldap.h:1082
apr_status_t result
Definition apr_ldap.h:1084
apr_buffer_t context
Definition apr_ldap.h:1086
apr_size_t offset
Definition apr_ldap.h:1080
Definition apr_ldap.h:1863
apr_ldap_pair_t pair
Definition apr_ldap.h:1867
apr_ldap_operation_e op
Definition apr_ldap.h:1865
Definition apr_ldap.h:714
const char * password
Definition apr_ldap.h:720
const char * path
Definition apr_ldap.h:718
int type
Definition apr_ldap.h:716
Definition apr_ldap.h:1748
apr_array_header_t * vals
Definition apr_ldap.h:1752
const char * attr
Definition apr_ldap.h:1750
Definition apr_ldap.h:1624
apr_size_t nattrs
Definition apr_ldap.h:1626
int flags
Definition apr_ldap.h:1638
apr_buffer_t val
Definition apr_ldap.h:1636
apr_size_t vidx
Definition apr_ldap.h:1634
apr_size_t aidx
Definition apr_ldap.h:1628
apr_size_t nvals
Definition apr_ldap.h:1632
const char * attr
Definition apr_ldap.h:1630
Definition apr_ldap.h:93
char ** lud_exts
Definition apr_ldap.h:111
int lud_scope
Definition apr_ldap.h:107
char * lud_host
Definition apr_ldap.h:99
int lud_crit_exts
Definition apr_ldap.h:113
char * lud_filter
Definition apr_ldap.h:109
char * lud_dn
Definition apr_ldap.h:103
char * lud_scheme
Definition apr_ldap.h:97
char ** lud_attrs
Definition apr_ldap.h:105
struct apr_ldap_url_desc_t * lud_next
Definition apr_ldap.h:95
int lud_port
Definition apr_ldap.h:101
Definition apu_errno.h:418
Definition apr_ldap.h:761
int result
Definition apr_ldap.h:849
const char * uri
Definition apr_ldap.h:782
apr_ldap_protocol_version_e pv
Definition apr_ldap.h:800
apr_ldap_tls_e tls
Definition apr_ldap.h:819
apr_socket_t * socket
Definition apr_ldap.h:776
apr_ldap_debug_e debug
Definition apr_ldap.h:855
void * handle
Definition apr_ldap.h:766
apr_ldap_deref_e deref
Definition apr_ldap.h:831
void * opt
Definition apr_ldap.h:770
int refhoplimit
Definition apr_ldap.h:843
apr_interval_time_t timeout
Definition apr_ldap.h:813
apr_ldap_switch_e refs
Definition apr_ldap.h:837
apr_ldap_verify_e verify
Definition apr_ldap.h:825
apr_array_header_t * certs
Definition apr_ldap.h:806
apr_ldap_apifeature_info_t ldfi
Definition apr_ldap.h:794
apr_ldap_apiinfo_t info
Definition apr_ldap.h:788