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