3 * Copyright 1998-2001 The OpenLDAP Foundation, Redwood City, California, USA
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted only as authorized by the OpenLDAP
8 * Public License. A copy of this license is available at
9 * http://www.OpenLDAP.org/license.html or in file LICENSE in the
10 * top-level directory of the distribution.
13 * Copyright (c) 1990 Regents of the University of Michigan.
14 * All rights reserved.
16 * Redistribution and use in source and binary forms are permitted
17 * provided that this notice is preserved and that due credit is given
18 * to the University of Michigan at Ann Arbor. The name of the University
19 * may not be used to endorse or promote products derived from this
20 * software without specific prior written permission. This software
21 * is provided ``as is'' without express or implied warranty.
32 #define LDAP_VERSION1 1
33 #define LDAP_VERSION2 2
34 #define LDAP_VERSION3 3
36 #define LDAP_VERSION_MIN LDAP_VERSION2
37 #define LDAP_VERSION LDAP_VERSION2
38 #define LDAP_VERSION_MAX LDAP_VERSION3
41 * We'll use 2000+draft revision for our API version number
42 * As such, the number will be above the old RFC but below
43 * whatever number does finally get assigned
45 #define LDAP_API_VERSION 2004
46 #define LDAP_VENDOR_NAME "OpenLDAP"
49 * vendor version number
53 #define LDAP_VENDOR_VERSION 20017
55 /* OpenLDAP API Features */
56 #define LDAP_API_FEATURE_X_OPENLDAP LDAP_VENDOR_VERSION
58 /* include LDAP_API_FEATURE defines */
59 #include <ldap_features.h>
61 #if defined( LDAP_API_FEATURE_X_OPENLDAP_REENTRANT ) || \
62 ( defined( LDAP_THREAD_SAFE ) && \
63 defined( LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE ) )
64 /* -lldap may or may not be thread safe */
65 /* -lldap_r, if available, is always thread safe */
66 # define LDAP_API_FEATURE_THREAD_SAFE 1
68 #if defined( LDAP_THREAD_SAFE ) && \
69 defined( LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE )
70 /* #define LDAP_API_FEATURE_SESSION_SAFE 1 */
71 /* #define LDAP_API_OPERATION_SESSION_SAFE 1 */
74 #define LDAP_PORT 389 /* ldap:/// default LDAP port */
75 #define LDAPS_PORT 636 /* ldaps:/// default LDAP over TLS port */
77 #define LDAP_ROOT_DSE ""
78 #define LDAP_NO_ATTRS "1.1"
79 #define LDAP_ALL_USER_ATTRIBUTES "*"
80 #define LDAP_ALL_OPERATIONAL_ATTRIBUTES "+" /* OpenLDAP extension */
83 * LDAP_OPTions defined by draft-ldapext-ldap-c-api-02
84 * 0x0000 - 0x0fff reserved for api options
85 * 0x1000 - 0x3fff reserved for api extended options
86 * 0x4000 - 0x7fff reserved for private and experimental options
88 #define LDAP_OPT_API_INFO 0x0000
89 #define LDAP_OPT_DESC 0x0001 /* deprecated */
90 #define LDAP_OPT_DEREF 0x0002
91 #define LDAP_OPT_SIZELIMIT 0x0003
92 #define LDAP_OPT_TIMELIMIT 0x0004
93 /* 0x05 - 0x07 not defined by current draft */
94 #define LDAP_OPT_REFERRALS 0x0008
95 #define LDAP_OPT_RESTART 0x0009
96 /* 0x0a - 0x10 not defined by current draft */
97 #define LDAP_OPT_PROTOCOL_VERSION 0x0011
98 #define LDAP_OPT_SERVER_CONTROLS 0x0012
99 #define LDAP_OPT_CLIENT_CONTROLS 0x0013
100 /* 0x14 not defined by current draft */
101 #define LDAP_OPT_API_FEATURE_INFO 0x0015
103 /* 0x16 - 0x2f not defined by current draft */
104 #define LDAP_OPT_HOST_NAME 0x0030
105 #define LDAP_OPT_ERROR_NUMBER 0x0031
106 #define LDAP_OPT_ERROR_STRING 0x0032
107 #define LDAP_OPT_MATCHED_DN 0x0033
109 /* 0x34 - 0x0fff not defined by current draft */
111 #define LDAP_OPT_PRIVATE_EXTENSION_BASE 0x4000 /* to 0x7FFF inclusive */
113 /* private and experimental options */
114 /* OpenLDAP specific options */
115 #define LDAP_OPT_DEBUG_LEVEL 0x5001 /* debug level */
116 #define LDAP_OPT_TIMEOUT 0x5002 /* default timeout */
117 #define LDAP_OPT_REFHOPLIMIT 0x5003 /* ref hop limit */
118 #define LDAP_OPT_NETWORK_TIMEOUT 0x5005 /* socket level timeout */
119 #define LDAP_OPT_URI 0x5006
121 /* OpenLDAP TLS options */
122 #define LDAP_OPT_X_TLS 0x6000
123 #define LDAP_OPT_X_TLS_CTX 0x6001 /* SSL CTX */
124 #define LDAP_OPT_X_TLS_CACERTFILE 0x6002
125 #define LDAP_OPT_X_TLS_CACERTDIR 0x6003
126 #define LDAP_OPT_X_TLS_CERTFILE 0x6004
127 #define LDAP_OPT_X_TLS_KEYFILE 0x6005
128 #define LDAP_OPT_X_TLS_REQUIRE_CERT 0x6006
129 /* #define LDAP_OPT_X_TLS_PROTOCOL 0x6007 */
130 #define LDAP_OPT_X_TLS_CIPHER_SUITE 0x6008
131 #define LDAP_OPT_X_TLS_RANDOM_FILE 0x6009
133 #define LDAP_OPT_X_TLS_NEVER 0
134 #define LDAP_OPT_X_TLS_HARD 1
135 #define LDAP_OPT_X_TLS_DEMAND 2
136 #define LDAP_OPT_X_TLS_ALLOW 3
137 #define LDAP_OPT_X_TLS_TRY 4
139 /* OpenLDAP SASL options */
140 #define LDAP_OPT_X_SASL_MECH 0x6100
141 #define LDAP_OPT_X_SASL_REALM 0x6101
142 #define LDAP_OPT_X_SASL_AUTHCID 0x6102
143 #define LDAP_OPT_X_SASL_AUTHZID 0x6103
144 #define LDAP_OPT_X_SASL_SSF 0x6104 /* read-only */
145 #define LDAP_OPT_X_SASL_SSF_EXTERNAL 0x6105 /* write-only */
146 #define LDAP_OPT_X_SASL_SECPROPS 0x6106 /* write-only */
147 #define LDAP_OPT_X_SASL_SSF_MIN 0x6107
148 #define LDAP_OPT_X_SASL_SSF_MAX 0x6108
149 #define LDAP_OPT_X_SASL_MAXBUFSIZE 0x6109
153 #define LDAP_OPT_ON ((void *) 1)
154 #define LDAP_OPT_OFF ((void *) 0)
157 * ldap_get_option() and ldap_set_option() return values.
158 * As later versions may return other values indicating
159 * failure, current applications should only compare returned
160 * value against LDAP_OPT_SUCCESS.
162 #define LDAP_OPT_SUCCESS 0
163 #define LDAP_OPT_ERROR (-1)
165 #define LDAP_API_INFO_VERSION (1)
166 typedef struct ldapapiinfo {
167 int ldapai_info_version; /* version of LDAPAPIInfo (1) */
168 int ldapai_api_version; /* revision of API supported */
169 int ldapai_protocol_version; /* highest LDAP version supported */
170 char **ldapai_extensions; /* names of API extensions */
171 char *ldapai_vendor_name; /* name of supplier */
172 int ldapai_vendor_version; /* supplier-specific version * 100 */
175 #define LDAP_FEATURE_INFO_VERSION (1) /* version of api feature structure */
176 typedef struct ldap_apifeature_info {
177 int ldapaif_info_version; /* version of this struct (1) */
178 char* ldapaif_name; /* matches LDAP_API_FEATURE_... less the prefix */
179 int ldapaif_version; /* matches the value LDAP_API_FEATURE_... */
180 } LDAPAPIFeatureInfo;
182 typedef struct ldapcontrol {
184 struct berval ldctl_value;
185 char ldctl_iscritical;
191 /* chase referrals client control (not yet implemented) */
192 #define LDAP_CONTROL_REFERRALS "1.2.840.113666.1.4.616"
193 #define LDAP_CHASE_SUBORDINATE_REFERRALS 0x0020U
194 #define LDAP_CHASE_EXTERNAL_REFERRALS 0x0040U
197 #define LDAP_CONTROL_MANAGEDSAIT "2.16.840.1.113730.3.4.2"
199 /* Experimental Controls */
201 #define LDAP_CONTROL_SORTREQUEST "1.2.840.113556.1.4.473"
202 #define LDAP_CONTROL_SORTRESPONSE "1.2.840.113556.1.4.474"
203 #define LDAP_CONTROL_VLVREQUEST "2.16.840.1.113730.3.4.9"
204 #define LDAP_CONTROL_VLVRESPONSE "2.16.840.1.113730.3.4.10"
206 /* LDAP Unsolicited Notifications */
207 #define LDAP_NOTICE_OF_DISCONNECTION "1.3.6.1.4.1.1466.20036"
208 #define LDAP_NOTICE_DISCONNECT LDAP_NOTICE_OF_DISCONNECTION
210 /* LDAP Extended Operations */
211 #define LDAP_EXOP_START_TLS "1.3.6.1.4.1.1466.20037"
213 #define LDAP_EXOP_X_MODIFY_PASSWD "1.3.6.1.4.1.4203.1.11.1"
214 #define LDAP_TAG_EXOP_X_MODIFY_PASSWD_ID ((ber_tag_t) 0x80U)
215 #define LDAP_TAG_EXOP_X_MODIFY_PASSWD_OLD ((ber_tag_t) 0x81U)
216 #define LDAP_TAG_EXOP_X_MODIFY_PASSWD_NEW ((ber_tag_t) 0x82U)
217 #define LDAP_TAG_EXOP_X_MODIFY_PASSWD_GEN ((ber_tag_t) 0x80U)
220 * specific LDAP instantiations of BER types we know about
223 /* Overview of LBER tag construction
230 * 1 0 = CONTEXT-SPECIFIC
237 * | 5 ... 1 | TAG-NUMBER
241 #define LDAP_TAG_MESSAGE ((ber_tag_t) 0x30U) /* constructed + 16 */
242 #define LDAP_TAG_MSGID ((ber_tag_t) 0x02U) /* integer */
243 #define LDAP_TAG_LDAPDN ((ber_tag_t) 0x04U) /* octect string */
244 #define LDAP_TAG_LDAPCRED ((ber_tag_t) 0x04U) /* octect string */
245 #define LDAP_TAG_CONTROLS ((ber_tag_t) 0xa0U) /* context specific + constructed + 0 */
246 #define LDAP_TAG_REFERRAL ((ber_tag_t) 0xa3U) /* context specific + constructed + 3 */
248 #define LDAP_TAG_NEWSUPERIOR ((ber_tag_t) 0x80U) /* context-specific + primitive + 0 */
250 #define LDAP_TAG_EXOP_REQ_OID ((ber_tag_t) 0x80U) /* context specific + primitive */
251 #define LDAP_TAG_EXOP_REQ_VALUE ((ber_tag_t) 0x81U) /* context specific + primitive */
252 #define LDAP_TAG_EXOP_RES_OID ((ber_tag_t) 0x8aU) /* context specific + primitive */
253 #define LDAP_TAG_EXOP_RES_VALUE ((ber_tag_t) 0x8bU) /* context specific + primitive */
255 #define LDAP_TAG_SASL_RES_CREDS ((ber_tag_t) 0x87U) /* context specific + primitive */
258 /* possible operations a client can invoke */
259 #define LDAP_REQ_BIND ((ber_tag_t) 0x60U) /* application + constructed */
260 #define LDAP_REQ_UNBIND ((ber_tag_t) 0x42U) /* application + primitive */
261 #define LDAP_REQ_SEARCH ((ber_tag_t) 0x63U) /* application + constructed */
262 #define LDAP_REQ_MODIFY ((ber_tag_t) 0x66U) /* application + constructed */
263 #define LDAP_REQ_ADD ((ber_tag_t) 0x68U) /* application + constructed */
264 #define LDAP_REQ_DELETE ((ber_tag_t) 0x4aU) /* application + primitive */
265 #define LDAP_REQ_MODDN ((ber_tag_t) 0x6cU) /* application + constructed */
266 #define LDAP_REQ_MODRDN LDAP_REQ_MODDN
267 #define LDAP_REQ_RENAME LDAP_REQ_MODDN
268 #define LDAP_REQ_COMPARE ((ber_tag_t) 0x6eU) /* application + constructed */
269 #define LDAP_REQ_ABANDON ((ber_tag_t) 0x50U) /* application + primitive */
270 #define LDAP_REQ_EXTENDED ((ber_tag_t) 0x77U) /* application + constructed */
272 /* possible result types a server can return */
273 #define LDAP_RES_BIND ((ber_tag_t) 0x61U) /* application + constructed */
274 #define LDAP_RES_SEARCH_ENTRY ((ber_tag_t) 0x64U) /* application + constructed */
275 #define LDAP_RES_SEARCH_REFERENCE ((ber_tag_t) 0x73U) /* V3: application + constructed */
276 #define LDAP_RES_SEARCH_RESULT ((ber_tag_t) 0x65U) /* application + constructed */
277 #define LDAP_RES_MODIFY ((ber_tag_t) 0x67U) /* application + constructed */
278 #define LDAP_RES_ADD ((ber_tag_t) 0x69U) /* application + constructed */
279 #define LDAP_RES_DELETE ((ber_tag_t) 0x6bU) /* application + constructed */
280 #define LDAP_RES_MODDN ((ber_tag_t) 0x6dU) /* application + constructed */
281 #define LDAP_RES_MODRDN LDAP_RES_MODDN /* application + constructed */
282 #define LDAP_RES_RENAME LDAP_RES_MODDN /* application + constructed */
283 #define LDAP_RES_COMPARE ((ber_tag_t) 0x6fU) /* application + constructed */
284 #define LDAP_RES_EXTENDED ((ber_tag_t) 0x78U) /* V3: application + constructed */
285 #define LDAP_RES_EXTENDED_PARTIAL ((ber_tag_t) 0x79U) /* V3+: application + constructed */
287 #define LDAP_RES_ANY (-1)
288 #define LDAP_RES_UNSOLICITED (0)
292 #define LDAP_SASL_SIMPLE ((char*)0)
293 #define LDAP_SASL_NULL ("")
296 /* authentication methods available */
297 #define LDAP_AUTH_NONE ((ber_tag_t) 0x00U) /* no authentication */
298 #define LDAP_AUTH_SIMPLE ((ber_tag_t) 0x80U) /* context specific + primitive */
299 #define LDAP_AUTH_SASL ((ber_tag_t) 0xa3U) /* context specific + constructed */
300 #define LDAP_AUTH_KRBV4 ((ber_tag_t) 0xffU) /* means do both of the following */
301 #define LDAP_AUTH_KRBV41 ((ber_tag_t) 0x81U) /* context specific + primitive */
302 #define LDAP_AUTH_KRBV42 ((ber_tag_t) 0x82U) /* context specific + primitive */
306 #define LDAP_FILTER_AND ((ber_tag_t) 0xa0U) /* context specific + constructed */
307 #define LDAP_FILTER_OR ((ber_tag_t) 0xa1U) /* context specific + constructed */
308 #define LDAP_FILTER_NOT ((ber_tag_t) 0xa2U) /* context specific + constructed */
309 #define LDAP_FILTER_EQUALITY ((ber_tag_t) 0xa3U) /* context specific + constructed */
310 #define LDAP_FILTER_SUBSTRINGS ((ber_tag_t) 0xa4U) /* context specific + constructed */
311 #define LDAP_FILTER_GE ((ber_tag_t) 0xa5U) /* context specific + constructed */
312 #define LDAP_FILTER_LE ((ber_tag_t) 0xa6U) /* context specific + constructed */
313 #define LDAP_FILTER_PRESENT ((ber_tag_t) 0x87U) /* context specific + primitive */
314 #define LDAP_FILTER_APPROX ((ber_tag_t) 0xa8U) /* context specific + constructed */
315 #define LDAP_FILTER_EXT ((ber_tag_t) 0xa9U) /* context specific + constructed */
317 /* extended filter component types */
318 #define LDAP_FILTER_EXT_OID ((ber_tag_t) 0x81U) /* context specific */
319 #define LDAP_FILTER_EXT_TYPE ((ber_tag_t) 0x82U) /* context specific */
320 #define LDAP_FILTER_EXT_VALUE ((ber_tag_t) 0x83U) /* context specific */
321 #define LDAP_FILTER_EXT_DNATTRS ((ber_tag_t) 0x84U) /* context specific */
323 /* substring filter component types */
324 #define LDAP_SUBSTRING_INITIAL ((ber_tag_t) 0x80U) /* context specific */
325 #define LDAP_SUBSTRING_ANY ((ber_tag_t) 0x81U) /* context specific */
326 #define LDAP_SUBSTRING_FINAL ((ber_tag_t) 0x82U) /* context specific */
329 #define LDAP_SCOPE_DEFAULT ((ber_int_t) -1)
330 #define LDAP_SCOPE_BASE ((ber_int_t) 0x0000)
331 #define LDAP_SCOPE_ONELEVEL ((ber_int_t) 0x0001)
332 #define LDAP_SCOPE_SUBTREE ((ber_int_t) 0x0002)
334 /* substring filter component types */
335 #define LDAP_SUBSTRING_INITIAL ((ber_tag_t) 0x80U) /* context specific */
336 #define LDAP_SUBSTRING_ANY ((ber_tag_t) 0x81U) /* context specific */
337 #define LDAP_SUBSTRING_FINAL ((ber_tag_t) 0x82U) /* context specific */
340 * possible error codes we can return
343 #define LDAP_RANGE(n,x,y) (((x) <= (n)) && ((n) <= (y)))
345 #define LDAP_SUCCESS 0x00
346 #define LDAP_OPERATIONS_ERROR 0x01
347 #define LDAP_PROTOCOL_ERROR 0x02
348 #define LDAP_TIMELIMIT_EXCEEDED 0x03
349 #define LDAP_SIZELIMIT_EXCEEDED 0x04
350 #define LDAP_COMPARE_FALSE 0x05
351 #define LDAP_COMPARE_TRUE 0x06
352 #define LDAP_AUTH_METHOD_NOT_SUPPORTED 0x07
353 #define LDAP_STRONG_AUTH_NOT_SUPPORTED LDAP_AUTH_METHOD_NOT_SUPPORTED
354 #define LDAP_STRONG_AUTH_REQUIRED 0x08
355 #define LDAP_PARTIAL_RESULTS 0x09 /* LDAPv2+ (not LDAPv3) */
357 #define LDAP_REFERRAL 0x0a /* LDAPv3 */
358 #define LDAP_ADMINLIMIT_EXCEEDED 0x0b /* LDAPv3 */
359 #define LDAP_UNAVAILABLE_CRITICAL_EXTENSION 0x0c /* LDAPv3 */
360 #define LDAP_CONFIDENTIALITY_REQUIRED 0x0d /* LDAPv3 */
361 #define LDAP_SASL_BIND_IN_PROGRESS 0x0e /* LDAPv3 */
363 #define LDAP_ATTR_ERROR(n) LDAP_RANGE((n),0x10,0x15) /* 16-21 */
365 #define LDAP_NO_SUCH_ATTRIBUTE 0x10
366 #define LDAP_UNDEFINED_TYPE 0x11
367 #define LDAP_INAPPROPRIATE_MATCHING 0x12
368 #define LDAP_CONSTRAINT_VIOLATION 0x13
369 #define LDAP_TYPE_OR_VALUE_EXISTS 0x14
370 #define LDAP_INVALID_SYNTAX 0x15
372 #define LDAP_NAME_ERROR(n) LDAP_RANGE((n),0x20,0x24) /* 32-34,36 */
374 #define LDAP_NO_SUCH_OBJECT 0x20
375 #define LDAP_ALIAS_PROBLEM 0x21
376 #define LDAP_INVALID_DN_SYNTAX 0x22
377 #define LDAP_IS_LEAF 0x23 /* not LDAPv3 */
378 #define LDAP_ALIAS_DEREF_PROBLEM 0x24
380 #define LDAP_SECURITY_ERROR(n) LDAP_RANGE((n),0x30,0x32) /* 48-50 */
382 #define LDAP_INAPPROPRIATE_AUTH 0x30
383 #define LDAP_INVALID_CREDENTIALS 0x31
384 #define LDAP_INSUFFICIENT_ACCESS 0x32
386 #define LDAP_SERVICE_ERROR(n) LDAP_RANGE((n),0x33,0x36) /* 51-54 */
388 #define LDAP_BUSY 0x33
389 #define LDAP_UNAVAILABLE 0x34
390 #define LDAP_UNWILLING_TO_PERFORM 0x35
391 #define LDAP_LOOP_DETECT 0x36
393 #define LDAP_UPDATE_ERROR(n) LDAP_RANGE((n),0x40,0x47) /* 64-69,71 */
395 #define LDAP_NAMING_VIOLATION 0x40
396 #define LDAP_OBJECT_CLASS_VIOLATION 0x41
397 #define LDAP_NOT_ALLOWED_ON_NONLEAF 0x42
398 #define LDAP_NOT_ALLOWED_ON_RDN 0x43
399 #define LDAP_ALREADY_EXISTS 0x44
400 #define LDAP_NO_OBJECT_CLASS_MODS 0x45
401 #define LDAP_RESULTS_TOO_LARGE 0x46 /* CLDAP */
402 #define LDAP_AFFECTS_MULTIPLE_DSAS 0x47 /* LDAPv3 */
404 #define LDAP_OTHER 0x50
406 #define LDAP_API_ERROR(n) LDAP_RANGE((n),0x51,0x61) /* 81-97 */
407 #define LDAP_API_RESULT(n) (((n) == LDAP_SUCCESS) || \
408 LDAP_RANGE((n),0x51,0x61)) /* 0,81-97 */
410 #define LDAP_SERVER_DOWN 0x51
411 #define LDAP_LOCAL_ERROR 0x52
412 #define LDAP_ENCODING_ERROR 0x53
413 #define LDAP_DECODING_ERROR 0x54
414 #define LDAP_TIMEOUT 0x55
415 #define LDAP_AUTH_UNKNOWN 0x56
416 #define LDAP_FILTER_ERROR 0x57
417 #define LDAP_USER_CANCELLED 0x58
418 #define LDAP_PARAM_ERROR 0x59
419 #define LDAP_NO_MEMORY 0x5a
421 /* not technically reserved for APIs */
422 #define LDAP_CONNECT_ERROR 0x5b /* draft-ietf-ldap-c-api-xx */
423 #define LDAP_NOT_SUPPORTED 0x5c /* draft-ietf-ldap-c-api-xx */
424 #define LDAP_CONTROL_NOT_FOUND 0x5d /* draft-ietf-ldap-c-api-xx */
425 #define LDAP_NO_RESULTS_RETURNED 0x5e /* draft-ietf-ldap-c-api-xx */
426 #define LDAP_MORE_RESULTS_TO_RETURN 0x5f /* draft-ietf-ldap-c-api-xx */
427 #define LDAP_CLIENT_LOOP 0x60 /* draft-ietf-ldap-c-api-xx */
428 #define LDAP_REFERRAL_LIMIT_EXCEEDED 0x61 /* draft-ietf-ldap-c-api-xx */
431 * This structure represents both ldap messages and ldap responses.
432 * These are really the same, except in the case of search responses,
433 * where a response has multiple messages.
436 typedef struct ldapmsg LDAPMessage;
438 /* for modifications */
439 typedef struct ldapmod {
442 #define LDAP_MOD_ADD ((ber_int_t) 0x0000)
443 #define LDAP_MOD_DELETE ((ber_int_t) 0x0001)
444 #define LDAP_MOD_REPLACE ((ber_int_t) 0x0002)
445 #define LDAP_MOD_BVALUES ((ber_int_t) 0x0080)
446 /* IMPORTANT: do not use code 0x1000 (or above),
447 * it is used internally by the backends!
448 * (see ldap/servers/slapd/slap.h)
454 struct berval **modv_bvals;
456 #define mod_values mod_vals.modv_strvals
457 #define mod_bvalues mod_vals.modv_bvals
461 * structures for ldap getfilter routines
464 typedef struct ldap_filt_info {
469 struct ldap_filt_info *lfi_next;
472 typedef struct ldap_filt_list {
476 LDAPFiltInfo *lfl_ilist;
477 struct ldap_filt_list *lfl_next;
481 #define LDAP_FILT_MAXSIZ 1024
483 typedef struct ldap_filt_desc {
484 LDAPFiltList *lfd_filtlist;
485 LDAPFiltInfo *lfd_curfip;
486 LDAPFiltInfo lfd_retfi;
487 char lfd_filter[ LDAP_FILT_MAXSIZ ];
489 char *lfd_curvalcopy;
490 char **lfd_curvalwords;
491 char *lfd_filtprefix;
492 char *lfd_filtsuffix;
497 * structure representing an ldap session which can
498 * encompass connections to multiple servers (in the
499 * face of referrals).
501 typedef struct ldap LDAP;
503 #define LDAP_DEREF_NEVER 0x00
504 #define LDAP_DEREF_SEARCHING 0x01
505 #define LDAP_DEREF_FINDING 0x02
506 #define LDAP_DEREF_ALWAYS 0x03
508 #define LDAP_NO_LIMIT 0
510 /* how many messages to retrieve results for */
511 #define LDAP_MSG_ONE 0x00
512 #define LDAP_MSG_ALL 0x01
513 #define LDAP_MSG_RECEIVED 0x02
516 * structure for ldap friendly mapping routines
519 typedef struct ldap_friendly {
525 * types for ldap URL handling
527 typedef struct ldap_url_desc {
528 struct ldap_url_desc *lud_next;
540 #define LDAP_URL_SUCCESS 0x00 /* Success */
541 #define LDAP_URL_ERR_MEM 0x01 /* can't allocate memory space */
542 #define LDAP_URL_ERR_PARAM 0x02 /* parameter is bad */
544 #define LDAP_URL_ERR_BADSCHEME 0x03 /* URL doesn't begin with "ldap[si]://" */
545 #define LDAP_URL_ERR_BADENCLOSURE 0x04 /* URL is missing trailing ">" */
546 #define LDAP_URL_ERR_BADURL 0x05 /* URL is bad */
547 #define LDAP_URL_ERR_BADHOST 0x06 /* host port is bad */
548 #define LDAP_URL_ERR_BADATTRS 0x07 /* bad (or missing) attributes */
549 #define LDAP_URL_ERR_BADSCOPE 0x08 /* scope string is invalid (or missing) */
550 #define LDAP_URL_ERR_BADFILTER 0x09 /* bad or missing filter */
551 #define LDAP_URL_ERR_BADEXTS 0x0a /* bad or missing extensions */
554 * The API draft spec says we should declare (or cause to be declared)
555 * 'struct timeval'. We don't. See IETF LDAPext discussions.
563 ldap_get_option LDAP_P((
569 ldap_set_option LDAP_P((
572 LDAP_CONST void *invalue));
574 /* V3 REBIND Function Callback Prototype */
575 typedef int (LDAP_REBIND_PROC) LDAP_P((
576 LDAP *ld, LDAP_CONST char *url, int request, ber_int_t msgid ));
579 ldap_set_rebind_proc LDAP_P((
581 LDAP_REBIND_PROC *ldap_proc));
587 ldap_create_control LDAP_P((
588 const char *requestOID,
591 LDAPControl **ctrlp ));
594 ldap_control_free LDAP_P((
595 LDAPControl *ctrl ));
598 ldap_controls_free LDAP_P((
599 LDAPControl **ctrls ));
605 ldap_domain2dn LDAP_P((
606 LDAP_CONST char* domain,
610 ldap_dn2domain LDAP_P((
615 ldap_domain2hostlist LDAP_P((
616 LDAP_CONST char *domain,
623 ldap_extended_operation LDAP_P((
625 LDAP_CONST char *reqoid,
626 struct berval *reqdata,
627 LDAPControl **serverctrls,
628 LDAPControl **clientctrls,
632 ldap_extended_operation_s LDAP_P((
634 LDAP_CONST char *reqoid,
635 struct berval *reqdata,
636 LDAPControl **serverctrls,
637 LDAPControl **clientctrls,
639 struct berval **retdatap ));
642 ldap_parse_extended_result LDAP_P((
646 struct berval **retdatap,
650 ldap_parse_extended_partial LDAP_P((
654 struct berval **retdatap,
655 LDAPControl ***serverctrls,
662 ldap_abandon_ext LDAP_P((
665 LDAPControl **serverctrls,
666 LDAPControl **clientctrls ));
669 ldap_abandon LDAP_P(( /* deprecated */
678 ldap_add_ext LDAP_P((
682 LDAPControl **serverctrls,
683 LDAPControl **clientctrls,
687 ldap_add_ext_s LDAP_P((
691 LDAPControl **serverctrls,
692 LDAPControl **clientctrls ));
695 ldap_add LDAP_P(( /* deprecated */
701 ldap_add_s LDAP_P(( /* deprecated */
711 ldap_sasl_bind LDAP_P((
714 LDAP_CONST char *mechanism,
716 LDAPControl **serverctrls,
717 LDAPControl **clientctrls,
720 /* Interaction flags (should be passed about in a control)
721 * Automatic (default): use defaults, prompt otherwise
722 * Interactive: prompt always
723 * Quiet: never prompt
725 #define LDAP_SASL_AUTOMATIC 0U
726 #define LDAP_SASL_INTERACTIVE 1U
727 #define LDAP_SASL_QUIET 2U
730 * V3 SASL Interaction Function Callback Prototype
731 * when using Cyrus SASL, interact is pointer to sasl_interact_t
732 * should likely passed in a control (and provided controls)
734 typedef int (LDAP_SASL_INTERACT_PROC) LDAP_P((
735 LDAP *ld, unsigned flags, void* defaults, void *interact ));
738 ldap_sasl_interactive_bind_s LDAP_P((
740 LDAP_CONST char *dn, /* usually NULL */
741 LDAP_CONST char *saslMechanism,
742 LDAPControl **serverControls,
743 LDAPControl **clientControls,
745 /* should be client controls */
747 LDAP_SASL_INTERACT_PROC *proc,
751 ldap_sasl_bind_s LDAP_P((
754 LDAP_CONST char *mechanism,
756 LDAPControl **serverctrls,
757 LDAPControl **clientctrls,
758 struct berval **servercredp ));
761 ldap_parse_sasl_bind_result LDAP_P((
764 struct berval **servercredp,
772 ldap_bind LDAP_P(( /* deprecated */
774 LDAP_CONST char *who,
775 LDAP_CONST char *passwd,
779 ldap_bind_s LDAP_P(( /* deprecated */
781 LDAP_CONST char *who,
782 LDAP_CONST char *cred,
789 ldap_simple_bind LDAP_P((
791 LDAP_CONST char *who,
792 LDAP_CONST char *passwd ));
795 ldap_simple_bind_s LDAP_P((
797 LDAP_CONST char *who,
798 LDAP_CONST char *passwd ));
806 ldap_kerberos_bind_s LDAP_P(( /* deprecated */
808 LDAP_CONST char *who ));
811 ldap_kerberos_bind1 LDAP_P(( /* deprecated */
813 LDAP_CONST char *who ));
816 ldap_kerberos_bind1_s LDAP_P(( /* deprecated */
818 LDAP_CONST char *who ));
821 ldap_kerberos_bind2 LDAP_P(( /* deprecated */
823 LDAP_CONST char *who ));
826 ldap_kerberos_bind2_s LDAP_P(( /* deprecated */
828 LDAP_CONST char *who ));
835 ldap_enable_cache LDAP_P(( LDAP *ld, long timeout, ber_len_t maxmem ));
838 ldap_disable_cache LDAP_P(( LDAP *ld ));
841 ldap_set_cache_options LDAP_P(( LDAP *ld, unsigned long opts ));
844 ldap_destroy_cache LDAP_P(( LDAP *ld ));
847 ldap_flush_cache LDAP_P(( LDAP *ld ));
850 ldap_uncache_entry LDAP_P(( LDAP *ld, LDAP_CONST char *dn ));
853 ldap_uncache_request LDAP_P(( LDAP *ld, int msgid ));
860 ldap_compare_ext LDAP_P((
863 LDAP_CONST char *attr,
864 struct berval *bvalue,
865 LDAPControl **serverctrls,
866 LDAPControl **clientctrls,
870 ldap_compare_ext_s LDAP_P((
873 LDAP_CONST char *attr,
874 struct berval *bvalue,
875 LDAPControl **serverctrls,
876 LDAPControl **clientctrls ));
879 ldap_compare LDAP_P(( /* deprecated */
882 LDAP_CONST char *attr,
883 LDAP_CONST char *value ));
886 ldap_compare_s LDAP_P(( /* deprecated */
889 LDAP_CONST char *attr,
890 LDAP_CONST char *value ));
897 ldap_delete_ext LDAP_P((
900 LDAPControl **serverctrls,
901 LDAPControl **clientctrls,
905 ldap_delete_ext_s LDAP_P((
908 LDAPControl **serverctrls,
909 LDAPControl **clientctrls ));
912 ldap_delete LDAP_P(( /* deprecated */
914 LDAP_CONST char *dn ));
917 ldap_delete_s LDAP_P(( /* deprecated */
919 LDAP_CONST char *dn ));
926 ldap_parse_result LDAP_P((
933 LDAPControl ***serverctrls,
937 ldap_err2string LDAP_P((
941 ldap_result2error LDAP_P(( /* deprecated */
947 ldap_perror LDAP_P(( /* deprecated */
949 LDAP_CONST char *s ));
956 ldap_modify_ext LDAP_P((
960 LDAPControl **serverctrls,
961 LDAPControl **clientctrls,
965 ldap_modify_ext_s LDAP_P((
969 LDAPControl **serverctrls,
970 LDAPControl **clientctrls ));
973 ldap_modify LDAP_P(( /* deprecated */
979 ldap_modify_s LDAP_P(( /* deprecated */
992 LDAP_CONST char *newrdn,
993 LDAP_CONST char *newSuperior,
995 LDAPControl **sctrls,
996 LDAPControl **cctrls,
1000 ldap_rename_s LDAP_P((
1002 LDAP_CONST char *dn,
1003 LDAP_CONST char *newrdn,
1004 LDAP_CONST char *newSuperior,
1006 LDAPControl **sctrls,
1007 LDAPControl **cctrls ));
1010 ldap_rename2 LDAP_P(( /* deprecated */
1012 LDAP_CONST char *dn,
1013 LDAP_CONST char *newrdn,
1014 LDAP_CONST char *newSuperior,
1015 int deleteoldrdn ));
1018 ldap_rename2_s LDAP_P(( /* deprecated */
1020 LDAP_CONST char *dn,
1021 LDAP_CONST char *newrdn,
1022 LDAP_CONST char *newSuperior,
1023 int deleteoldrdn ));
1026 ldap_modrdn LDAP_P(( /* deprecated */
1028 LDAP_CONST char *dn,
1029 LDAP_CONST char *newrdn ));
1032 ldap_modrdn_s LDAP_P(( /* deprecated */
1034 LDAP_CONST char *dn,
1035 LDAP_CONST char *newrdn ));
1038 ldap_modrdn2 LDAP_P(( /* deprecated */
1040 LDAP_CONST char *dn,
1041 LDAP_CONST char *newrdn,
1042 int deleteoldrdn ));
1045 ldap_modrdn2_s LDAP_P(( /* deprecated */
1047 LDAP_CONST char *dn,
1048 LDAP_CONST char *newrdn,
1057 LDAP_CONST char *host,
1061 ldap_open LDAP_P(( /* deprecated */
1062 LDAP_CONST char *host,
1066 ldap_create LDAP_P((
1070 ldap_initialize LDAP_P((
1072 LDAP_CONST char *url ));
1075 ldap_start_tls_s LDAP_P((
1077 LDAPControl **serverctrls,
1078 LDAPControl **clientctrls ));
1083 LDAP_F( LDAPMessage *)
1084 ldap_first_message LDAP_P((
1086 LDAPMessage *chain ));
1088 LDAP_F( LDAPMessage *)
1089 ldap_next_message LDAP_P((
1091 LDAPMessage *msg ));
1094 ldap_count_messages LDAP_P((
1096 LDAPMessage *chain ));
1102 LDAP_F( LDAPMessage *)
1103 ldap_first_reference LDAP_P((
1105 LDAPMessage *chain ));
1107 LDAP_F( LDAPMessage *)
1108 ldap_next_reference LDAP_P((
1110 LDAPMessage *ref ));
1113 ldap_count_references LDAP_P((
1115 LDAPMessage *chain ));
1118 ldap_parse_reference LDAP_P((
1122 LDAPControl ***serverctrls,
1129 LDAP_F( LDAPMessage *)
1130 ldap_first_entry LDAP_P((
1132 LDAPMessage *chain ));
1134 LDAP_F( LDAPMessage *)
1135 ldap_next_entry LDAP_P((
1137 LDAPMessage *entry ));
1140 ldap_count_entries LDAP_P((
1142 LDAPMessage *chain ));
1145 ldap_get_entry_controls LDAP_P((
1148 LDAPControl ***serverctrls));
1154 LDAP_F( LDAPMessage *)
1155 ldap_delete_result_entry LDAP_P((
1160 ldap_add_result_entry LDAP_P((
1169 ldap_get_dn LDAP_P((
1171 LDAPMessage *entry ));
1174 ldap_dn2ufn LDAP_P((
1175 LDAP_CONST char *dn ));
1178 ldap_explode_dn LDAP_P((
1179 LDAP_CONST char *dn,
1183 ldap_explode_rdn LDAP_P((
1184 LDAP_CONST char *rdn,
1188 ldap_dn2dcedn LDAP_P(( LDAP_CONST char *dn )); /* deprecated */
1191 ldap_dcedn2dn LDAP_P(( LDAP_CONST char *dce )); /* deprecated */
1197 ldap_first_attribute LDAP_P((
1200 BerElement **ber ));
1203 ldap_next_attribute LDAP_P((
1213 ldap_get_values LDAP_P((
1216 LDAP_CONST char *target ));
1218 LDAP_F( struct berval **)
1219 ldap_get_values_len LDAP_P((
1222 LDAP_CONST char *target ));
1225 ldap_count_values LDAP_P((
1229 ldap_count_values_len LDAP_P((
1230 struct berval **vals ));
1233 ldap_value_free LDAP_P((
1237 ldap_value_free_len LDAP_P((
1238 struct berval **vals ));
1244 ldap_result LDAP_P((
1248 struct timeval *timeout,
1249 LDAPMessage **result ));
1252 ldap_msgtype LDAP_P((
1260 ldap_msgfree LDAP_P((
1264 ldap_msgdelete LDAP_P((
1273 ldap_search_ext LDAP_P((
1275 LDAP_CONST char *base,
1277 LDAP_CONST char *filter,
1280 LDAPControl **serverctrls,
1281 LDAPControl **clientctrls,
1282 struct timeval *timeout,
1287 ldap_search_ext_s LDAP_P((
1289 LDAP_CONST char *base,
1291 LDAP_CONST char *filter,
1294 LDAPControl **serverctrls,
1295 LDAPControl **clientctrls,
1296 struct timeval *timeout,
1298 LDAPMessage **res ));
1301 ldap_search LDAP_P(( /* deprecated */
1303 LDAP_CONST char *base,
1305 LDAP_CONST char *filter,
1310 ldap_search_s LDAP_P(( /* deprecated */
1312 LDAP_CONST char *base,
1314 LDAP_CONST char *filter,
1317 LDAPMessage **res ));
1320 ldap_search_st LDAP_P(( /* deprecated */
1322 LDAP_CONST char *base,
1324 LDAP_CONST char *filter,
1327 struct timeval *timeout,
1328 LDAPMessage **res ));
1334 ldap_unbind LDAP_P(( /* deprecated */
1338 ldap_unbind_s LDAP_P(( /* deprecated */
1342 ldap_unbind_ext LDAP_P((
1344 LDAPControl **serverctrls,
1345 LDAPControl **clientctrls));
1348 ldap_unbind_ext_s LDAP_P((
1350 LDAPControl **serverctrls,
1351 LDAPControl **clientctrls));
1357 LDAP_F( LDAPFiltDesc *)
1358 ldap_init_getfilter LDAP_P(( /* deprecated */
1359 LDAP_CONST char *fname ));
1361 LDAP_F( LDAPFiltDesc *)
1362 ldap_init_getfilter_buf LDAP_P(( /* deprecated */
1363 /* LDAP_CONST */ char *buf,
1364 ber_len_t buflen ));
1366 LDAP_F( LDAPFiltInfo *)
1367 ldap_getfirstfilter LDAP_P(( /* deprecated */
1369 /* LDAP_CONST */ char *tagpat,
1370 /* LDAP_CONST */ char *value ));
1372 LDAP_F( LDAPFiltInfo *)
1373 ldap_getnextfilter LDAP_P(( /* deprecated */
1374 LDAPFiltDesc *lfdp ));
1377 ldap_setfilteraffixes LDAP_P(( /* deprecated */
1379 LDAP_CONST char *prefix,
1380 LDAP_CONST char *suffix ));
1383 ldap_build_filter LDAP_P(( /* deprecated */
1386 LDAP_CONST char *pattern,
1387 LDAP_CONST char *prefix,
1388 LDAP_CONST char *suffix,
1389 LDAP_CONST char *attr,
1390 LDAP_CONST char *value,
1399 ldap_memalloc LDAP_P((
1403 ldap_memrealloc LDAP_P((
1408 ldap_memcalloc LDAP_P((
1413 ldap_memfree LDAP_P((
1417 ldap_memvfree LDAP_P((
1421 ldap_strdup LDAP_P((
1422 LDAP_CONST char * ));
1425 ldap_getfilter_free LDAP_P((
1426 LDAPFiltDesc *lfdp ));
1429 ldap_mods_free LDAP_P((
1439 ldap_friendly_name LDAP_P(( /* deprecated */
1440 LDAP_CONST char *filename,
1441 /* LDAP_CONST */ char *uname,
1442 LDAPFriendlyMap **map ));
1445 ldap_free_friendlymap LDAP_P(( /* deprecated */
1446 LDAPFriendlyMap **map ));
1452 typedef int (LDAP_SORT_AD_CMP_PROC) LDAP_P((
1453 LDAP_CONST char *left,
1454 LDAP_CONST char *right ));
1456 typedef int (LDAP_SORT_AV_CMP_PROC) LDAP_P((
1457 LDAP_CONST void *left,
1458 LDAP_CONST void *right ));
1461 ldap_sort_entries LDAP_P(( LDAP *ld,
1462 LDAPMessage **chain,
1463 LDAP_CONST char *attr,
1464 LDAP_SORT_AD_CMP_PROC *cmp ));
1466 LDAP_F( int ) /* deprecated */
1467 ldap_sort_values LDAP_P((
1470 LDAP_SORT_AV_CMP_PROC *cmp ));
1472 LDAP_F( int ) /* deprecated */
1473 ldap_sort_strcasecmp LDAP_P((
1475 LDAP_CONST void *b ));
1481 * need _ext varients
1484 ldap_is_ldap_url LDAP_P((
1485 LDAP_CONST char *url ));
1488 ldap_is_ldaps_url LDAP_P((
1489 LDAP_CONST char *url ));
1492 ldap_is_ldapi_url LDAP_P((
1493 LDAP_CONST char *url ));
1496 ldap_url_parse LDAP_P((
1497 LDAP_CONST char *url,
1498 LDAPURLDesc **ludpp ));
1501 ldap_free_urldesc LDAP_P((
1502 LDAPURLDesc *ludp ));
1505 ldap_url_search LDAP_P((
1507 LDAP_CONST char *url,
1511 ldap_url_search_s LDAP_P((
1513 LDAP_CONST char *url,
1515 LDAPMessage **res ));
1518 ldap_url_search_st LDAP_P((
1520 LDAP_CONST char *url,
1522 struct timeval *timeout,
1523 LDAPMessage **res ));
1529 * structure for a sort-key
1531 typedef struct ldapsortkey {
1532 char * attributeType;
1533 char * orderingRule;
1538 ldap_create_sort_keylist LDAP_P((
1539 LDAPSortKey ***sortKeyList,
1543 ldap_free_sort_keylist LDAP_P((
1544 LDAPSortKey **sortkeylist ));
1547 ldap_create_sort_control LDAP_P((
1549 LDAPSortKey **keyList,
1551 LDAPControl **ctrlp ));
1554 ldap_parse_sort_control LDAP_P((
1556 LDAPControl **ctrlp,
1557 unsigned long *result,
1558 char **attribute ));
1566 * structure for virtul list.
1568 typedef struct ldapvlvinfo {
1570 unsigned long ldvlv_before_count;
1571 unsigned long ldvlv_after_count;
1572 unsigned long ldvlv_offset;
1573 unsigned long ldvlv_count;
1574 struct berval *ldvlv_attrvalue;
1575 struct berval *ldvlv_context;
1576 void *ldvlv_extradata;
1580 ldap_create_vlv_control LDAP_P((
1582 LDAPVLVInfo *ldvlistp,
1583 LDAPControl **ctrlp ));
1586 ldap_parse_vlv_control LDAP_P((
1588 LDAPControl **ctrls,
1589 unsigned long *target_posp,
1590 unsigned long *list_countp,
1591 struct berval **contextp,
1596 #endif /* _LDAP_H */