]> git.sur5r.net Git - openldap/blob - include/ldap.h
Ready for 2.0.3 release
[openldap] / include / ldap.h
1 /* $OpenLDAP$ */
2 /*
3  * Copyright 1998-2000 The OpenLDAP Foundation, Redwood City, California, USA
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms are permitted only
7  * as authorized by the OpenLDAP Public License.  A copy of this
8  * license is available at http://www.OpenLDAP.org/license.html or
9  * in file LICENSE in the top-level directory of the distribution.
10  */
11 /* Portions
12  * Copyright (c) 1990 Regents of the University of Michigan.
13  * All rights reserved.
14  *
15  * Redistribution and use in source and binary forms are permitted
16  * provided that this notice is preserved and that due credit is given
17  * to the University of Michigan at Ann Arbor. The name of the University
18  * may not be used to endorse or promote products derived from this
19  * software without specific prior written permission. This software
20  * is provided ``as is'' without express or implied warranty.
21  */
22
23 #ifndef _LDAP_H
24 #define _LDAP_H
25
26 /* pull in lber */
27 #include <lber.h>
28
29 LDAP_BEGIN_DECL
30
31 #define LDAP_VERSION1   1
32 #define LDAP_VERSION2   2
33 #define LDAP_VERSION3   3
34
35 #define LDAP_VERSION_MIN        LDAP_VERSION2
36 #define LDAP_VERSION            LDAP_VERSION2
37 #define LDAP_VERSION_MAX        LDAP_VERSION3
38
39 /*
40  * We'll use 2000+draft revision for our API version number
41  * As such, the number will be above the old RFC but below 
42  * whatever number does finally get assigned
43  */
44 #define LDAP_API_VERSION        2004
45 #define LDAP_VENDOR_NAME        "OpenLDAP"
46 /*
47  * vendor version number
48  *      2.0.0  -> 20000
49  *      2.3.16 -> 20316
50  */
51 #define LDAP_VENDOR_VERSION     20003
52
53 /* OpenLDAP API Features */
54 #define LDAP_API_FEATURE_X_OPENLDAP LDAP_VENDOR_VERSION
55
56 /* include LDAP_API_FEATURE defines */
57 #include <ldap_features.h>
58
59 #if defined( LDAP_API_FEATURE_X_OPENLDAP_REENTRANT ) || \
60         ( defined( LDAP_THREAD_SAFE ) && \
61                 defined( LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE ) )
62         /* -lldap may or may not be thread safe */
63         /* -lldap_r, if available, is always thread safe */
64 #       define  LDAP_API_FEATURE_THREAD_SAFE 1
65 #endif
66 #if defined( LDAP_THREAD_SAFE ) && \
67         defined( LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE )
68 /* #define LDAP_API_FEATURE_SESSION_SAFE        1       */
69 /* #define LDAP_API_OPERATION_SESSION_SAFE      1       */
70 #endif
71
72 #define LDAP_PORT               389             /* ldap:///             default LDAP port */
73 #define LDAPS_PORT              636             /* ldaps:///    default LDAP over TLS port */
74
75 #define LDAP_ROOT_DSE                           ""
76 #define LDAP_NO_ATTRS                           "1.1"
77 #define LDAP_ALL_USER_ATTRIBUTES        "*"
78 #define LDAP_ALL_OPERATIONAL_ATTRIBUTES "+" /* OpenLDAP extension */
79
80 /*
81  * LDAP_OPTions defined by draft-ldapext-ldap-c-api-02
82  * 0x0000 - 0x0fff reserved for api options
83  * 0x1000 - 0x3fff reserved for api extended options
84  * 0x4000 - 0x7fff reserved for private and experimental options
85  */
86 #define LDAP_OPT_API_INFO                       0x0000
87 #define LDAP_OPT_DESC                           0x0001 /* deprecated */
88 #define LDAP_OPT_DEREF                          0x0002
89 #define LDAP_OPT_SIZELIMIT                      0x0003
90 #define LDAP_OPT_TIMELIMIT                      0x0004
91 /* 0x05 - 0x07 not defined by current draft */
92 #define LDAP_OPT_REFERRALS                      0x0008
93 #define LDAP_OPT_RESTART                        0x0009
94 /* 0x0a - 0x10 not defined by current draft */
95 #define LDAP_OPT_PROTOCOL_VERSION       0x0011
96 #define LDAP_OPT_SERVER_CONTROLS        0x0012
97 #define LDAP_OPT_CLIENT_CONTROLS        0x0013
98 /* 0x14 not defined by current draft */
99 #define LDAP_OPT_API_FEATURE_INFO       0x0015
100
101 /* 0x16 - 0x2f not defined by current draft */
102 #define LDAP_OPT_HOST_NAME                      0x0030
103 #define LDAP_OPT_ERROR_NUMBER           0x0031
104 #define LDAP_OPT_ERROR_STRING           0x0032
105 #define LDAP_OPT_MATCHED_DN                     0x0033
106
107 /* 0x34 - 0x0fff not defined by current draft */
108
109 #define LDAP_OPT_PRIVATE_EXTENSION_BASE 0x4000  /* to 0x7FFF inclusive */
110
111 /* private and experimental options */
112 /* OpenLDAP specific options */
113 #define LDAP_OPT_DEBUG_LEVEL            0x5001  /* debug level */
114 #define LDAP_OPT_TIMEOUT                        0x5002  /* default timeout */
115 #define LDAP_OPT_REFHOPLIMIT            0x5003  /* ref hop limit */
116 #define LDAP_OPT_NETWORK_TIMEOUT        0x5005  /* socket level timeout */
117 #define LDAP_OPT_URI                            0x5006
118
119 /* OpenLDAP TLS options */
120 #define LDAP_OPT_X_TLS_CACERTFILE       0x6001
121 #define LDAP_OPT_X_TLS_CACERTDIR        0x6002
122 #define LDAP_OPT_X_TLS_CERT             0x6003
123 #define LDAP_OPT_X_TLS_CERTFILE         0x6004
124 #define LDAP_OPT_X_TLS_KEYFILE          0x6005
125 #define LDAP_OPT_X_TLS_REQUIRE_CERT     0x6006
126 #define LDAP_OPT_X_TLS                  0x6007
127 #define LDAP_OPT_X_TLS_PROTOCOL         0x6008
128 #define LDAP_OPT_X_TLS_CIPHER_SUITE     0x6009
129 #define LDAP_OPT_X_TLS_RANDOM_FILE      0x600a
130
131 #define LDAP_OPT_X_TLS_NEVER            0
132 #define LDAP_OPT_X_TLS_HARD             1
133 #define LDAP_OPT_X_TLS_DEMAND           2
134 #define LDAP_OPT_X_TLS_ALLOW            3
135 #define LDAP_OPT_X_TLS_TRY              4
136
137 /* OpenLDAP SASL options */
138 #define LDAP_OPT_X_SASL_MECH                    0x6100
139 #define LDAP_OPT_X_SASL_REALM                   0x6101
140 #define LDAP_OPT_X_SASL_AUTHCID                 0x6102
141 #define LDAP_OPT_X_SASL_AUTHZID                 0x6103
142 #define LDAP_OPT_X_SASL_SSF                             0x6104 /* read-only */
143 #define LDAP_OPT_X_SASL_SSF_EXTERNAL    0x6105 /* write-only */
144 #define LDAP_OPT_X_SASL_SECPROPS                0x6106 /* write-only */
145 #define LDAP_OPT_X_SASL_SSF_MIN                 0x6107
146 #define LDAP_OPT_X_SASL_SSF_MAX                 0x6108
147 #define LDAP_OPT_X_SASL_MAXBUFSIZE              0x6109
148
149
150 /* on/off values */
151 #define LDAP_OPT_ON             ((void *) 1)
152 #define LDAP_OPT_OFF    ((void *) 0)
153
154 /*
155  * ldap_get_option() and ldap_set_option() return values.
156  * As later versions may return other values indicating
157  * failure, current applications should only compare returned
158  * value against LDAP_OPT_SUCCESS.
159  */
160 #define LDAP_OPT_SUCCESS        0
161 #define LDAP_OPT_ERROR          (-1)
162
163 #define LDAP_API_INFO_VERSION   (1)
164 typedef struct ldapapiinfo {
165         int             ldapai_info_version;            /* version of LDAPAPIInfo (1) */
166         int             ldapai_api_version;                     /* revision of API supported */
167         int             ldapai_protocol_version;        /* highest LDAP version supported */
168         char    **ldapai_extensions;            /* names of API extensions */
169         char    *ldapai_vendor_name;            /* name of supplier */
170         int             ldapai_vendor_version;          /* supplier-specific version * 100 */
171 } LDAPAPIInfo;
172
173 #define LDAP_FEATURE_INFO_VERSION (1) /* version of api feature structure */
174 typedef struct ldap_apifeature_info {
175         int             ldapaif_info_version; /* version of this struct (1) */
176         char*   ldapaif_name;    /* matches LDAP_API_FEATURE_... less the prefix */
177         int             ldapaif_version; /* matches the value LDAP_API_FEATURE_... */
178 } LDAPAPIFeatureInfo;
179
180 typedef struct ldapcontrol {
181         char *                  ldctl_oid;
182         struct berval   ldctl_value;
183         char                    ldctl_iscritical;
184 } LDAPControl;
185
186 /* LDAP Controls */
187         /* chase referrals controls */
188 #define LDAP_CONTROL_REFERRALS  "1.2.840.113666.1.4.616"
189 #define LDAP_CHASE_SUBORDINATE_REFERRALS        0x0020U
190 #define LDAP_CHASE_EXTERNAL_REFERRALS   0x0040U
191
192 #define LDAP_CONTROL_MANAGEDSAIT "2.16.840.1.113730.3.4.2"
193
194 /* Experimental Controls */
195
196 #define LDAP_CONTROL_SORTREQUEST    "1.2.840.113556.1.4.473"
197 #define LDAP_CONTROL_SORTRESPONSE       "1.2.840.113556.1.4.474"
198 #define LDAP_CONTROL_VLVREQUEST         "2.16.840.1.113730.3.4.9"
199 #define LDAP_CONTROL_VLVRESPONSE    "2.16.840.1.113730.3.4.10"
200
201 /* LDAP Unsolicited Notifications */
202 #define LDAP_NOTICE_OF_DISCONNECTION    "1.3.6.1.4.1.1466.20036"
203 #define LDAP_NOTICE_DISCONNECT LDAP_NOTICE_OF_DISCONNECTION
204
205 /* LDAP Extended Operations */
206 #define LDAP_EXOP_START_TLS "1.3.6.1.4.1.1466.20037"
207
208 #define LDAP_EXOP_X_MODIFY_PASSWD "1.3.6.1.4.1.4203.1.11.1"
209 #define LDAP_TAG_EXOP_X_MODIFY_PASSWD_ID        ((ber_tag_t) 0x80U)
210 #define LDAP_TAG_EXOP_X_MODIFY_PASSWD_OLD       ((ber_tag_t) 0x81U)
211 #define LDAP_TAG_EXOP_X_MODIFY_PASSWD_NEW       ((ber_tag_t) 0x82U)
212 #define LDAP_TAG_EXOP_X_MODIFY_PASSWD_GEN       ((ber_tag_t) 0x80U)
213
214 /* 
215  * specific LDAP instantiations of BER types we know about
216  */
217
218 /* Overview of LBER tag construction
219  *
220  *      Bits
221  *      ______
222  *      8 7 | CLASS
223  *      0 0 = UNIVERSAL
224  *      0 1 = APPLICATION
225  *      1 0 = CONTEXT-SPECIFIC
226  *      1 1 = PRIVATE
227  *              _____
228  *              | 6 | DATA-TYPE
229  *                0 = PRIMITIVE
230  *                1 = CONSTRUCTED
231  *                      ___________
232  *                      | 5 ... 1 | TAG-NUMBER
233  */
234
235 /* general stuff */
236 #define LDAP_TAG_MESSAGE        ((ber_tag_t) 0x30U)     /* constructed + 16 */
237 #define LDAP_TAG_MSGID          ((ber_tag_t) 0x02U)     /* integer */
238 #define LDAP_TAG_LDAPDN         ((ber_tag_t) 0x04U)     /* octect string */
239 #define LDAP_TAG_LDAPCRED       ((ber_tag_t) 0x04U)     /* octect string */
240 #define LDAP_TAG_CONTROLS       ((ber_tag_t) 0xa0U)     /* context specific + constructed + 0 */
241 #define LDAP_TAG_REFERRAL       ((ber_tag_t) 0xa3U)     /* context specific + constructed + 3 */
242
243 #define LDAP_TAG_NEWSUPERIOR    ((ber_tag_t) 0x80U)     /* context-specific + primitive + 0 */
244
245 #define LDAP_TAG_EXOP_REQ_OID   ((ber_tag_t) 0x80U)     /* context specific + primitive */
246 #define LDAP_TAG_EXOP_REQ_VALUE ((ber_tag_t) 0x81U)     /* context specific + primitive */
247 #define LDAP_TAG_EXOP_RES_OID   ((ber_tag_t) 0x8aU)     /* context specific + primitive */
248 #define LDAP_TAG_EXOP_RES_VALUE ((ber_tag_t) 0x8bU)     /* context specific + primitive */
249
250 #define LDAP_TAG_SASL_RES_CREDS ((ber_tag_t) 0x87U)     /* context specific + primitive */
251
252
253 /* possible operations a client can invoke */
254 #define LDAP_REQ_BIND                   ((ber_tag_t) 0x60U)     /* application + constructed */
255 #define LDAP_REQ_UNBIND                 ((ber_tag_t) 0x42U)     /* application + primitive   */
256 #define LDAP_REQ_SEARCH                 ((ber_tag_t) 0x63U)     /* application + constructed */
257 #define LDAP_REQ_MODIFY                 ((ber_tag_t) 0x66U)     /* application + constructed */
258 #define LDAP_REQ_ADD                    ((ber_tag_t) 0x68U)     /* application + constructed */
259 #define LDAP_REQ_DELETE                 ((ber_tag_t) 0x4aU)     /* application + primitive   */
260 #define LDAP_REQ_MODDN                  ((ber_tag_t) 0x6cU)     /* application + constructed */
261 #define LDAP_REQ_MODRDN                 LDAP_REQ_MODDN  
262 #define LDAP_REQ_RENAME                 LDAP_REQ_MODDN  
263 #define LDAP_REQ_COMPARE                ((ber_tag_t) 0x6eU)     /* application + constructed */
264 #define LDAP_REQ_ABANDON                ((ber_tag_t) 0x50U)     /* application + primitive   */
265 #define LDAP_REQ_EXTENDED               ((ber_tag_t) 0x77U)     /* application + constructed */
266
267 /* possible result types a server can return */
268 #define LDAP_RES_BIND                   ((ber_tag_t) 0x61U)     /* application + constructed */
269 #define LDAP_RES_SEARCH_ENTRY           ((ber_tag_t) 0x64U)     /* application + constructed */
270 #define LDAP_RES_SEARCH_REFERENCE       ((ber_tag_t) 0x73U)     /* V3: application + constructed */
271 #define LDAP_RES_SEARCH_RESULT          ((ber_tag_t) 0x65U)     /* application + constructed */
272 #define LDAP_RES_MODIFY                 ((ber_tag_t) 0x67U)     /* application + constructed */
273 #define LDAP_RES_ADD                    ((ber_tag_t) 0x69U)     /* application + constructed */
274 #define LDAP_RES_DELETE                 ((ber_tag_t) 0x6bU)     /* application + constructed */
275 #define LDAP_RES_MODDN                  ((ber_tag_t) 0x6dU)     /* application + constructed */
276 #define LDAP_RES_MODRDN                 LDAP_RES_MODDN  /* application + constructed */
277 #define LDAP_RES_RENAME                 LDAP_RES_MODDN  /* application + constructed */
278 #define LDAP_RES_COMPARE                ((ber_tag_t) 0x6fU)     /* application + constructed */
279 #define LDAP_RES_EXTENDED               ((ber_tag_t) 0x78U)     /* V3: application + constructed */
280 #define LDAP_RES_EXTENDED_PARTIAL       ((ber_tag_t) 0x79U)     /* V3+: application + constructed */
281
282 #define LDAP_RES_ANY                    (-1)
283 #define LDAP_RES_UNSOLICITED    (0)
284
285
286 /* sasl methods */
287 #define LDAP_SASL_SIMPLE                ((char*)0)
288
289
290 /* authentication methods available */
291 #define LDAP_AUTH_NONE          ((ber_tag_t) 0x00U)     /* no authentication              */
292 #define LDAP_AUTH_SIMPLE        ((ber_tag_t) 0x80U)     /* context specific + primitive   */
293 #define LDAP_AUTH_SASL          ((ber_tag_t) 0xa3U)     /* context specific + primitive   */
294 #define LDAP_AUTH_KRBV4         ((ber_tag_t) 0xffU)     /* means do both of the following */
295 #define LDAP_AUTH_KRBV41        ((ber_tag_t) 0x81U)     /* context specific + primitive   */
296 #define LDAP_AUTH_KRBV42        ((ber_tag_t) 0x82U)     /* context specific + primitive   */
297
298
299 /* filter types */
300 #define LDAP_FILTER_AND         ((ber_tag_t) 0xa0U)     /* context specific + constructed */
301 #define LDAP_FILTER_OR          ((ber_tag_t) 0xa1U)     /* context specific + constructed */
302 #define LDAP_FILTER_NOT         ((ber_tag_t) 0xa2U)     /* context specific + constructed */
303 #define LDAP_FILTER_EQUALITY    ((ber_tag_t) 0xa3U)     /* context specific + constructed */
304 #define LDAP_FILTER_SUBSTRINGS  ((ber_tag_t) 0xa4U)     /* context specific + constructed */
305 #define LDAP_FILTER_GE          ((ber_tag_t) 0xa5U)     /* context specific + constructed */
306 #define LDAP_FILTER_LE          ((ber_tag_t) 0xa6U)     /* context specific + constructed */
307 #define LDAP_FILTER_PRESENT     ((ber_tag_t) 0x87U)     /* context specific + primitive   */
308 #define LDAP_FILTER_APPROX      ((ber_tag_t) 0xa8U)     /* context specific + constructed */
309 #define LDAP_FILTER_EXT         ((ber_tag_t) 0xa9U)     /* context specific + constructed */
310
311 /* extended filter component types */
312 #define LDAP_FILTER_EXT_OID     ((ber_tag_t) 0x81U)     /* context specific */
313 #define LDAP_FILTER_EXT_TYPE    ((ber_tag_t) 0x82U)     /* context specific */
314 #define LDAP_FILTER_EXT_VALUE   ((ber_tag_t) 0x83U)     /* context specific */
315 #define LDAP_FILTER_EXT_DNATTRS ((ber_tag_t) 0x84U)     /* context specific */
316
317 /* substring filter component types */
318 #define LDAP_SUBSTRING_INITIAL  ((ber_tag_t) 0x80U)     /* context specific */
319 #define LDAP_SUBSTRING_ANY      ((ber_tag_t) 0x81U)     /* context specific */
320 #define LDAP_SUBSTRING_FINAL    ((ber_tag_t) 0x82U)     /* context specific */
321
322 /* search scopes */
323 #define LDAP_SCOPE_BASE         ((ber_int_t) 0x0000)
324 #define LDAP_SCOPE_ONELEVEL     ((ber_int_t) 0x0001)
325 #define LDAP_SCOPE_SUBTREE      ((ber_int_t) 0x0002)
326
327 /* substring filter component types */
328 #define LDAP_SUBSTRING_INITIAL  ((ber_tag_t) 0x80U)     /* context specific */
329 #define LDAP_SUBSTRING_ANY      ((ber_tag_t) 0x81U)     /* context specific */
330 #define LDAP_SUBSTRING_FINAL    ((ber_tag_t) 0x82U)     /* context specific */
331
332 /* 
333  * possible error codes we can return
334  */
335
336 #define LDAP_RANGE(n,x,y)       (((x) <= (n)) && ((n) <= (y)))
337
338 #define LDAP_SUCCESS                    0x00
339 #define LDAP_OPERATIONS_ERROR           0x01
340 #define LDAP_PROTOCOL_ERROR             0x02
341 #define LDAP_TIMELIMIT_EXCEEDED         0x03
342 #define LDAP_SIZELIMIT_EXCEEDED         0x04
343 #define LDAP_COMPARE_FALSE              0x05
344 #define LDAP_COMPARE_TRUE               0x06
345 #define LDAP_AUTH_METHOD_NOT_SUPPORTED  0x07
346 #define LDAP_STRONG_AUTH_NOT_SUPPORTED  LDAP_AUTH_METHOD_NOT_SUPPORTED
347 #define LDAP_STRONG_AUTH_REQUIRED       0x08
348 #define LDAP_PARTIAL_RESULTS            0x09    /* not listed in v3 */
349
350 #define LDAP_REFERRAL                           0x0a /* LDAPv3 */
351 #define LDAP_ADMINLIMIT_EXCEEDED        0x0b /* LDAPv3 */
352 #define LDAP_UNAVAILABLE_CRITICAL_EXTENSION     0x0c /* LDAPv3 */
353 #define LDAP_CONFIDENTIALITY_REQUIRED   0x0d /* LDAPv3 */
354 #define LDAP_SASL_BIND_IN_PROGRESS      0x0e /* LDAPv3 */       
355
356 #define LDAP_ATTR_ERROR(n)      LDAP_RANGE((n),0x10,0x15) /* 16-21 */
357
358 #define LDAP_NO_SUCH_ATTRIBUTE          0x10
359 #define LDAP_UNDEFINED_TYPE             0x11
360 #define LDAP_INAPPROPRIATE_MATCHING     0x12
361 #define LDAP_CONSTRAINT_VIOLATION       0x13
362 #define LDAP_TYPE_OR_VALUE_EXISTS       0x14
363 #define LDAP_INVALID_SYNTAX             0x15
364
365 #define LDAP_NAME_ERROR(n)      LDAP_RANGE((n),0x20,0x24) /* 32-34,36 */
366
367 #define LDAP_NO_SUCH_OBJECT             0x20
368 #define LDAP_ALIAS_PROBLEM              0x21
369 #define LDAP_INVALID_DN_SYNTAX          0x22
370 #define LDAP_IS_LEAF                    0x23 /* not LDAPv3 */
371 #define LDAP_ALIAS_DEREF_PROBLEM        0x24
372
373 #define LDAP_SECURITY_ERROR(n)  LDAP_RANGE((n),0x30,0x32) /* 48-50 */
374
375 #define LDAP_INAPPROPRIATE_AUTH         0x30
376 #define LDAP_INVALID_CREDENTIALS        0x31
377 #define LDAP_INSUFFICIENT_ACCESS        0x32
378
379 #define LDAP_SERVICE_ERROR(n)   LDAP_RANGE((n),0x33,0x36) /* 51-54 */
380
381 #define LDAP_BUSY                       0x33
382 #define LDAP_UNAVAILABLE                0x34
383 #define LDAP_UNWILLING_TO_PERFORM       0x35
384 #define LDAP_LOOP_DETECT                0x36
385
386 #define LDAP_UPDATE_ERROR(n)    LDAP_RANGE((n),0x40,0x47) /* 64-69,71 */
387
388 #define LDAP_NAMING_VIOLATION           0x40
389 #define LDAP_OBJECT_CLASS_VIOLATION     0x41
390 #define LDAP_NOT_ALLOWED_ON_NONLEAF     0x42
391 #define LDAP_NOT_ALLOWED_ON_RDN         0x43
392 #define LDAP_ALREADY_EXISTS             0x44
393 #define LDAP_NO_OBJECT_CLASS_MODS       0x45
394 #define LDAP_RESULTS_TOO_LARGE          0x46 /* CLDAP */
395 #define LDAP_AFFECTS_MULTIPLE_DSAS      0x47 /* LDAPv3 */
396
397 #define LDAP_OTHER                      0x50
398
399 #define LDAP_API_ERROR(n)               LDAP_RANGE((n),0x51,0x61) /* 81-97 */
400
401 #define LDAP_SERVER_DOWN                0x51
402 #define LDAP_LOCAL_ERROR                0x52
403 #define LDAP_ENCODING_ERROR             0x53
404 #define LDAP_DECODING_ERROR             0x54
405 #define LDAP_TIMEOUT                    0x55
406 #define LDAP_AUTH_UNKNOWN               0x56
407 #define LDAP_FILTER_ERROR               0x57
408 #define LDAP_USER_CANCELLED             0x58
409 #define LDAP_PARAM_ERROR                0x59
410 #define LDAP_NO_MEMORY                  0x5a
411
412 /* not technically reserved for APIs */
413 #define LDAP_CONNECT_ERROR                              0x5b    /* draft-ietf-ldap-c-api-xx */
414 #define LDAP_NOT_SUPPORTED                              0x5c    /* draft-ietf-ldap-c-api-xx */
415 #define LDAP_CONTROL_NOT_FOUND                  0x5d    /* draft-ietf-ldap-c-api-xx */
416 #define LDAP_NO_RESULTS_RETURNED                0x5e    /* draft-ietf-ldap-c-api-xx */
417 #define LDAP_MORE_RESULTS_TO_RETURN             0x5f    /* draft-ietf-ldap-c-api-xx */
418 #define LDAP_CLIENT_LOOP                                0x60    /* draft-ietf-ldap-c-api-xx */
419 #define LDAP_REFERRAL_LIMIT_EXCEEDED    0x61    /* draft-ietf-ldap-c-api-xx */
420
421 /*
422  * This structure represents both ldap messages and ldap responses.
423  * These are really the same, except in the case of search responses,
424  * where a response has multiple messages.
425  */
426
427 typedef struct ldapmsg LDAPMessage;
428
429 /* for modifications */
430 typedef struct ldapmod {
431         int             mod_op;
432
433 #define LDAP_MOD_ADD            ((ber_int_t) 0x0000)
434 #define LDAP_MOD_DELETE         ((ber_int_t) 0x0001)
435 #define LDAP_MOD_REPLACE        ((ber_int_t) 0x0002)
436 #define LDAP_MOD_BVALUES        ((ber_int_t) 0x0080)
437 /* IMPORTANT: do not use code 0x1000 (or above),
438  * it is used internally by the backends!
439  * (see ldap/servers/slapd/slap.h)
440  */
441
442         char            *mod_type;
443         union mod_vals_u {
444                 char            **modv_strvals;
445                 struct berval   **modv_bvals;
446         } mod_vals;
447 #define mod_values      mod_vals.modv_strvals
448 #define mod_bvalues     mod_vals.modv_bvals
449 } LDAPMod;
450
451 /*
452  * structures for ldap getfilter routines
453  */
454
455 typedef struct ldap_filt_info {
456         char                    *lfi_filter;
457         char                    *lfi_desc;
458         int                     lfi_scope;
459         int                     lfi_isexact;
460         struct ldap_filt_info   *lfi_next;
461 } LDAPFiltInfo;
462
463 typedef struct ldap_filt_list {
464     char                        *lfl_tag;
465     char                        *lfl_pattern;
466     char                        *lfl_delims;
467     LDAPFiltInfo                *lfl_ilist;
468     struct ldap_filt_list       *lfl_next;
469 } LDAPFiltList;
470
471
472 #define LDAP_FILT_MAXSIZ        1024
473
474 typedef struct ldap_filt_desc {
475         LDAPFiltList            *lfd_filtlist;
476         LDAPFiltInfo            *lfd_curfip;
477         LDAPFiltInfo            lfd_retfi;
478         char                    lfd_filter[ LDAP_FILT_MAXSIZ ];
479         char                    *lfd_curval;
480         char                    *lfd_curvalcopy;
481         char                    **lfd_curvalwords;
482         char                    *lfd_filtprefix;
483         char                    *lfd_filtsuffix;
484 } LDAPFiltDesc;
485
486
487 /*
488  * structure representing an ldap session which can
489  * encompass connections to multiple servers (in the
490  * face of referrals).
491  */
492 typedef struct ldap LDAP;
493
494 #define LDAP_DEREF_NEVER        0x00
495 #define LDAP_DEREF_SEARCHING    0x01
496 #define LDAP_DEREF_FINDING      0x02
497 #define LDAP_DEREF_ALWAYS       0x03
498
499 #define LDAP_NO_LIMIT           0
500
501 /* how many messages to retrieve results for */
502 #define LDAP_MSG_ONE            0x00
503 #define LDAP_MSG_ALL            0x01
504 #define LDAP_MSG_RECEIVED       0x02
505
506 /*
507  * structure for ldap friendly mapping routines
508  */
509
510 typedef struct ldap_friendly {
511         char    *lf_unfriendly;
512         char    *lf_friendly;
513 } LDAPFriendlyMap;
514
515 /*
516  * types for ldap URL handling
517  */
518 typedef struct ldap_url_desc {
519     struct ldap_url_desc *lud_next;
520     char        *lud_scheme;
521     char        *lud_host;
522     int         lud_port;
523     char        *lud_dn;
524     char        **lud_attrs;
525     int         lud_scope;
526     char        *lud_filter;
527     char        **lud_exts;
528 } LDAPURLDesc;
529
530 #define LDAP_URL_SUCCESS                0x00    /* Success */
531 #define LDAP_URL_ERR_MEM                0x01    /* can't allocate memory space */
532 #define LDAP_URL_ERR_PARAM              0x02    /* parameter is bad */
533
534 #define LDAP_URL_ERR_BADSCHEME  0x03    /* URL doesn't begin with "ldap[si]://" */
535 #define LDAP_URL_ERR_BADENCLOSURE 0x04  /* URL is missing trailing ">" */
536 #define LDAP_URL_ERR_BADURL             0x05    /* URL is bad */
537 #define LDAP_URL_ERR_BADHOST    0x06    /* host port is bad */
538 #define LDAP_URL_ERR_BADATTRS   0x07    /* bad (or missing) attributes */
539 #define LDAP_URL_ERR_BADSCOPE   0x08    /* scope string is invalid (or missing) */
540 #define LDAP_URL_ERR_BADFILTER  0x09    /* bad or missing filter */
541 #define LDAP_URL_ERR_BADEXTS    0x0a    /* bad or missing extensions */
542
543 /*
544  * The API draft spec says we should declare (or cause to be declared)
545  * 'struct timeval'.   We don't.  See IETF LDAPext discussions.
546  */
547 struct timeval;
548
549 /*
550  * in options.c:
551  */
552 LDAP_F( int )
553 ldap_get_option LDAP_P((
554         LDAP *ld,
555         int option,
556         void *outvalue));
557
558 LDAP_F( int )
559 ldap_set_option LDAP_P((
560         LDAP *ld,
561         int option,
562         LDAP_CONST void *invalue));
563
564 /* V3 REBIND Function Callback Prototype */
565 typedef int (LDAP_REBIND_PROC) LDAP_P((
566         LDAP *ld, LDAP_CONST char *url, int request, ber_int_t msgid ));
567
568 LDAP_F( int )
569 ldap_set_rebind_proc LDAP_P((
570         LDAP *ld,
571         LDAP_REBIND_PROC *ldap_proc));
572
573 /*
574  * in controls.c:
575  */
576 LDAP_F( int ) 
577 ldap_create_control LDAP_P(( 
578         const char *requestOID, 
579         BerElement *ber, 
580         int iscritical,
581         LDAPControl **ctrlp ));
582
583 LDAP_F( void )
584 ldap_control_free LDAP_P((
585         LDAPControl *ctrl ));
586
587 LDAP_F( void )
588 ldap_controls_free LDAP_P((
589         LDAPControl **ctrls ));
590
591 /*
592  * in dnssrv.c:
593  */
594 LDAP_F( int )
595 ldap_domain2dn LDAP_P((
596         LDAP_CONST char* domain,
597         char** dn ));
598
599 LDAP_F( int )
600 ldap_dn2domain LDAP_P((
601         LDAP_CONST char* dn,
602         char** domain ));
603
604 LDAP_F( int )
605 ldap_domain2hostlist LDAP_P((
606         LDAP_CONST char *domain,
607         char** hostlist ));
608
609 /*
610  * in extended.c:
611  */
612 LDAP_F( int )
613 ldap_extended_operation LDAP_P((
614         LDAP                    *ld,
615         LDAP_CONST char *reqoid,
616         struct berval   *reqdata,
617         LDAPControl             **serverctrls,
618         LDAPControl             **clientctrls,
619         int                             *msgidp ));
620
621 LDAP_F( int )
622 ldap_extended_operation_s LDAP_P((
623         LDAP                    *ld,
624         LDAP_CONST char *reqoid,
625         struct berval   *reqdata,
626         LDAPControl             **serverctrls,
627         LDAPControl             **clientctrls,
628         char                    **retoidp,
629         struct berval   **retdatap ));
630
631 LDAP_F( int )
632 ldap_parse_extended_result LDAP_P((
633         LDAP                    *ld,
634         LDAPMessage             *res,
635         char                    **retoidp,
636         struct berval   **retdatap,
637         int                             freeit ));
638
639 LDAP_F( int )
640 ldap_parse_extended_partial LDAP_P((
641         LDAP                    *ld,
642         LDAPMessage             *res,
643         char                    **retoidp,
644         struct berval   **retdatap,
645         LDAPControl             ***serverctrls,
646         int                             freeit ));
647
648 /*
649  * in abandon.c:
650  */
651 LDAP_F( int )
652 ldap_abandon_ext LDAP_P((
653         LDAP                    *ld,
654         int                             msgid,
655         LDAPControl             **serverctrls,
656         LDAPControl             **clientctrls ));
657
658 LDAP_F( int )
659 ldap_abandon LDAP_P((   /* deprecated */
660         LDAP *ld,
661         int msgid ));
662
663
664 /*
665  * in add.c:
666  */
667 LDAP_F( int )
668 ldap_add_ext LDAP_P((
669         LDAP                    *ld,
670         LDAP_CONST char *dn,
671         LDAPMod                 **attrs,
672         LDAPControl             **serverctrls,
673         LDAPControl             **clientctrls,
674         int                     *msgidp ));
675
676 LDAP_F( int )
677 ldap_add_ext_s LDAP_P((
678         LDAP                    *ld,
679         LDAP_CONST char *dn,
680         LDAPMod                 **attrs,
681         LDAPControl             **serverctrls,
682         LDAPControl             **clientctrls ));
683
684 LDAP_F( int )
685 ldap_add LDAP_P((       /* deprecated */
686         LDAP *ld,
687         LDAP_CONST char *dn,
688         LDAPMod **attrs ));
689
690 LDAP_F( int )
691 ldap_add_s LDAP_P((     /* deprecated */
692         LDAP *ld,
693         LDAP_CONST char *dn,
694         LDAPMod **attrs ));
695
696
697 /*
698  * in sasl.c:
699  */
700 LDAP_F( int )
701 ldap_sasl_bind LDAP_P((
702         LDAP                    *ld,
703         LDAP_CONST char *dn,
704         LDAP_CONST char *mechanism,
705         struct berval   *cred,
706         LDAPControl             **serverctrls,
707         LDAPControl             **clientctrls,
708         int                             *msgidp ));
709
710 /* Interaction flags (should be passed about in a control)
711  *  Automatic (default): use defaults, prompt otherwise
712  *  Interactive: prompt always
713  *  Quiet: never prompt
714  */
715 #define LDAP_SASL_AUTOMATIC             0U
716 #define LDAP_SASL_INTERACTIVE   1U
717 #define LDAP_SASL_QUIET                 2U
718
719 /*
720  * V3 SASL Interaction Function Callback Prototype
721  *      when using Cyrus SASL, interact is pointer to sasl_interact_t
722  *  should likely passed in a control (and provided controls)
723  */
724 typedef int (LDAP_SASL_INTERACT_PROC) LDAP_P((
725         LDAP *ld, unsigned flags, void* defaults, void *interact ));
726
727 LDAP_F( int )
728 ldap_sasl_interactive_bind_s LDAP_P((
729         LDAP *ld,
730         LDAP_CONST char *dn, /* usually NULL */
731         LDAP_CONST char *saslMechanism,
732         LDAPControl **serverControls,
733         LDAPControl **clientControls,
734
735         /* should be client controls */
736         unsigned flags,
737         LDAP_SASL_INTERACT_PROC *proc,
738         void *defaults ));
739
740 LDAP_F( int )
741 ldap_sasl_bind_s LDAP_P((
742         LDAP                    *ld,
743         LDAP_CONST char *dn,
744         LDAP_CONST char *mechanism,
745         struct berval   *cred,
746         LDAPControl             **serverctrls,
747         LDAPControl             **clientctrls,
748         struct berval   **servercredp ));
749
750 LDAP_F( int )
751 ldap_parse_sasl_bind_result LDAP_P((
752         LDAP                    *ld,
753         LDAPMessage             *res,
754         struct berval   **servercredp,
755         int                             freeit ));
756
757 /*
758  * in bind.c:
759  *      (deprecated)
760  */
761 LDAP_F( int )
762 ldap_bind LDAP_P((      /* deprecated */
763         LDAP *ld,
764         LDAP_CONST char *who,
765         LDAP_CONST char *passwd,
766         int authmethod ));
767
768 LDAP_F( int )
769 ldap_bind_s LDAP_P((    /* deprecated */
770         LDAP *ld,
771         LDAP_CONST char *who,
772         LDAP_CONST char *cred,
773         int authmethod ));
774
775 /*
776  * in sbind.c:
777  */
778 LDAP_F( int )
779 ldap_simple_bind LDAP_P((
780         LDAP *ld,
781         LDAP_CONST char *who,
782         LDAP_CONST char *passwd ));
783
784 LDAP_F( int )
785 ldap_simple_bind_s LDAP_P((
786         LDAP *ld,
787         LDAP_CONST char *who,
788         LDAP_CONST char *passwd ));
789
790
791 /*
792  * in kbind.c:
793  *      (deprecated)
794  */
795 LDAP_F( int )
796 ldap_kerberos_bind_s LDAP_P((   /* deprecated */
797         LDAP *ld,
798         LDAP_CONST char *who ));
799
800 LDAP_F( int )
801 ldap_kerberos_bind1 LDAP_P((    /* deprecated */
802         LDAP *ld,
803         LDAP_CONST char *who ));
804
805 LDAP_F( int )
806 ldap_kerberos_bind1_s LDAP_P((  /* deprecated */
807         LDAP *ld,
808         LDAP_CONST char *who ));
809
810 LDAP_F( int )
811 ldap_kerberos_bind2 LDAP_P((    /* deprecated */
812         LDAP *ld,
813         LDAP_CONST char *who ));
814
815 LDAP_F( int )
816 ldap_kerberos_bind2_s LDAP_P((  /* deprecated */
817         LDAP *ld,
818         LDAP_CONST char *who ));
819
820 /*
821  * in cache.c
822  * (deprecated)
823  */
824 LDAP_F( int )
825 ldap_enable_cache LDAP_P(( LDAP *ld, long timeout, ber_len_t maxmem ));
826
827 LDAP_F( void )
828 ldap_disable_cache LDAP_P(( LDAP *ld ));
829
830 LDAP_F( void )
831 ldap_set_cache_options LDAP_P(( LDAP *ld, unsigned long opts ));
832
833 LDAP_F( void )
834 ldap_destroy_cache LDAP_P(( LDAP *ld ));
835
836 LDAP_F( void )
837 ldap_flush_cache LDAP_P(( LDAP *ld ));
838
839 LDAP_F( void )
840 ldap_uncache_entry LDAP_P(( LDAP *ld, LDAP_CONST char *dn ));
841
842 LDAP_F( void )
843 ldap_uncache_request LDAP_P(( LDAP *ld, int msgid ));
844
845
846 /*
847  * in compare.c:
848  */
849 LDAP_F( int )
850 ldap_compare_ext LDAP_P((
851         LDAP                    *ld,
852         LDAP_CONST char *dn,
853         LDAP_CONST char *attr,
854         struct berval   *bvalue,
855         LDAPControl             **serverctrls,
856         LDAPControl             **clientctrls,
857         int                     *msgidp ));
858
859 LDAP_F( int )
860 ldap_compare_ext_s 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
868 LDAP_F( int )
869 ldap_compare LDAP_P((   /* deprecated */
870         LDAP *ld,
871         LDAP_CONST char *dn,
872         LDAP_CONST char *attr,
873         LDAP_CONST char *value ));
874
875 LDAP_F( int )
876 ldap_compare_s LDAP_P(( /* deprecated */
877         LDAP *ld,
878         LDAP_CONST char *dn,
879         LDAP_CONST char *attr,
880         LDAP_CONST char *value ));
881
882
883 /*
884  * in delete.c:
885  */
886 LDAP_F( int )
887 ldap_delete_ext LDAP_P((
888         LDAP                    *ld,
889         LDAP_CONST char *dn,
890         LDAPControl             **serverctrls,
891         LDAPControl             **clientctrls,
892         int                     *msgidp ));
893
894 LDAP_F( int )
895 ldap_delete_ext_s LDAP_P((
896         LDAP                    *ld,
897         LDAP_CONST char *dn,
898         LDAPControl             **serverctrls,
899         LDAPControl             **clientctrls ));
900
901 LDAP_F( int )
902 ldap_delete LDAP_P((    /* deprecated */
903         LDAP *ld,
904         LDAP_CONST char *dn ));
905
906 LDAP_F( int )
907 ldap_delete_s LDAP_P((  /* deprecated */
908         LDAP *ld,
909         LDAP_CONST char *dn ));
910
911
912 /*
913  * in error.c:
914  */
915 LDAP_F( int )
916 ldap_parse_result LDAP_P((
917         LDAP                    *ld,
918         LDAPMessage             *res,
919         int                             *errcodep,
920         char                    **matcheddnp,
921         char                    **errmsgp,
922         char                    ***referralsp,
923         LDAPControl             ***serverctrls,
924         int                             freeit ));
925
926 LDAP_F( char *)
927 ldap_err2string LDAP_P((
928         int err ));
929
930 LDAP_F( int )
931 ldap_result2error LDAP_P((      /* deprecated */
932         LDAP *ld,
933         LDAPMessage *r,
934         int freeit ));
935
936 LDAP_F( void )
937 ldap_perror LDAP_P((    /* deprecated */
938         LDAP *ld,
939         LDAP_CONST char *s ));
940
941
942 /*
943  * in modify.c:
944  */
945 LDAP_F( int )
946 ldap_modify_ext LDAP_P((
947         LDAP                    *ld,
948         LDAP_CONST char *dn,
949         LDAPMod                 **mods,
950         LDAPControl             **serverctrls,
951         LDAPControl             **clientctrls,
952         int                     *msgidp ));
953
954 LDAP_F( int )
955 ldap_modify_ext_s LDAP_P((
956         LDAP                    *ld,
957         LDAP_CONST char *dn,
958         LDAPMod                 **mods,
959         LDAPControl             **serverctrls,
960         LDAPControl             **clientctrls ));
961
962 LDAP_F( int )
963 ldap_modify LDAP_P((    /* deprecated */
964         LDAP *ld,
965         LDAP_CONST char *dn,
966         LDAPMod **mods ));
967
968 LDAP_F( int )
969 ldap_modify_s LDAP_P((  /* deprecated */
970         LDAP *ld,
971         LDAP_CONST char *dn,
972         LDAPMod **mods ));
973
974
975 /*
976  * in modrdn.c:
977  */
978 LDAP_F( int )
979 ldap_rename LDAP_P((
980         LDAP *ld,
981         LDAP_CONST char *dn,
982         LDAP_CONST char *newrdn,
983         LDAP_CONST char *newSuperior,
984         int deleteoldrdn,
985         LDAPControl **sctrls,
986         LDAPControl **cctrls,
987         int *msgidp ));
988
989 LDAP_F( int )
990 ldap_rename_s LDAP_P((
991         LDAP *ld,
992         LDAP_CONST char *dn,
993         LDAP_CONST char *newrdn,
994         LDAP_CONST char *newSuperior,
995         int deleteoldrdn,
996         LDAPControl **sctrls,
997         LDAPControl **cctrls ));
998
999 LDAP_F( int )
1000 ldap_rename2 LDAP_P((   /* deprecated */
1001         LDAP *ld,
1002         LDAP_CONST char *dn,
1003         LDAP_CONST char *newrdn,
1004         LDAP_CONST char *newSuperior,
1005         int deleteoldrdn ));
1006
1007 LDAP_F( int )
1008 ldap_rename2_s LDAP_P(( /* deprecated */
1009         LDAP *ld,
1010         LDAP_CONST char *dn,
1011         LDAP_CONST char *newrdn,
1012         LDAP_CONST char *newSuperior,
1013         int deleteoldrdn ));
1014
1015 LDAP_F( int )
1016 ldap_modrdn LDAP_P((    /* deprecated */
1017         LDAP *ld,
1018         LDAP_CONST char *dn,
1019         LDAP_CONST char *newrdn ));
1020
1021 LDAP_F( int )
1022 ldap_modrdn_s LDAP_P((  /* deprecated */
1023         LDAP *ld,
1024         LDAP_CONST char *dn,
1025         LDAP_CONST char *newrdn ));
1026
1027 LDAP_F( int )
1028 ldap_modrdn2 LDAP_P((   /* deprecated */
1029         LDAP *ld,
1030         LDAP_CONST char *dn,
1031         LDAP_CONST char *newrdn,
1032         int deleteoldrdn ));
1033
1034 LDAP_F( int )
1035 ldap_modrdn2_s LDAP_P(( /* deprecated */
1036         LDAP *ld,
1037         LDAP_CONST char *dn,
1038         LDAP_CONST char *newrdn,
1039         int deleteoldrdn));
1040
1041
1042 /*
1043  * in open.c:
1044  */
1045 LDAP_F( LDAP *)
1046 ldap_init LDAP_P((
1047         LDAP_CONST char *host,
1048         int port ));
1049
1050 LDAP_F( LDAP *)
1051 ldap_open LDAP_P((      /* deprecated */
1052         LDAP_CONST char *host,
1053         int port ));
1054
1055 LDAP_F( int )
1056 ldap_create LDAP_P(( 
1057         LDAP **ldp ));
1058
1059 LDAP_F( int )
1060 ldap_initialize LDAP_P((
1061         LDAP **ldp,
1062         LDAP_CONST char *url ));
1063
1064 LDAP_F( int )
1065 ldap_start_tls_s LDAP_P((
1066         LDAP *ld,
1067         LDAPControl **serverctrls,
1068         LDAPControl **clientctrls ));
1069
1070 /*
1071  * in messages.c:
1072  */
1073 LDAP_F( LDAPMessage *)
1074 ldap_first_message LDAP_P((
1075         LDAP *ld,
1076         LDAPMessage *chain ));
1077
1078 LDAP_F( LDAPMessage *)
1079 ldap_next_message LDAP_P((
1080         LDAP *ld,
1081         LDAPMessage *msg ));
1082
1083 LDAP_F( int )
1084 ldap_count_messages LDAP_P((
1085         LDAP *ld,
1086         LDAPMessage *chain ));
1087
1088
1089 /*
1090  * in references.c:
1091  */
1092 LDAP_F( LDAPMessage *)
1093 ldap_first_reference LDAP_P((
1094         LDAP *ld,
1095         LDAPMessage *chain ));
1096
1097 LDAP_F( LDAPMessage *)
1098 ldap_next_reference LDAP_P((
1099         LDAP *ld,
1100         LDAPMessage *ref ));
1101
1102 LDAP_F( int )
1103 ldap_count_references LDAP_P((
1104         LDAP *ld,
1105         LDAPMessage *chain ));
1106
1107 LDAP_F( int )
1108 ldap_parse_reference LDAP_P((
1109         LDAP                    *ld,
1110         LDAPMessage             *ref,
1111         char                    ***referralsp,
1112         LDAPControl             ***serverctrls,
1113         int                             freeit));
1114
1115
1116 /*
1117  * in getentry.c:
1118  */
1119 LDAP_F( LDAPMessage *)
1120 ldap_first_entry LDAP_P((
1121         LDAP *ld,
1122         LDAPMessage *chain ));
1123
1124 LDAP_F( LDAPMessage *)
1125 ldap_next_entry LDAP_P((
1126         LDAP *ld,
1127         LDAPMessage *entry ));
1128
1129 LDAP_F( int )
1130 ldap_count_entries LDAP_P((
1131         LDAP *ld,
1132         LDAPMessage *chain ));
1133
1134 LDAP_F( int )
1135 ldap_get_entry_controls LDAP_P((
1136         LDAP                    *ld,
1137         LDAPMessage             *entry,
1138         LDAPControl             ***serverctrls));
1139
1140
1141 /*
1142  * in addentry.c
1143  */
1144 LDAP_F( LDAPMessage *)
1145 ldap_delete_result_entry LDAP_P((
1146         LDAPMessage **list,
1147         LDAPMessage *e ));
1148
1149 LDAP_F( void )
1150 ldap_add_result_entry LDAP_P((
1151         LDAPMessage **list,
1152         LDAPMessage *e ));
1153
1154
1155 /*
1156  * in getdn.c
1157  */
1158 LDAP_F( char * )
1159 ldap_get_dn LDAP_P((
1160         LDAP *ld,
1161         LDAPMessage *entry ));
1162
1163 LDAP_F( char * )
1164 ldap_dn2ufn LDAP_P((
1165         LDAP_CONST char *dn ));
1166
1167 LDAP_F( char ** )
1168 ldap_explode_dn LDAP_P((
1169         LDAP_CONST char *dn,
1170         int notypes ));
1171
1172 LDAP_F( char ** )
1173 ldap_explode_rdn LDAP_P((
1174         LDAP_CONST char *rdn,
1175         int notypes ));
1176
1177 LDAP_F( char * )
1178 ldap_dn2dcedn LDAP_P(( LDAP_CONST char *dn ));  /* deprecated */
1179
1180 LDAP_F( char * )
1181 ldap_dcedn2dn LDAP_P(( LDAP_CONST char *dce )); /* deprecated */
1182
1183 /*
1184  * in getattr.c
1185  */
1186 LDAP_F( char *)
1187 ldap_first_attribute LDAP_P((                                                                    
1188         LDAP *ld,
1189         LDAPMessage *entry,
1190         BerElement **ber ));
1191
1192 LDAP_F( char *)
1193 ldap_next_attribute LDAP_P((
1194         LDAP *ld,
1195         LDAPMessage *entry,
1196         BerElement *ber ));
1197
1198
1199 /*
1200  * in getvalues.c
1201  */
1202 LDAP_F( char **)
1203 ldap_get_values LDAP_P((
1204         LDAP *ld,
1205         LDAPMessage *entry,
1206         LDAP_CONST char *target ));
1207
1208 LDAP_F( struct berval **)
1209 ldap_get_values_len LDAP_P((
1210         LDAP *ld,
1211         LDAPMessage *entry,
1212         LDAP_CONST char *target ));
1213
1214 LDAP_F( int )
1215 ldap_count_values LDAP_P((
1216         char **vals ));
1217
1218 LDAP_F( int )
1219 ldap_count_values_len LDAP_P((
1220         struct berval **vals ));
1221
1222 LDAP_F( void )
1223 ldap_value_free LDAP_P((
1224         char **vals ));
1225
1226 LDAP_F( void )
1227 ldap_value_free_len LDAP_P((
1228         struct berval **vals ));
1229
1230 /*
1231  * in result.c:
1232  */
1233 LDAP_F( int )
1234 ldap_result LDAP_P((
1235         LDAP *ld,
1236         int msgid,
1237         int all,
1238         struct timeval *timeout,
1239         LDAPMessage **result ));
1240
1241 LDAP_F( int )
1242 ldap_msgtype LDAP_P((
1243         LDAPMessage *lm ));
1244
1245 LDAP_F( int )
1246 ldap_msgid   LDAP_P((
1247         LDAPMessage *lm ));
1248
1249 LDAP_F( int )
1250 ldap_msgfree LDAP_P((
1251         LDAPMessage *lm ));
1252
1253 LDAP_F( int )
1254 ldap_msgdelete LDAP_P((
1255         LDAP *ld,
1256         int msgid ));
1257
1258
1259 /*
1260  * in search.c:
1261  */
1262 LDAP_F( int )
1263 ldap_search_ext LDAP_P((
1264         LDAP                    *ld,
1265         LDAP_CONST char *base,
1266         int                             scope,
1267         LDAP_CONST char *filter,
1268         char                    **attrs,
1269         int                             attrsonly,
1270         LDAPControl             **serverctrls,
1271         LDAPControl             **clientctrls,
1272         struct timeval  *timeout,
1273         int                             sizelimit,
1274         int                             *msgidp ));
1275
1276 LDAP_F( int )
1277 ldap_search_ext_s LDAP_P((
1278         LDAP                    *ld,
1279         LDAP_CONST char *base,
1280         int                             scope,
1281         LDAP_CONST char *filter,
1282         char                    **attrs,
1283         int                             attrsonly,
1284         LDAPControl             **serverctrls,
1285         LDAPControl             **clientctrls,
1286         struct timeval  *timeout,
1287         int                             sizelimit,
1288         LDAPMessage             **res ));
1289
1290 LDAP_F( int )
1291 ldap_search LDAP_P((    /* deprecated */
1292         LDAP *ld,
1293         LDAP_CONST char *base,
1294         int scope,
1295         LDAP_CONST char *filter,
1296         char **attrs,
1297         int attrsonly ));
1298
1299 LDAP_F( int )
1300 ldap_search_s LDAP_P((  /* deprecated */
1301         LDAP *ld,
1302         LDAP_CONST char *base,
1303         int scope,
1304         LDAP_CONST char *filter,
1305         char **attrs,
1306         int attrsonly,
1307         LDAPMessage **res ));
1308
1309 LDAP_F( int )
1310 ldap_search_st 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         struct timeval *timeout,
1318         LDAPMessage **res ));
1319
1320
1321 /*
1322  * in ufn.c                                                     
1323  *      (deprecated)
1324  */
1325 LDAP_F( int )
1326 ldap_ufn_search_c LDAP_P(( /* deprecated */
1327         LDAP *ld,
1328         LDAP_CONST char *ufn,
1329         char **attrs,
1330         int attrsonly,
1331         LDAPMessage **res,
1332         int (*cancelproc)( void *cl ),
1333         void *cancelparm ));
1334
1335 LDAP_F( int )
1336 ldap_ufn_search_ct LDAP_P(( /* deprecated */
1337         LDAP *ld,
1338         LDAP_CONST char *ufn,
1339         char **attrs,
1340         int attrsonly,
1341         LDAPMessage **res,
1342         int (*cancelproc)( void *cl ),
1343         void *cancelparm,
1344         char *tag1,
1345         char *tag2,
1346         char *tag3 ));
1347
1348 LDAP_F( int )
1349 ldap_ufn_search_s LDAP_P(( /* deprecated */
1350         LDAP *ld,
1351         LDAP_CONST char *ufn,
1352         char **attrs,
1353         int attrsonly,
1354         LDAPMessage **res ));
1355
1356 LDAP_F( LDAPFiltDesc *)
1357 ldap_ufn_setfilter LDAP_P(( /* deprecated */
1358         LDAP *ld,
1359         LDAP_CONST char *fname ));
1360
1361 LDAP_F( void )
1362 ldap_ufn_setprefix LDAP_P(( /* deprecated */
1363         LDAP *ld,
1364         LDAP_CONST char *prefix ));
1365
1366 LDAP_F( int )
1367 ldap_ufn_timeout LDAP_P(( /* deprecated */
1368         void *tvparam ));
1369
1370
1371 /*
1372  * in unbind.c
1373  */
1374 LDAP_F( int )
1375 ldap_unbind LDAP_P(( /* deprecated */
1376         LDAP *ld ));
1377
1378 LDAP_F( int )
1379 ldap_unbind_s LDAP_P(( /* deprecated */
1380         LDAP *ld ));
1381
1382 LDAP_F( int )
1383 ldap_unbind_ext LDAP_P((
1384         LDAP                    *ld,
1385         LDAPControl             **serverctrls,
1386         LDAPControl             **clientctrls));
1387
1388 LDAP_F( int )
1389 ldap_unbind_ext_s LDAP_P((
1390         LDAP                    *ld,
1391         LDAPControl             **serverctrls,
1392         LDAPControl             **clientctrls));
1393
1394 /*
1395  * in getfilter.c
1396  *      (deprecated)
1397  */
1398 LDAP_F( LDAPFiltDesc *)
1399 ldap_init_getfilter LDAP_P(( /* deprecated */
1400         LDAP_CONST char *fname ));
1401
1402 LDAP_F( LDAPFiltDesc *)
1403 ldap_init_getfilter_buf LDAP_P(( /* deprecated */
1404         /* LDAP_CONST */ char *buf,
1405         ber_len_t buflen ));
1406
1407 LDAP_F( LDAPFiltInfo *)
1408 ldap_getfirstfilter LDAP_P(( /* deprecated */
1409         LDAPFiltDesc *lfdp,
1410         /* LDAP_CONST */ char *tagpat,
1411         /* LDAP_CONST */ char *value ));
1412
1413 LDAP_F( LDAPFiltInfo *)
1414 ldap_getnextfilter LDAP_P(( /* deprecated */
1415         LDAPFiltDesc *lfdp ));
1416
1417 LDAP_F( void )
1418 ldap_setfilteraffixes LDAP_P(( /* deprecated */
1419         LDAPFiltDesc *lfdp,
1420         LDAP_CONST char *prefix,
1421         LDAP_CONST char *suffix ));
1422
1423 LDAP_F( void )
1424 ldap_build_filter LDAP_P(( /* deprecated */
1425         char *buf,
1426         ber_len_t buflen,
1427         LDAP_CONST char *pattern,
1428         LDAP_CONST char *prefix,
1429         LDAP_CONST char *suffix,
1430         LDAP_CONST char *attr,
1431         LDAP_CONST char *value,
1432         char **valwords ));
1433
1434
1435 /*
1436  * in free.c
1437  */
1438
1439 LDAP_F( void * )
1440 ldap_memalloc LDAP_P((
1441         ber_len_t s ));
1442
1443 LDAP_F( void * )
1444 ldap_memrealloc LDAP_P((
1445         void* p,
1446         ber_len_t s ));
1447
1448 LDAP_F( void * )
1449 ldap_memcalloc LDAP_P((
1450         ber_len_t n,
1451         ber_len_t s ));
1452
1453 LDAP_F( void )
1454 ldap_memfree LDAP_P((
1455         void* p ));
1456
1457 LDAP_F( void )
1458 ldap_memvfree LDAP_P((
1459         void** v ));
1460
1461 LDAP_F( char * )
1462 ldap_strdup LDAP_P((
1463         LDAP_CONST char * ));
1464
1465 LDAP_F( void )
1466 ldap_getfilter_free LDAP_P((
1467         LDAPFiltDesc *lfdp ));
1468
1469 LDAP_F( void )
1470 ldap_mods_free LDAP_P((
1471         LDAPMod **mods,
1472         int freemods ));
1473
1474
1475 /*
1476  * in friendly.c
1477  *      (deprecated)
1478  */
1479 LDAP_F( char * )
1480 ldap_friendly_name LDAP_P(( /* deprecated */
1481         LDAP_CONST char *filename,
1482         /* LDAP_CONST */ char *uname,
1483         LDAPFriendlyMap **map ));
1484
1485 LDAP_F( void )
1486 ldap_free_friendlymap LDAP_P(( /* deprecated */
1487         LDAPFriendlyMap **map ));
1488
1489
1490 /*
1491  * in sort.c
1492  */
1493 typedef int (LDAP_SORT_AD_CMP_PROC) LDAP_P((
1494         LDAP_CONST char *left,
1495         LDAP_CONST char *right ));
1496
1497 typedef int (LDAP_SORT_AV_CMP_PROC) LDAP_P((
1498         LDAP_CONST void *left,
1499         LDAP_CONST void *right ));
1500
1501 LDAP_F( int )
1502 ldap_sort_entries LDAP_P(( LDAP *ld,
1503         LDAPMessage **chain,
1504         LDAP_CONST char *attr,
1505         LDAP_SORT_AD_CMP_PROC *cmp ));
1506
1507 LDAP_F( int )   /* deprecated */
1508 ldap_sort_values LDAP_P((
1509         LDAP *ld,
1510         char **vals,
1511         LDAP_SORT_AV_CMP_PROC *cmp ));
1512
1513 LDAP_F( int ) /* deprecated */
1514 ldap_sort_strcasecmp LDAP_P((
1515         LDAP_CONST void *a,
1516         LDAP_CONST void *b ));
1517
1518
1519 /*
1520  * in url.c
1521  *
1522  * need _ext varients
1523  */
1524 LDAP_F( int )
1525 ldap_is_ldap_url LDAP_P((
1526         LDAP_CONST char *url ));
1527
1528 LDAP_F( int )
1529 ldap_is_ldaps_url LDAP_P((
1530         LDAP_CONST char *url ));
1531
1532 LDAP_F( int )
1533 ldap_is_ldapi_url LDAP_P((
1534         LDAP_CONST char *url ));
1535
1536 LDAP_F( int )
1537 ldap_url_parse LDAP_P((
1538         LDAP_CONST char *url,
1539         LDAPURLDesc **ludpp ));
1540
1541 LDAP_F( void )
1542 ldap_free_urldesc LDAP_P((
1543         LDAPURLDesc *ludp ));
1544
1545 LDAP_F( int )
1546 ldap_url_search LDAP_P((
1547         LDAP *ld,
1548         LDAP_CONST char *url,
1549         int attrsonly ));
1550
1551 LDAP_F( int )
1552 ldap_url_search_s LDAP_P((
1553         LDAP *ld,
1554         LDAP_CONST char *url,
1555         int attrsonly,
1556         LDAPMessage **res ));
1557
1558 LDAP_F( int )
1559 ldap_url_search_st LDAP_P((
1560         LDAP *ld,
1561         LDAP_CONST char *url,
1562         int attrsonly,
1563         struct timeval *timeout,
1564         LDAPMessage **res ));
1565
1566 /* 
1567  * in sortctrl.c  
1568  */
1569 /*
1570  * structure for a sort-key 
1571  */
1572 typedef struct ldapsortkey {
1573         char *  attributeType;
1574         char *  orderingRule;
1575         int     reverseOrder;
1576 } LDAPSortKey;
1577
1578 LDAP_F( int )
1579 ldap_create_sort_keylist LDAP_P((
1580         LDAPSortKey ***sortKeyList,
1581         char        *keyString ));
1582
1583 LDAP_F( void )
1584 ldap_free_sort_keylist LDAP_P((
1585         LDAPSortKey **sortkeylist ));
1586
1587 LDAP_F( int )
1588 ldap_create_sort_control LDAP_P((       
1589         LDAP *ld, 
1590         LDAPSortKey **keyList,
1591         int ctl_iscritical,
1592         LDAPControl **ctrlp ));
1593
1594 LDAP_F( int )
1595 ldap_parse_sort_control LDAP_P((
1596         LDAP           *ld, 
1597         LDAPControl    **ctrlp,  
1598         unsigned long  *result,
1599         char           **attribute ));
1600
1601
1602 /* 
1603  * in vlvctrl.c  
1604  */
1605
1606 /*
1607  * structure for virtul list.
1608  */
1609 typedef struct ldapvlvinfo {
1610         int             ldvlv_version;
1611     unsigned long   ldvlv_before_count;      
1612     unsigned long   ldvlv_after_count;                     
1613     unsigned long   ldvlv_offset;              
1614     unsigned long   ldvlv_count;
1615     struct berval  *ldvlv_attrvalue;
1616     struct berval  *ldvlv_context;
1617     void           *ldvlv_extradata;
1618 } LDAPVLVInfo;
1619
1620 LDAP_F( int ) 
1621 ldap_create_vlv_control LDAP_P((
1622         LDAP *ld, 
1623         LDAPVLVInfo *ldvlistp,
1624         LDAPControl **ctrlp ));
1625
1626 LDAP_F( int )
1627 ldap_parse_vlv_control LDAP_P(( 
1628         LDAP          *ld, 
1629         LDAPControl   **ctrls,
1630         unsigned long *target_posp, 
1631         unsigned long *list_countp, 
1632         struct berval **contextp,
1633         int           *errcodep ));
1634
1635
1636 LDAP_END_DECL
1637 #endif /* _LDAP_H */