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