]> git.sur5r.net Git - openldap/blob - include/ldap.h
Add ldap_pvt_tls_destroy
[openldap] / include / ldap.h
1 /* $OpenLDAP$ */
2 /*
3  * Copyright 1998-2001 The OpenLDAP Foundation, Redwood City, California, USA
4  * All rights reserved.
5  *
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.
11  */
12 /* Portions
13  * Copyright (c) 1990 Regents of the University of Michigan.
14  * All rights reserved.
15  *
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.
22  */
23
24 #ifndef _LDAP_H
25 #define _LDAP_H
26
27 /* pull in lber */
28 #include <lber.h>
29
30 LDAP_BEGIN_DECL
31
32 #define LDAP_VERSION1   1
33 #define LDAP_VERSION2   2
34 #define LDAP_VERSION3   3
35
36 #define LDAP_VERSION_MIN        LDAP_VERSION2
37 #define LDAP_VERSION            LDAP_VERSION2
38 #define LDAP_VERSION_MAX        LDAP_VERSION3
39
40 /*
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
44  */
45 #define LDAP_API_VERSION        2004
46 #define LDAP_VENDOR_NAME        "OpenLDAP"
47
48 /*
49  * vendor version number
50  *      2.0.0  -> 20000
51  *      2.3.16 -> 20316
52  */
53 #define LDAP_VENDOR_VERSION     20018
54
55 /* OpenLDAP API Features */
56 #define LDAP_API_FEATURE_X_OPENLDAP LDAP_VENDOR_VERSION
57
58 /* include LDAP_API_FEATURE defines */
59 #include <ldap_features.h>
60
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
67 #endif
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       */
72 #endif
73
74 #define LDAP_PORT               389             /* ldap:///             default LDAP port */
75 #define LDAPS_PORT              636             /* ldaps:///    default LDAP over TLS port */
76
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 */
81
82 /*
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
87  */
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
102
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
108
109 /* 0x34 - 0x0fff not defined by current draft */
110
111 #define LDAP_OPT_PRIVATE_EXTENSION_BASE 0x4000  /* to 0x7FFF inclusive */
112
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
120
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
132
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
138
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
150
151
152 /* on/off values */
153 #define LDAP_OPT_ON             ((void *) 1)
154 #define LDAP_OPT_OFF    ((void *) 0)
155
156 /*
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.
161  */
162 #define LDAP_OPT_SUCCESS        0
163 #define LDAP_OPT_ERROR          (-1)
164
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 */
173 } LDAPAPIInfo;
174
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;
181
182 typedef struct ldapcontrol {
183         char *                  ldctl_oid;
184         struct berval   ldctl_value;
185         char                    ldctl_iscritical;
186 } LDAPControl;
187
188 /* LDAP Controls */
189
190 #ifdef undef
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
195 #endif
196
197 #define LDAP_CONTROL_MANAGEDSAIT "2.16.840.1.113730.3.4.2"
198
199 /* Experimental Controls */
200
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"
205
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
209
210 /* LDAP Extended Operations */
211 #define LDAP_EXOP_START_TLS "1.3.6.1.4.1.1466.20037"
212
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)
218
219 /* 
220  * specific LDAP instantiations of BER types we know about
221  */
222
223 /* Overview of LBER tag construction
224  *
225  *      Bits
226  *      ______
227  *      8 7 | CLASS
228  *      0 0 = UNIVERSAL
229  *      0 1 = APPLICATION
230  *      1 0 = CONTEXT-SPECIFIC
231  *      1 1 = PRIVATE
232  *              _____
233  *              | 6 | DATA-TYPE
234  *                0 = PRIMITIVE
235  *                1 = CONSTRUCTED
236  *                      ___________
237  *                      | 5 ... 1 | TAG-NUMBER
238  */
239
240 /* general stuff */
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 */
247
248 #define LDAP_TAG_NEWSUPERIOR    ((ber_tag_t) 0x80U)     /* context-specific + primitive + 0 */
249
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 */
254
255 #define LDAP_TAG_SASL_RES_CREDS ((ber_tag_t) 0x87U)     /* context specific + primitive */
256
257
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 */
271
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 */
286
287 #define LDAP_RES_ANY                    (-1)
288 #define LDAP_RES_UNSOLICITED    (0)
289
290
291 /* sasl methods */
292 #define LDAP_SASL_SIMPLE                ((char*)0)
293 #define LDAP_SASL_NULL                  ("")
294
295
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   */
303
304
305 /* filter types */
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 */
316
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 */
322
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 */
327
328 /* search scopes */
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)
333
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 */
338
339 /* 
340  * possible error codes we can return
341  */
342
343 #define LDAP_RANGE(n,x,y)       (((x) <= (n)) && ((n) <= (y)))
344
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) */
356
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 */       
362
363 #define LDAP_ATTR_ERROR(n)      LDAP_RANGE((n),0x10,0x15) /* 16-21 */
364
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
371
372 #define LDAP_NAME_ERROR(n)      LDAP_RANGE((n),0x20,0x24) /* 32-34,36 */
373
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
379
380 #define LDAP_SECURITY_ERROR(n)  LDAP_RANGE((n),0x30,0x32) /* 48-50 */
381
382 #define LDAP_INAPPROPRIATE_AUTH         0x30
383 #define LDAP_INVALID_CREDENTIALS        0x31
384 #define LDAP_INSUFFICIENT_ACCESS        0x32
385
386 #define LDAP_SERVICE_ERROR(n)   LDAP_RANGE((n),0x33,0x36) /* 51-54 */
387
388 #define LDAP_BUSY                       0x33
389 #define LDAP_UNAVAILABLE                0x34
390 #define LDAP_UNWILLING_TO_PERFORM       0x35
391 #define LDAP_LOOP_DETECT                0x36
392
393 #define LDAP_UPDATE_ERROR(n)    LDAP_RANGE((n),0x40,0x47) /* 64-69,71 */
394
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 */
403
404 #define LDAP_OTHER                      0x50
405
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 */
409
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
420
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 */
429
430 /*
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.
434  */
435
436 typedef struct ldapmsg LDAPMessage;
437
438 /* for modifications */
439 typedef struct ldapmod {
440         int             mod_op;
441
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)
449  */
450
451         char            *mod_type;
452         union mod_vals_u {
453                 char            **modv_strvals;
454                 struct berval   **modv_bvals;
455         } mod_vals;
456 #define mod_values      mod_vals.modv_strvals
457 #define mod_bvalues     mod_vals.modv_bvals
458 } LDAPMod;
459
460 /*
461  * structures for ldap getfilter routines
462  */
463
464 typedef struct ldap_filt_info {
465         char                    *lfi_filter;
466         char                    *lfi_desc;
467         int                     lfi_scope;
468         int                     lfi_isexact;
469         struct ldap_filt_info   *lfi_next;
470 } LDAPFiltInfo;
471
472 typedef struct ldap_filt_list {
473     char                        *lfl_tag;
474     char                        *lfl_pattern;
475     char                        *lfl_delims;
476     LDAPFiltInfo                *lfl_ilist;
477     struct ldap_filt_list       *lfl_next;
478 } LDAPFiltList;
479
480
481 #define LDAP_FILT_MAXSIZ        1024
482
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 ];
488         char                    *lfd_curval;
489         char                    *lfd_curvalcopy;
490         char                    **lfd_curvalwords;
491         char                    *lfd_filtprefix;
492         char                    *lfd_filtsuffix;
493 } LDAPFiltDesc;
494
495
496 /*
497  * structure representing an ldap session which can
498  * encompass connections to multiple servers (in the
499  * face of referrals).
500  */
501 typedef struct ldap LDAP;
502
503 #define LDAP_DEREF_NEVER        0x00
504 #define LDAP_DEREF_SEARCHING    0x01
505 #define LDAP_DEREF_FINDING      0x02
506 #define LDAP_DEREF_ALWAYS       0x03
507
508 #define LDAP_NO_LIMIT           0
509
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
514
515 /*
516  * structure for ldap friendly mapping routines
517  */
518
519 typedef struct ldap_friendly {
520         char    *lf_unfriendly;
521         char    *lf_friendly;
522 } LDAPFriendlyMap;
523
524 /*
525  * types for ldap URL handling
526  */
527 typedef struct ldap_url_desc {
528         struct ldap_url_desc *lud_next;
529         char    *lud_scheme;
530         char    *lud_host;
531         int             lud_port;
532         char    *lud_dn;
533         char    **lud_attrs;
534         int             lud_scope;
535         char    *lud_filter;
536         char    **lud_exts;
537         int             lud_crit_exts;
538 } LDAPURLDesc;
539
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 */
543
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 */
552
553 /*
554  * The API draft spec says we should declare (or cause to be declared)
555  * 'struct timeval'.   We don't.  See IETF LDAPext discussions.
556  */
557 struct timeval;
558
559 /*
560  * in options.c:
561  */
562 LDAP_F( int )
563 ldap_get_option LDAP_P((
564         LDAP *ld,
565         int option,
566         void *outvalue));
567
568 LDAP_F( int )
569 ldap_set_option LDAP_P((
570         LDAP *ld,
571         int option,
572         LDAP_CONST void *invalue));
573
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 ));
577
578 LDAP_F( int )
579 ldap_set_rebind_proc LDAP_P((
580         LDAP *ld,
581         LDAP_REBIND_PROC *ldap_proc));
582
583 /*
584  * in controls.c:
585  */
586 LDAP_F( int ) 
587 ldap_create_control LDAP_P(( 
588         const char *requestOID, 
589         BerElement *ber, 
590         int iscritical,
591         LDAPControl **ctrlp ));
592
593 LDAP_F( void )
594 ldap_control_free LDAP_P((
595         LDAPControl *ctrl ));
596
597 LDAP_F( void )
598 ldap_controls_free LDAP_P((
599         LDAPControl **ctrls ));
600
601 /*
602  * in dnssrv.c:
603  */
604 LDAP_F( int )
605 ldap_domain2dn LDAP_P((
606         LDAP_CONST char* domain,
607         char** dn ));
608
609 LDAP_F( int )
610 ldap_dn2domain LDAP_P((
611         LDAP_CONST char* dn,
612         char** domain ));
613
614 LDAP_F( int )
615 ldap_domain2hostlist LDAP_P((
616         LDAP_CONST char *domain,
617         char** hostlist ));
618
619 /*
620  * in extended.c:
621  */
622 LDAP_F( int )
623 ldap_extended_operation LDAP_P((
624         LDAP                    *ld,
625         LDAP_CONST char *reqoid,
626         struct berval   *reqdata,
627         LDAPControl             **serverctrls,
628         LDAPControl             **clientctrls,
629         int                             *msgidp ));
630
631 LDAP_F( int )
632 ldap_extended_operation_s LDAP_P((
633         LDAP                    *ld,
634         LDAP_CONST char *reqoid,
635         struct berval   *reqdata,
636         LDAPControl             **serverctrls,
637         LDAPControl             **clientctrls,
638         char                    **retoidp,
639         struct berval   **retdatap ));
640
641 LDAP_F( int )
642 ldap_parse_extended_result LDAP_P((
643         LDAP                    *ld,
644         LDAPMessage             *res,
645         char                    **retoidp,
646         struct berval   **retdatap,
647         int                             freeit ));
648
649 LDAP_F( int )
650 ldap_parse_extended_partial LDAP_P((
651         LDAP                    *ld,
652         LDAPMessage             *res,
653         char                    **retoidp,
654         struct berval   **retdatap,
655         LDAPControl             ***serverctrls,
656         int                             freeit ));
657
658 /*
659  * in abandon.c:
660  */
661 LDAP_F( int )
662 ldap_abandon_ext LDAP_P((
663         LDAP                    *ld,
664         int                             msgid,
665         LDAPControl             **serverctrls,
666         LDAPControl             **clientctrls ));
667
668 LDAP_F( int )
669 ldap_abandon LDAP_P((   /* deprecated */
670         LDAP *ld,
671         int msgid ));
672
673
674 /*
675  * in add.c:
676  */
677 LDAP_F( int )
678 ldap_add_ext LDAP_P((
679         LDAP                    *ld,
680         LDAP_CONST char *dn,
681         LDAPMod                 **attrs,
682         LDAPControl             **serverctrls,
683         LDAPControl             **clientctrls,
684         int                     *msgidp ));
685
686 LDAP_F( int )
687 ldap_add_ext_s LDAP_P((
688         LDAP                    *ld,
689         LDAP_CONST char *dn,
690         LDAPMod                 **attrs,
691         LDAPControl             **serverctrls,
692         LDAPControl             **clientctrls ));
693
694 LDAP_F( int )
695 ldap_add LDAP_P((       /* deprecated */
696         LDAP *ld,
697         LDAP_CONST char *dn,
698         LDAPMod **attrs ));
699
700 LDAP_F( int )
701 ldap_add_s LDAP_P((     /* deprecated */
702         LDAP *ld,
703         LDAP_CONST char *dn,
704         LDAPMod **attrs ));
705
706
707 /*
708  * in sasl.c:
709  */
710 LDAP_F( int )
711 ldap_sasl_bind LDAP_P((
712         LDAP                    *ld,
713         LDAP_CONST char *dn,
714         LDAP_CONST char *mechanism,
715         struct berval   *cred,
716         LDAPControl             **serverctrls,
717         LDAPControl             **clientctrls,
718         int                             *msgidp ));
719
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
724  */
725 #define LDAP_SASL_AUTOMATIC             0U
726 #define LDAP_SASL_INTERACTIVE   1U
727 #define LDAP_SASL_QUIET                 2U
728
729 /*
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)
733  */
734 typedef int (LDAP_SASL_INTERACT_PROC) LDAP_P((
735         LDAP *ld, unsigned flags, void* defaults, void *interact ));
736
737 LDAP_F( int )
738 ldap_sasl_interactive_bind_s LDAP_P((
739         LDAP *ld,
740         LDAP_CONST char *dn, /* usually NULL */
741         LDAP_CONST char *saslMechanism,
742         LDAPControl **serverControls,
743         LDAPControl **clientControls,
744
745         /* should be client controls */
746         unsigned flags,
747         LDAP_SASL_INTERACT_PROC *proc,
748         void *defaults ));
749
750 LDAP_F( int )
751 ldap_sasl_bind_s LDAP_P((
752         LDAP                    *ld,
753         LDAP_CONST char *dn,
754         LDAP_CONST char *mechanism,
755         struct berval   *cred,
756         LDAPControl             **serverctrls,
757         LDAPControl             **clientctrls,
758         struct berval   **servercredp ));
759
760 LDAP_F( int )
761 ldap_parse_sasl_bind_result LDAP_P((
762         LDAP                    *ld,
763         LDAPMessage             *res,
764         struct berval   **servercredp,
765         int                             freeit ));
766
767 /*
768  * in bind.c:
769  *      (deprecated)
770  */
771 LDAP_F( int )
772 ldap_bind LDAP_P((      /* deprecated */
773         LDAP *ld,
774         LDAP_CONST char *who,
775         LDAP_CONST char *passwd,
776         int authmethod ));
777
778 LDAP_F( int )
779 ldap_bind_s LDAP_P((    /* deprecated */
780         LDAP *ld,
781         LDAP_CONST char *who,
782         LDAP_CONST char *cred,
783         int authmethod ));
784
785 /*
786  * in sbind.c:
787  */
788 LDAP_F( int )
789 ldap_simple_bind LDAP_P((
790         LDAP *ld,
791         LDAP_CONST char *who,
792         LDAP_CONST char *passwd ));
793
794 LDAP_F( int )
795 ldap_simple_bind_s LDAP_P((
796         LDAP *ld,
797         LDAP_CONST char *who,
798         LDAP_CONST char *passwd ));
799
800
801 /*
802  * in kbind.c:
803  *      (deprecated)
804  */
805 LDAP_F( int )
806 ldap_kerberos_bind_s LDAP_P((   /* deprecated */
807         LDAP *ld,
808         LDAP_CONST char *who ));
809
810 LDAP_F( int )
811 ldap_kerberos_bind1 LDAP_P((    /* deprecated */
812         LDAP *ld,
813         LDAP_CONST char *who ));
814
815 LDAP_F( int )
816 ldap_kerberos_bind1_s LDAP_P((  /* deprecated */
817         LDAP *ld,
818         LDAP_CONST char *who ));
819
820 LDAP_F( int )
821 ldap_kerberos_bind2 LDAP_P((    /* deprecated */
822         LDAP *ld,
823         LDAP_CONST char *who ));
824
825 LDAP_F( int )
826 ldap_kerberos_bind2_s LDAP_P((  /* deprecated */
827         LDAP *ld,
828         LDAP_CONST char *who ));
829
830 /*
831  * in cache.c
832  * (deprecated)
833  */
834 LDAP_F( int )
835 ldap_enable_cache LDAP_P(( LDAP *ld, long timeout, ber_len_t maxmem ));
836
837 LDAP_F( void )
838 ldap_disable_cache LDAP_P(( LDAP *ld ));
839
840 LDAP_F( void )
841 ldap_set_cache_options LDAP_P(( LDAP *ld, unsigned long opts ));
842
843 LDAP_F( void )
844 ldap_destroy_cache LDAP_P(( LDAP *ld ));
845
846 LDAP_F( void )
847 ldap_flush_cache LDAP_P(( LDAP *ld ));
848
849 LDAP_F( void )
850 ldap_uncache_entry LDAP_P(( LDAP *ld, LDAP_CONST char *dn ));
851
852 LDAP_F( void )
853 ldap_uncache_request LDAP_P(( LDAP *ld, int msgid ));
854
855
856 /*
857  * in compare.c:
858  */
859 LDAP_F( int )
860 ldap_compare_ext LDAP_P((
861         LDAP                    *ld,
862         LDAP_CONST char *dn,
863         LDAP_CONST char *attr,
864         struct berval   *bvalue,
865         LDAPControl             **serverctrls,
866         LDAPControl             **clientctrls,
867         int                     *msgidp ));
868
869 LDAP_F( int )
870 ldap_compare_ext_s LDAP_P((
871         LDAP                    *ld,
872         LDAP_CONST char *dn,
873         LDAP_CONST char *attr,
874         struct berval   *bvalue,
875         LDAPControl             **serverctrls,
876         LDAPControl             **clientctrls ));
877
878 LDAP_F( int )
879 ldap_compare LDAP_P((   /* deprecated */
880         LDAP *ld,
881         LDAP_CONST char *dn,
882         LDAP_CONST char *attr,
883         LDAP_CONST char *value ));
884
885 LDAP_F( int )
886 ldap_compare_s LDAP_P(( /* deprecated */
887         LDAP *ld,
888         LDAP_CONST char *dn,
889         LDAP_CONST char *attr,
890         LDAP_CONST char *value ));
891
892
893 /*
894  * in delete.c:
895  */
896 LDAP_F( int )
897 ldap_delete_ext LDAP_P((
898         LDAP                    *ld,
899         LDAP_CONST char *dn,
900         LDAPControl             **serverctrls,
901         LDAPControl             **clientctrls,
902         int                     *msgidp ));
903
904 LDAP_F( int )
905 ldap_delete_ext_s LDAP_P((
906         LDAP                    *ld,
907         LDAP_CONST char *dn,
908         LDAPControl             **serverctrls,
909         LDAPControl             **clientctrls ));
910
911 LDAP_F( int )
912 ldap_delete LDAP_P((    /* deprecated */
913         LDAP *ld,
914         LDAP_CONST char *dn ));
915
916 LDAP_F( int )
917 ldap_delete_s LDAP_P((  /* deprecated */
918         LDAP *ld,
919         LDAP_CONST char *dn ));
920
921
922 /*
923  * in error.c:
924  */
925 LDAP_F( int )
926 ldap_parse_result LDAP_P((
927         LDAP                    *ld,
928         LDAPMessage             *res,
929         int                             *errcodep,
930         char                    **matcheddnp,
931         char                    **errmsgp,
932         char                    ***referralsp,
933         LDAPControl             ***serverctrls,
934         int                             freeit ));
935
936 LDAP_F( char *)
937 ldap_err2string LDAP_P((
938         int err ));
939
940 LDAP_F( int )
941 ldap_result2error LDAP_P((      /* deprecated */
942         LDAP *ld,
943         LDAPMessage *r,
944         int freeit ));
945
946 LDAP_F( void )
947 ldap_perror LDAP_P((    /* deprecated */
948         LDAP *ld,
949         LDAP_CONST char *s ));
950
951
952 /*
953  * in modify.c:
954  */
955 LDAP_F( int )
956 ldap_modify_ext LDAP_P((
957         LDAP                    *ld,
958         LDAP_CONST char *dn,
959         LDAPMod                 **mods,
960         LDAPControl             **serverctrls,
961         LDAPControl             **clientctrls,
962         int                     *msgidp ));
963
964 LDAP_F( int )
965 ldap_modify_ext_s LDAP_P((
966         LDAP                    *ld,
967         LDAP_CONST char *dn,
968         LDAPMod                 **mods,
969         LDAPControl             **serverctrls,
970         LDAPControl             **clientctrls ));
971
972 LDAP_F( int )
973 ldap_modify LDAP_P((    /* deprecated */
974         LDAP *ld,
975         LDAP_CONST char *dn,
976         LDAPMod **mods ));
977
978 LDAP_F( int )
979 ldap_modify_s LDAP_P((  /* deprecated */
980         LDAP *ld,
981         LDAP_CONST char *dn,
982         LDAPMod **mods ));
983
984
985 /*
986  * in modrdn.c:
987  */
988 LDAP_F( int )
989 ldap_rename LDAP_P((
990         LDAP *ld,
991         LDAP_CONST char *dn,
992         LDAP_CONST char *newrdn,
993         LDAP_CONST char *newSuperior,
994         int deleteoldrdn,
995         LDAPControl **sctrls,
996         LDAPControl **cctrls,
997         int *msgidp ));
998
999 LDAP_F( int )
1000 ldap_rename_s LDAP_P((
1001         LDAP *ld,
1002         LDAP_CONST char *dn,
1003         LDAP_CONST char *newrdn,
1004         LDAP_CONST char *newSuperior,
1005         int deleteoldrdn,
1006         LDAPControl **sctrls,
1007         LDAPControl **cctrls ));
1008
1009 LDAP_F( int )
1010 ldap_rename2 LDAP_P((   /* deprecated */
1011         LDAP *ld,
1012         LDAP_CONST char *dn,
1013         LDAP_CONST char *newrdn,
1014         LDAP_CONST char *newSuperior,
1015         int deleteoldrdn ));
1016
1017 LDAP_F( int )
1018 ldap_rename2_s LDAP_P(( /* deprecated */
1019         LDAP *ld,
1020         LDAP_CONST char *dn,
1021         LDAP_CONST char *newrdn,
1022         LDAP_CONST char *newSuperior,
1023         int deleteoldrdn ));
1024
1025 LDAP_F( int )
1026 ldap_modrdn LDAP_P((    /* deprecated */
1027         LDAP *ld,
1028         LDAP_CONST char *dn,
1029         LDAP_CONST char *newrdn ));
1030
1031 LDAP_F( int )
1032 ldap_modrdn_s LDAP_P((  /* deprecated */
1033         LDAP *ld,
1034         LDAP_CONST char *dn,
1035         LDAP_CONST char *newrdn ));
1036
1037 LDAP_F( int )
1038 ldap_modrdn2 LDAP_P((   /* deprecated */
1039         LDAP *ld,
1040         LDAP_CONST char *dn,
1041         LDAP_CONST char *newrdn,
1042         int deleteoldrdn ));
1043
1044 LDAP_F( int )
1045 ldap_modrdn2_s LDAP_P(( /* deprecated */
1046         LDAP *ld,
1047         LDAP_CONST char *dn,
1048         LDAP_CONST char *newrdn,
1049         int deleteoldrdn));
1050
1051
1052 /*
1053  * in open.c:
1054  */
1055 LDAP_F( LDAP *)
1056 ldap_init LDAP_P((
1057         LDAP_CONST char *host,
1058         int port ));
1059
1060 LDAP_F( LDAP *)
1061 ldap_open LDAP_P((      /* deprecated */
1062         LDAP_CONST char *host,
1063         int port ));
1064
1065 LDAP_F( int )
1066 ldap_create LDAP_P(( 
1067         LDAP **ldp ));
1068
1069 LDAP_F( int )
1070 ldap_initialize LDAP_P((
1071         LDAP **ldp,
1072         LDAP_CONST char *url ));
1073
1074 LDAP_F( int )
1075 ldap_start_tls_s LDAP_P((
1076         LDAP *ld,
1077         LDAPControl **serverctrls,
1078         LDAPControl **clientctrls ));
1079
1080 /*
1081  * in messages.c:
1082  */
1083 LDAP_F( LDAPMessage *)
1084 ldap_first_message LDAP_P((
1085         LDAP *ld,
1086         LDAPMessage *chain ));
1087
1088 LDAP_F( LDAPMessage *)
1089 ldap_next_message LDAP_P((
1090         LDAP *ld,
1091         LDAPMessage *msg ));
1092
1093 LDAP_F( int )
1094 ldap_count_messages LDAP_P((
1095         LDAP *ld,
1096         LDAPMessage *chain ));
1097
1098
1099 /*
1100  * in references.c:
1101  */
1102 LDAP_F( LDAPMessage *)
1103 ldap_first_reference LDAP_P((
1104         LDAP *ld,
1105         LDAPMessage *chain ));
1106
1107 LDAP_F( LDAPMessage *)
1108 ldap_next_reference LDAP_P((
1109         LDAP *ld,
1110         LDAPMessage *ref ));
1111
1112 LDAP_F( int )
1113 ldap_count_references LDAP_P((
1114         LDAP *ld,
1115         LDAPMessage *chain ));
1116
1117 LDAP_F( int )
1118 ldap_parse_reference LDAP_P((
1119         LDAP                    *ld,
1120         LDAPMessage             *ref,
1121         char                    ***referralsp,
1122         LDAPControl             ***serverctrls,
1123         int                             freeit));
1124
1125
1126 /*
1127  * in getentry.c:
1128  */
1129 LDAP_F( LDAPMessage *)
1130 ldap_first_entry LDAP_P((
1131         LDAP *ld,
1132         LDAPMessage *chain ));
1133
1134 LDAP_F( LDAPMessage *)
1135 ldap_next_entry LDAP_P((
1136         LDAP *ld,
1137         LDAPMessage *entry ));
1138
1139 LDAP_F( int )
1140 ldap_count_entries LDAP_P((
1141         LDAP *ld,
1142         LDAPMessage *chain ));
1143
1144 LDAP_F( int )
1145 ldap_get_entry_controls LDAP_P((
1146         LDAP                    *ld,
1147         LDAPMessage             *entry,
1148         LDAPControl             ***serverctrls));
1149
1150
1151 /*
1152  * in addentry.c
1153  */
1154 LDAP_F( LDAPMessage *)
1155 ldap_delete_result_entry LDAP_P((
1156         LDAPMessage **list,
1157         LDAPMessage *e ));
1158
1159 LDAP_F( void )
1160 ldap_add_result_entry LDAP_P((
1161         LDAPMessage **list,
1162         LDAPMessage *e ));
1163
1164
1165 /*
1166  * in getdn.c
1167  */
1168 LDAP_F( char * )
1169 ldap_get_dn LDAP_P((
1170         LDAP *ld,
1171         LDAPMessage *entry ));
1172
1173 LDAP_F( char * )
1174 ldap_dn2ufn LDAP_P((
1175         LDAP_CONST char *dn ));
1176
1177 LDAP_F( char ** )
1178 ldap_explode_dn LDAP_P((
1179         LDAP_CONST char *dn,
1180         int notypes ));
1181
1182 LDAP_F( char ** )
1183 ldap_explode_rdn LDAP_P((
1184         LDAP_CONST char *rdn,
1185         int notypes ));
1186
1187 LDAP_F( char * )
1188 ldap_dn2dcedn LDAP_P(( LDAP_CONST char *dn ));  /* deprecated */
1189
1190 LDAP_F( char * )
1191 ldap_dcedn2dn LDAP_P(( LDAP_CONST char *dce )); /* deprecated */
1192
1193 /*
1194  * in getattr.c
1195  */
1196 LDAP_F( char *)
1197 ldap_first_attribute LDAP_P((                                                                    
1198         LDAP *ld,
1199         LDAPMessage *entry,
1200         BerElement **ber ));
1201
1202 LDAP_F( char *)
1203 ldap_next_attribute LDAP_P((
1204         LDAP *ld,
1205         LDAPMessage *entry,
1206         BerElement *ber ));
1207
1208
1209 /*
1210  * in getvalues.c
1211  */
1212 LDAP_F( char **)
1213 ldap_get_values LDAP_P((
1214         LDAP *ld,
1215         LDAPMessage *entry,
1216         LDAP_CONST char *target ));
1217
1218 LDAP_F( struct berval **)
1219 ldap_get_values_len LDAP_P((
1220         LDAP *ld,
1221         LDAPMessage *entry,
1222         LDAP_CONST char *target ));
1223
1224 LDAP_F( int )
1225 ldap_count_values LDAP_P((
1226         char **vals ));
1227
1228 LDAP_F( int )
1229 ldap_count_values_len LDAP_P((
1230         struct berval **vals ));
1231
1232 LDAP_F( void )
1233 ldap_value_free LDAP_P((
1234         char **vals ));
1235
1236 LDAP_F( void )
1237 ldap_value_free_len LDAP_P((
1238         struct berval **vals ));
1239
1240 /*
1241  * in result.c:
1242  */
1243 LDAP_F( int )
1244 ldap_result LDAP_P((
1245         LDAP *ld,
1246         int msgid,
1247         int all,
1248         struct timeval *timeout,
1249         LDAPMessage **result ));
1250
1251 LDAP_F( int )
1252 ldap_msgtype LDAP_P((
1253         LDAPMessage *lm ));
1254
1255 LDAP_F( int )
1256 ldap_msgid   LDAP_P((
1257         LDAPMessage *lm ));
1258
1259 LDAP_F( int )
1260 ldap_msgfree LDAP_P((
1261         LDAPMessage *lm ));
1262
1263 LDAP_F( int )
1264 ldap_msgdelete LDAP_P((
1265         LDAP *ld,
1266         int msgid ));
1267
1268
1269 /*
1270  * in search.c:
1271  */
1272 LDAP_F( int )
1273 ldap_search_ext LDAP_P((
1274         LDAP                    *ld,
1275         LDAP_CONST char *base,
1276         int                             scope,
1277         LDAP_CONST char *filter,
1278         char                    **attrs,
1279         int                             attrsonly,
1280         LDAPControl             **serverctrls,
1281         LDAPControl             **clientctrls,
1282         struct timeval  *timeout,
1283         int                             sizelimit,
1284         int                             *msgidp ));
1285
1286 LDAP_F( int )
1287 ldap_search_ext_s LDAP_P((
1288         LDAP                    *ld,
1289         LDAP_CONST char *base,
1290         int                             scope,
1291         LDAP_CONST char *filter,
1292         char                    **attrs,
1293         int                             attrsonly,
1294         LDAPControl             **serverctrls,
1295         LDAPControl             **clientctrls,
1296         struct timeval  *timeout,
1297         int                             sizelimit,
1298         LDAPMessage             **res ));
1299
1300 LDAP_F( int )
1301 ldap_search LDAP_P((    /* deprecated */
1302         LDAP *ld,
1303         LDAP_CONST char *base,
1304         int scope,
1305         LDAP_CONST char *filter,
1306         char **attrs,
1307         int attrsonly ));
1308
1309 LDAP_F( int )
1310 ldap_search_s LDAP_P((  /* deprecated */
1311         LDAP *ld,
1312         LDAP_CONST char *base,
1313         int scope,
1314         LDAP_CONST char *filter,
1315         char **attrs,
1316         int attrsonly,
1317         LDAPMessage **res ));
1318
1319 LDAP_F( int )
1320 ldap_search_st LDAP_P(( /* deprecated */
1321         LDAP *ld,
1322         LDAP_CONST char *base,
1323         int scope,
1324         LDAP_CONST char *filter,
1325     char **attrs,
1326         int attrsonly,
1327         struct timeval *timeout,
1328         LDAPMessage **res ));
1329
1330 /*
1331  * in unbind.c
1332  */
1333 LDAP_F( int )
1334 ldap_unbind LDAP_P(( /* deprecated */
1335         LDAP *ld ));
1336
1337 LDAP_F( int )
1338 ldap_unbind_s LDAP_P(( /* deprecated */
1339         LDAP *ld ));
1340
1341 LDAP_F( int )
1342 ldap_unbind_ext LDAP_P((
1343         LDAP                    *ld,
1344         LDAPControl             **serverctrls,
1345         LDAPControl             **clientctrls));
1346
1347 LDAP_F( int )
1348 ldap_unbind_ext_s LDAP_P((
1349         LDAP                    *ld,
1350         LDAPControl             **serverctrls,
1351         LDAPControl             **clientctrls));
1352
1353 /*
1354  * in getfilter.c
1355  *      (deprecated)
1356  */
1357 LDAP_F( LDAPFiltDesc *)
1358 ldap_init_getfilter LDAP_P(( /* deprecated */
1359         LDAP_CONST char *fname ));
1360
1361 LDAP_F( LDAPFiltDesc *)
1362 ldap_init_getfilter_buf LDAP_P(( /* deprecated */
1363         /* LDAP_CONST */ char *buf,
1364         ber_len_t buflen ));
1365
1366 LDAP_F( LDAPFiltInfo *)
1367 ldap_getfirstfilter LDAP_P(( /* deprecated */
1368         LDAPFiltDesc *lfdp,
1369         /* LDAP_CONST */ char *tagpat,
1370         /* LDAP_CONST */ char *value ));
1371
1372 LDAP_F( LDAPFiltInfo *)
1373 ldap_getnextfilter LDAP_P(( /* deprecated */
1374         LDAPFiltDesc *lfdp ));
1375
1376 LDAP_F( void )
1377 ldap_setfilteraffixes LDAP_P(( /* deprecated */
1378         LDAPFiltDesc *lfdp,
1379         LDAP_CONST char *prefix,
1380         LDAP_CONST char *suffix ));
1381
1382 LDAP_F( void )
1383 ldap_build_filter LDAP_P(( /* deprecated */
1384         char *buf,
1385         ber_len_t buflen,
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,
1391         char **valwords ));
1392
1393
1394 /*
1395  * in free.c
1396  */
1397
1398 LDAP_F( void * )
1399 ldap_memalloc LDAP_P((
1400         ber_len_t s ));
1401
1402 LDAP_F( void * )
1403 ldap_memrealloc LDAP_P((
1404         void* p,
1405         ber_len_t s ));
1406
1407 LDAP_F( void * )
1408 ldap_memcalloc LDAP_P((
1409         ber_len_t n,
1410         ber_len_t s ));
1411
1412 LDAP_F( void )
1413 ldap_memfree LDAP_P((
1414         void* p ));
1415
1416 LDAP_F( void )
1417 ldap_memvfree LDAP_P((
1418         void** v ));
1419
1420 LDAP_F( char * )
1421 ldap_strdup LDAP_P((
1422         LDAP_CONST char * ));
1423
1424 LDAP_F( void )
1425 ldap_getfilter_free LDAP_P((
1426         LDAPFiltDesc *lfdp ));
1427
1428 LDAP_F( void )
1429 ldap_mods_free LDAP_P((
1430         LDAPMod **mods,
1431         int freemods ));
1432
1433
1434 /*
1435  * in friendly.c
1436  *      (deprecated)
1437  */
1438 LDAP_F( char * )
1439 ldap_friendly_name LDAP_P(( /* deprecated */
1440         LDAP_CONST char *filename,
1441         /* LDAP_CONST */ char *uname,
1442         LDAPFriendlyMap **map ));
1443
1444 LDAP_F( void )
1445 ldap_free_friendlymap LDAP_P(( /* deprecated */
1446         LDAPFriendlyMap **map ));
1447
1448
1449 /*
1450  * in sort.c
1451  */
1452 typedef int (LDAP_SORT_AD_CMP_PROC) LDAP_P((
1453         LDAP_CONST char *left,
1454         LDAP_CONST char *right ));
1455
1456 typedef int (LDAP_SORT_AV_CMP_PROC) LDAP_P((
1457         LDAP_CONST void *left,
1458         LDAP_CONST void *right ));
1459
1460 LDAP_F( int )
1461 ldap_sort_entries LDAP_P(( LDAP *ld,
1462         LDAPMessage **chain,
1463         LDAP_CONST char *attr,
1464         LDAP_SORT_AD_CMP_PROC *cmp ));
1465
1466 LDAP_F( int )   /* deprecated */
1467 ldap_sort_values LDAP_P((
1468         LDAP *ld,
1469         char **vals,
1470         LDAP_SORT_AV_CMP_PROC *cmp ));
1471
1472 LDAP_F( int ) /* deprecated */
1473 ldap_sort_strcasecmp LDAP_P((
1474         LDAP_CONST void *a,
1475         LDAP_CONST void *b ));
1476
1477
1478 /*
1479  * in url.c
1480  *
1481  * need _ext varients
1482  */
1483 LDAP_F( int )
1484 ldap_is_ldap_url LDAP_P((
1485         LDAP_CONST char *url ));
1486
1487 LDAP_F( int )
1488 ldap_is_ldaps_url LDAP_P((
1489         LDAP_CONST char *url ));
1490
1491 LDAP_F( int )
1492 ldap_is_ldapi_url LDAP_P((
1493         LDAP_CONST char *url ));
1494
1495 LDAP_F( int )
1496 ldap_url_parse LDAP_P((
1497         LDAP_CONST char *url,
1498         LDAPURLDesc **ludpp ));
1499
1500 LDAP_F( void )
1501 ldap_free_urldesc LDAP_P((
1502         LDAPURLDesc *ludp ));
1503
1504 LDAP_F( int )
1505 ldap_url_search LDAP_P((
1506         LDAP *ld,
1507         LDAP_CONST char *url,
1508         int attrsonly ));
1509
1510 LDAP_F( int )
1511 ldap_url_search_s LDAP_P((
1512         LDAP *ld,
1513         LDAP_CONST char *url,
1514         int attrsonly,
1515         LDAPMessage **res ));
1516
1517 LDAP_F( int )
1518 ldap_url_search_st LDAP_P((
1519         LDAP *ld,
1520         LDAP_CONST char *url,
1521         int attrsonly,
1522         struct timeval *timeout,
1523         LDAPMessage **res ));
1524
1525 /* 
1526  * in sortctrl.c  
1527  */
1528 /*
1529  * structure for a sort-key 
1530  */
1531 typedef struct ldapsortkey {
1532         char *  attributeType;
1533         char *  orderingRule;
1534         int     reverseOrder;
1535 } LDAPSortKey;
1536
1537 LDAP_F( int )
1538 ldap_create_sort_keylist LDAP_P((
1539         LDAPSortKey ***sortKeyList,
1540         char        *keyString ));
1541
1542 LDAP_F( void )
1543 ldap_free_sort_keylist LDAP_P((
1544         LDAPSortKey **sortkeylist ));
1545
1546 LDAP_F( int )
1547 ldap_create_sort_control LDAP_P((       
1548         LDAP *ld, 
1549         LDAPSortKey **keyList,
1550         int ctl_iscritical,
1551         LDAPControl **ctrlp ));
1552
1553 LDAP_F( int )
1554 ldap_parse_sort_control LDAP_P((
1555         LDAP           *ld, 
1556         LDAPControl    **ctrlp,  
1557         unsigned long  *result,
1558         char           **attribute ));
1559
1560
1561 /* 
1562  * in vlvctrl.c  
1563  */
1564
1565 /*
1566  * structure for virtul list.
1567  */
1568 typedef struct ldapvlvinfo {
1569         int             ldvlv_version;
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;
1577 } LDAPVLVInfo;
1578
1579 LDAP_F( int ) 
1580 ldap_create_vlv_control LDAP_P((
1581         LDAP *ld, 
1582         LDAPVLVInfo *ldvlistp,
1583         LDAPControl **ctrlp ));
1584
1585 LDAP_F( int )
1586 ldap_parse_vlv_control LDAP_P(( 
1587         LDAP          *ld, 
1588         LDAPControl   **ctrls,
1589         unsigned long *target_posp, 
1590         unsigned long *list_countp, 
1591         struct berval **contextp,
1592         int           *errcodep ));
1593
1594
1595 LDAP_END_DECL
1596 #endif /* _LDAP_H */