]> git.sur5r.net Git - openldap/blob - include/ldap.h
Add prototypes and pblock paramaters for more compat APIs
[openldap] / include / ldap.h
1 /* $OpenLDAP$ */
2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
3  * 
4  * Copyright 1998-2005 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 /*
46  * We use 3000+n here because it is above 1823 (for RFC 1823),
47  * above 2000+rev of IETF LDAPEXT draft (now quite dated),
48  * yet below allocations for new RFCs (just in case there is
49  * someday an RFC produced).
50  */
51 #define LDAP_API_VERSION        3001
52 #define LDAP_VENDOR_NAME        "OpenLDAP"
53
54 /* OpenLDAP API Features */
55 #define LDAP_API_FEATURE_X_OPENLDAP LDAP_VENDOR_VERSION
56
57 #if defined( LDAP_API_FEATURE_X_OPENLDAP_REENTRANT ) || \
58         ( defined( LDAP_THREAD_SAFE ) && \
59                 defined( LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE ) )
60         /* -lldap may or may not be thread safe */
61         /* -lldap_r, if available, is always thread safe */
62 #       define  LDAP_API_FEATURE_THREAD_SAFE 1
63 #endif
64 #if defined( LDAP_THREAD_SAFE ) && \
65         defined( LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE )
66 /* #define LDAP_API_FEATURE_SESSION_SAFE        1       */
67 /* #define LDAP_API_OPERATION_SESSION_SAFE      1       */
68 #endif
69
70
71 #define LDAP_PORT               389             /* ldap:///             default LDAP port */
72 #define LDAPS_PORT              636             /* ldaps:///    default LDAP over TLS port */
73
74 #define LDAP_ROOT_DSE                           ""
75 #define LDAP_NO_ATTRS                           "1.1"
76 #define LDAP_ALL_USER_ATTRIBUTES        "*"
77 #define LDAP_ALL_OPERATIONAL_ATTRIBUTES "+" /* RFC 3673 */
78
79 /* RFC 2251:  maxInt INTEGER ::= 2147483647 -- (2^^31 - 1) -- */
80 #define LDAP_MAXINT (2147483647)
81
82 /*
83  * LDAP_OPTions
84  *      0x0000 - 0x0fff reserved for api options
85  *      0x1000 - 0x3fff reserved for api extended options
86  *      0x4000 - 0x7fff reserved for private and experimental options
87  */
88
89 #define LDAP_OPT_API_INFO                       0x0000
90 #define LDAP_OPT_DESC                           0x0001 /* historic */
91 #define LDAP_OPT_DEREF                          0x0002
92 #define LDAP_OPT_SIZELIMIT                      0x0003
93 #define LDAP_OPT_TIMELIMIT                      0x0004
94 /* 0x05 - 0x07 not defined */
95 #define LDAP_OPT_REFERRALS                      0x0008
96 #define LDAP_OPT_RESTART                        0x0009
97 /* 0x0a - 0x10 not defined */
98 #define LDAP_OPT_PROTOCOL_VERSION       0x0011
99 #define LDAP_OPT_SERVER_CONTROLS        0x0012
100 #define LDAP_OPT_CLIENT_CONTROLS        0x0013
101 /* 0x14 not defined */
102 #define LDAP_OPT_API_FEATURE_INFO       0x0015
103 /* 0x16 - 0x2f not defined */
104 #define LDAP_OPT_HOST_NAME                      0x0030
105 #define LDAP_OPT_RESULT_CODE            0x0031
106 #define LDAP_OPT_ERROR_NUMBER           LDAP_OPT_RESULT_CODE
107 #define LDAP_OPT_ERROR_STRING           0x0032
108 #define LDAP_OPT_MATCHED_DN                     0x0033
109 /* 0x0034 - 0x3fff not defined */
110
111 /* API Extensions */
112 #define LDAP_OPT_API_EXTENSION_BASE 0x4000  /* API extensions */
113
114 /* private and experimental options */
115 /* OpenLDAP specific options */
116 #define LDAP_OPT_DEBUG_LEVEL            0x5001  /* debug level */
117 #define LDAP_OPT_TIMEOUT                        0x5002  /* default timeout */
118 #define LDAP_OPT_REFHOPLIMIT            0x5003  /* ref hop limit */
119 #define LDAP_OPT_NETWORK_TIMEOUT        0x5005  /* socket level timeout */
120 #define LDAP_OPT_URI                            0x5006
121 #define LDAP_OPT_REFERRAL_URLS      0x5007  /* Referral URLs */
122 #define LDAP_OPT_SOCKBUF            0x5008  /* sockbuf */
123
124 /* OpenLDAP TLS options */
125 #define LDAP_OPT_X_TLS                          0x6000
126 #define LDAP_OPT_X_TLS_CTX                      0x6001  /* SSL CTX */
127 #define LDAP_OPT_X_TLS_CACERTFILE       0x6002
128 #define LDAP_OPT_X_TLS_CACERTDIR        0x6003
129 #define LDAP_OPT_X_TLS_CERTFILE         0x6004
130 #define LDAP_OPT_X_TLS_KEYFILE          0x6005
131 #define LDAP_OPT_X_TLS_REQUIRE_CERT     0x6006
132 /* #define LDAP_OPT_X_TLS_PROTOCOL              0x6007 */
133 #define LDAP_OPT_X_TLS_CIPHER_SUITE     0x6008
134 #define LDAP_OPT_X_TLS_RANDOM_FILE      0x6009
135 #define LDAP_OPT_X_TLS_SSL_CTX          0x600a
136 #define LDAP_OPT_X_TLS_CRLCHECK         0x600b
137 #define LDAP_OPT_X_TLS_CONNECT_CB       0x600c
138 #define LDAP_OPT_X_TLS_CONNECT_ARG      0x600d
139
140 #define LDAP_OPT_X_TLS_NEVER    0
141 #define LDAP_OPT_X_TLS_HARD             1
142 #define LDAP_OPT_X_TLS_DEMAND   2
143 #define LDAP_OPT_X_TLS_ALLOW    3
144 #define LDAP_OPT_X_TLS_TRY              4
145
146 #define LDAP_OPT_X_TLS_CRL_NONE 0
147 #define LDAP_OPT_X_TLS_CRL_PEER 1
148 #define LDAP_OPT_X_TLS_CRL_ALL  2
149
150 /* OpenLDAP SASL options */
151 #define LDAP_OPT_X_SASL_MECH                    0x6100
152 #define LDAP_OPT_X_SASL_REALM                   0x6101
153 #define LDAP_OPT_X_SASL_AUTHCID                 0x6102
154 #define LDAP_OPT_X_SASL_AUTHZID                 0x6103
155 #define LDAP_OPT_X_SASL_SSF                             0x6104 /* read-only */
156 #define LDAP_OPT_X_SASL_SSF_EXTERNAL    0x6105 /* write-only */
157 #define LDAP_OPT_X_SASL_SECPROPS                0x6106 /* write-only */
158 #define LDAP_OPT_X_SASL_SSF_MIN                 0x6107
159 #define LDAP_OPT_X_SASL_SSF_MAX                 0x6108
160 #define LDAP_OPT_X_SASL_MAXBUFSIZE              0x6109
161
162 /* Private API Extensions -- reserved for application use */
163 #define LDAP_OPT_PRIVATE_EXTENSION_BASE 0x7000  /* Private API inclusive */
164
165 /*
166  * ldap_get_option() and ldap_set_option() return values.
167  * As later versions may return other values indicating
168  * failure, current applications should only compare returned
169  * value against LDAP_OPT_SUCCESS.
170  */
171 #define LDAP_OPT_SUCCESS        0
172 #define LDAP_OPT_ERROR          (-1)
173
174 /* option on/off values */
175 #define LDAP_OPT_ON             ((void *) &ber_pvt_opt_on)
176 #define LDAP_OPT_OFF    ((void *) 0)
177
178 typedef struct ldapapiinfo {
179         int             ldapai_info_version;            /* version of LDAPAPIInfo */
180 #define LDAP_API_INFO_VERSION   (1)
181         int             ldapai_api_version;                     /* revision of API supported */
182         int             ldapai_protocol_version;        /* highest LDAP version supported */
183         char    **ldapai_extensions;            /* names of API extensions */
184         char    *ldapai_vendor_name;            /* name of supplier */
185         int             ldapai_vendor_version;          /* supplier-specific version * 100 */
186 } LDAPAPIInfo;
187
188 typedef struct ldap_apifeature_info {
189         int             ldapaif_info_version;           /* version of LDAPAPIFeatureInfo */
190 #define LDAP_FEATURE_INFO_VERSION (1)   /* apifeature_info struct version */
191         char*   ldapaif_name;                           /* LDAP_API_FEATURE_* (less prefix) */
192         int             ldapaif_version;                        /* value of LDAP_API_FEATURE_... */
193 } LDAPAPIFeatureInfo;
194
195 /*
196  * LDAP Control structure
197  */
198 typedef struct ldapcontrol {
199         char *                  ldctl_oid;                      /* numericoid of control */
200         struct berval   ldctl_value;            /* encoded value of control */
201         char                    ldctl_iscritical;       /* criticality */
202 } LDAPControl;
203
204 /* LDAP Controls */
205 /*      standard track controls */
206 #define LDAP_CONTROL_MANAGEDSAIT                "2.16.840.1.113730.3.4.2" /* RFC 3296 */
207 #define LDAP_CONTROL_SUBENTRIES                 "1.3.6.1.4.1.4203.1.10.1" /* RFC 3672 */
208 #define LDAP_CONTROL_PAGEDRESULTS               "1.2.840.113556.1.4.319"  /* RFC 2696 */
209 #define LDAP_CONTROL_VALUESRETURNFILTER "1.2.826.0.1.334810.2.3"  /* RFC 3876 */
210
211 /*  standard track - not implemented in slapd(8) */
212 #define LDAP_CONTROL_SORTREQUEST    "1.2.840.113556.1.4.473" /* RFC 2891 */
213 #define LDAP_CONTROL_SORTRESPONSE       "1.2.840.113556.1.4.474" /* RFC 2891 */
214
215 /* but not yet formalized controls */
216 #define LDAP_CONTROL_PROXY_AUTHZ                "2.16.840.1.113730.3.4.18"
217
218 /* various works in progress */
219 #define LDAP_CONTROL_ASSERT                             "1.3.6.1.4.1.4203.666.5.9"
220 #define LDAP_CONTROL_NOOP                               "1.3.6.1.4.1.4203.666.5.2"
221 #define LDAP_CONTROL_PRE_READ                   "1.3.6.1.4.1.4203.666.5.10.1"
222 #define LDAP_CONTROL_POST_READ                  "1.3.6.1.4.1.4203.666.5.10.2"
223 #define LDAP_CONTROL_NO_SUBORDINATES    "1.3.6.1.4.1.4203.666.5.11"
224 #define LDAP_CONTROL_MANAGEDIT                  "1.3.6.1.4.1.4203.666.5.12"
225 #define LDAP_CONTROL_SLURP                              "1.3.6.1.4.1.4203.666.5.13"
226
227 /* LDAP Duplicated Entry Control Extension *//* not implemented in slapd(8) */
228 #define LDAP_CONTROL_DUPENT_REQUEST             "2.16.840.1.113719.1.27.101.1"
229 #define LDAP_CONTROL_DUPENT_RESPONSE    "2.16.840.1.113719.1.27.101.2"
230 #define LDAP_CONTROL_DUPENT_ENTRY               "2.16.840.1.113719.1.27.101.3"
231 #define LDAP_CONTROL_DUPENT     LDAP_CONTROL_DUPENT_REQUEST
232
233 /* LDAP Persistent Search Control *//* not implemented in slapd(8) */
234 /* draft-ietf-ldapext-psearch-03.txt (expired) */
235 #define LDAP_CONTROL_PERSIST_REQUEST                            "2.16.840.1.113730.3.4.3"
236 #define LDAP_CONTROL_PERSIST_ENTRY_CHANGE_NOTICE        "2.16.840.1.113730.3.4.7"
237 #define LDAP_CONTROL_PERSSIT_ENTRY_CHANGE_ADD           0x1
238 #define LDAP_CONTROL_PERSSIT_ENTRY_CHANGE_DELETE        0x2
239 #define LDAP_CONTROL_PERSSIT_ENTRY_CHANGE_MODIFY        0x4
240 #define LDAP_CONTROL_PERSSIT_ENTRY_CHANGE_RENAME        0x8
241
242 /* LDAP VLV *//* not implemented in slapd(8) */
243 #define LDAP_CONTROL_VLVREQUEST         "2.16.840.1.113730.3.4.9"
244 #define LDAP_CONTROL_VLVRESPONSE    "2.16.840.1.113730.3.4.10"
245
246 /* Password policy Controls *//* work in progress */
247 /* ITS#3458: released, but not to latest draft; disabled by default */
248 #define LDAP_CONTROL_PASSWORDPOLICYREQUEST      "1.3.6.1.4.1.42.2.27.8.5.1"
249 #define LDAP_CONTROL_PASSWORDPOLICYRESPONSE     "1.3.6.1.4.1.42.2.27.8.5.1"
250
251 /* LDAP Sync -- draft-zeilenga-ldup-sync *//* submitted for publication */
252 #define LDAP_SYNC_OID                   "1.3.6.1.4.1.4203.1.9.1"
253 #define LDAP_CONTROL_SYNC               LDAP_SYNC_OID ".1"
254 #define LDAP_CONTROL_SYNC_STATE LDAP_SYNC_OID ".2"
255 #define LDAP_CONTROL_SYNC_DONE  LDAP_SYNC_OID ".3"
256 #define LDAP_SYNC_INFO                  LDAP_SYNC_OID ".4"
257
258 #define LDAP_SYNC_NONE                                  0x00
259 #define LDAP_SYNC_REFRESH_ONLY                  0x01
260 #define LDAP_SYNC_RESERVED                              0x02
261 #define LDAP_SYNC_REFRESH_AND_PERSIST   0x03
262
263 #define LDAP_SYNC_REFRESH_PRESENTS              0
264 #define LDAP_SYNC_REFRESH_DELETES               1
265
266 #define LDAP_TAG_SYNC_NEW_COOKIE                ((ber_tag_t) 0x80U)
267 #define LDAP_TAG_SYNC_REFRESH_DELETE    ((ber_tag_t) 0xa1U)
268 #define LDAP_TAG_SYNC_REFRESH_PRESENT   ((ber_tag_t) 0xa2U)
269 #define LDAP_TAG_SYNC_ID_SET                    ((ber_tag_t) 0xa3U)
270
271 #define LDAP_TAG_SYNC_COOKIE                    ((ber_tag_t) 0x04U)
272 #define LDAP_TAG_REFRESHDELETES                 ((ber_tag_t) 0x01U)
273 #define LDAP_TAG_REFRESHDONE                    ((ber_tag_t) 0x01U)
274 #define LDAP_TAG_RELOAD_HINT                    ((ber_tag_t) 0x01U)
275
276 #define LDAP_SYNC_PRESENT                               0
277 #define LDAP_SYNC_ADD                                   1
278 #define LDAP_SYNC_MODIFY                                2
279 #define LDAP_SYNC_DELETE                                3
280
281 /* LDAP Chaining Behavior Control *//* work in progress */
282 /* <draft-sermersheim-ldap-chaining>;
283  * see also LDAP_NO_REFERRALS_FOUND, LDAP_CANNOT_CHAIN */
284 #ifdef LDAP_DEVEL
285 #define LDAP_CONTROL_X_CHAINING_BEHAVIOR        "1.3.6.1.4.1.4203.666.11.3"
286
287 #define LDAP_CHAINING_PREFERRED                         0
288 #define LDAP_CHAINING_REQUIRED                          1
289 #define LDAP_REFERRALS_PREFERRED                        2
290 #define LDAP_REFERRALS_REQUIRED                         3
291 #endif
292
293 /* MS ActiveDirectory controls (for compatibility) */
294 #define LDAP_CONTROL_X_DOMAIN_SCOPE             "1.2.840.113556.1.4.1339"
295 #define LDAP_CONTROL_X_PERMISSIVE_MODIFY        "1.2.840.113556.1.4.1413"
296 #define LDAP_CONTROL_X_INCREMENTAL_VALUES       "1.2.840.113556.1.4.802"
297 #define LDAP_CONTROL_X_TREE_DELETE              "1.2.840.113556.1.4.805"
298 #define LDAP_CONTROL_X_SEARCH_OPTIONS           "1.2.840.113556.1.4.1340"
299 #define LDAP_SEARCH_FLAG_DOMAIN_SCOPE           1 /* do not generate referrals */
300 #define LDAP_SEARCH_FLAG_PHANTOM_ROOT           2 /* search all NCs subordinate to base */
301
302 /* LDAP Unsolicited Notifications */
303 #define LDAP_NOTICE_OF_DISCONNECTION    "1.3.6.1.4.1.1466.20036" /* RFC 2251 */
304 #define LDAP_NOTICE_DISCONNECT LDAP_NOTICE_OF_DISCONNECTION
305
306 /* LDAP Extended Operations */
307 #define LDAP_EXOP_START_TLS             "1.3.6.1.4.1.1466.20037"        /* RFC 2830 */
308
309 #define LDAP_EXOP_MODIFY_PASSWD "1.3.6.1.4.1.4203.1.11.1"       /* RFC 3062 */
310 #define LDAP_TAG_EXOP_MODIFY_PASSWD_ID  ((ber_tag_t) 0x80U)
311 #define LDAP_TAG_EXOP_MODIFY_PASSWD_OLD ((ber_tag_t) 0x81U)
312 #define LDAP_TAG_EXOP_MODIFY_PASSWD_NEW ((ber_tag_t) 0x82U)
313 #define LDAP_TAG_EXOP_MODIFY_PASSWD_GEN ((ber_tag_t) 0x80U)
314
315 #define LDAP_EXOP_CANCEL                "1.3.6.1.1.8"                           /* RFC 3909 */
316 #define LDAP_EXOP_X_CANCEL              LDAP_EXOP_CANCEL
317
318 /* various works in progress */
319
320 #define LDAP_EXOP_WHO_AM_I              "1.3.6.1.4.1.4203.1.11.3"
321 #define LDAP_EXOP_X_WHO_AM_I    LDAP_EXOP_WHO_AM_I
322
323 #define LDAP_EXOP_X_TURN                "1.3.6.1.4.1.4203.666.6.4"
324
325 /* LDAP Grouping of Related Operations *//* a work in progress */
326 #ifdef LDAP_DEVEL
327 #define LDAP_X_GROUPING_BASE            "1.3.6.1.4.1.4203.666.10.3"
328 #define LDAP_EXOP_GROUPING_CREATE       LDAP_X_GROUPING_BASE ".1"
329 #define LDAP_EXOP_GROUPING_END          LDAP_X_GROUPING_BASE ".2"
330 #define LDAP_NOTICE_GROUPING_END        LDAP_X_GROUPING_BASE ".3"
331 #define LDAP_EXOP_GROUPING_ACTION       LDAP_X_GROUPING_BASE ".4"
332 #define LDAP_NOTICE_GROUPING_INFO       LDAP_X_GROUPING_BASE ".5"
333 #define LDAP_CONTROL_GROUPING           LDAP_X_GROUPING_BASE ".6"
334 #endif
335
336 /* LDAP Grouping Types *//* a work in progress */
337 #ifdef LDAP_DEVEL
338 #define LDAP_GROUP_TRANSACTION           "1.3.6.1.4.1.4203.666.10.4"
339 #endif
340
341 /* LDAP Features */
342 #define LDAP_FEATURE_ALL_OP_ATTRS       "1.3.6.1.4.1.4203.1.5.1"        /* RFC 3673 */
343 #define LDAP_FEATURE_OBJECTCLASS_ATTRS \
344         "1.3.6.1.4.1.4203.1.5.2" /*  @objectClass - new number to be assigned */
345 #define LDAP_FEATURE_ABSOLUTE_FILTERS "1.3.6.1.4.1.4203.1.5.3"  /* (&) (|) */
346 #define LDAP_FEATURE_LANGUAGE_TAG_OPTIONS "1.3.6.1.4.1.4203.1.5.4"
347 #define LDAP_FEATURE_LANGUAGE_RANGE_OPTIONS "1.3.6.1.4.1.4203.1.5.5"
348
349 #ifdef LDAP_DEVEL
350 /* LDAP Experimental (works in progress) Features */
351 #define LDAP_FEATURE_MODIFY_INCREMENT "1.3.6.1.4.1.4203.666.8.2"
352 #define LDAP_FEATURE_SUBORDINATE_SCOPE \
353         "1.3.6.1.4.1.4203.666.8.1" /* "children" */
354 #define LDAP_FEATURE_CHILDREN_SCOPE LDAP_FEATURE_SUBORDINATE_SCOPE
355 #endif
356
357 /*
358  * specific LDAP instantiations of BER types we know about
359  */
360
361 /* Overview of LBER tag construction
362  *
363  *      Bits
364  *      ______
365  *      8 7 | CLASS
366  *      0 0 = UNIVERSAL
367  *      0 1 = APPLICATION
368  *      1 0 = CONTEXT-SPECIFIC
369  *      1 1 = PRIVATE
370  *              _____
371  *              | 6 | DATA-TYPE
372  *                0 = PRIMITIVE
373  *                1 = CONSTRUCTED
374  *                      ___________
375  *                      | 5 ... 1 | TAG-NUMBER
376  */
377
378 /* general stuff */
379 #define LDAP_TAG_MESSAGE        ((ber_tag_t) 0x30U)     /* constructed + 16 */
380 #define LDAP_TAG_MSGID          ((ber_tag_t) 0x02U)     /* integer */
381
382 #define LDAP_TAG_LDAPDN         ((ber_tag_t) 0x04U)     /* octet string */
383 #define LDAP_TAG_LDAPCRED       ((ber_tag_t) 0x04U)     /* octet string */
384
385 #define LDAP_TAG_CONTROLS       ((ber_tag_t) 0xa0U)     /* context specific + constructed + 0 */
386 #define LDAP_TAG_REFERRAL       ((ber_tag_t) 0xa3U)     /* context specific + constructed + 3 */
387
388 #define LDAP_TAG_NEWSUPERIOR    ((ber_tag_t) 0x80U)     /* context-specific + primitive + 0 */
389
390 #define LDAP_TAG_EXOP_REQ_OID   ((ber_tag_t) 0x80U)     /* context specific + primitive */
391 #define LDAP_TAG_EXOP_REQ_VALUE ((ber_tag_t) 0x81U)     /* context specific + primitive */
392 #define LDAP_TAG_EXOP_RES_OID   ((ber_tag_t) 0x8aU)     /* context specific + primitive */
393 #define LDAP_TAG_EXOP_RES_VALUE ((ber_tag_t) 0x8bU)     /* context specific + primitive */
394
395 #define LDAP_TAG_IM_RES_OID   ((ber_tag_t) 0x80U)       /* context specific + primitive */
396 #define LDAP_TAG_IM_RES_VALUE ((ber_tag_t) 0x81U)       /* context specific + primitive */
397
398 #define LDAP_TAG_SASL_RES_CREDS ((ber_tag_t) 0x87U)     /* context specific + primitive */
399
400 /* LDAP Request Messages */
401 #define LDAP_REQ_BIND           ((ber_tag_t) 0x60U)     /* application + constructed */
402 #define LDAP_REQ_UNBIND         ((ber_tag_t) 0x42U)     /* application + primitive   */
403 #define LDAP_REQ_SEARCH         ((ber_tag_t) 0x63U)     /* application + constructed */
404 #define LDAP_REQ_MODIFY         ((ber_tag_t) 0x66U)     /* application + constructed */
405 #define LDAP_REQ_ADD            ((ber_tag_t) 0x68U)     /* application + constructed */
406 #define LDAP_REQ_DELETE         ((ber_tag_t) 0x4aU)     /* application + primitive   */
407 #define LDAP_REQ_MODDN          ((ber_tag_t) 0x6cU)     /* application + constructed */
408 #define LDAP_REQ_MODRDN         LDAP_REQ_MODDN
409 #define LDAP_REQ_RENAME         LDAP_REQ_MODDN
410 #define LDAP_REQ_COMPARE        ((ber_tag_t) 0x6eU)     /* application + constructed */
411 #define LDAP_REQ_ABANDON        ((ber_tag_t) 0x50U)     /* application + primitive   */
412 #define LDAP_REQ_EXTENDED       ((ber_tag_t) 0x77U)     /* application + constructed */
413
414 /* LDAP Response Messages */
415 #define LDAP_RES_BIND           ((ber_tag_t) 0x61U)     /* application + constructed */
416 #define LDAP_RES_SEARCH_ENTRY   ((ber_tag_t) 0x64U)     /* application + constructed */
417 #define LDAP_RES_SEARCH_REFERENCE       ((ber_tag_t) 0x73U)     /* V3: application + constructed */
418 #define LDAP_RES_SEARCH_RESULT  ((ber_tag_t) 0x65U)     /* application + constructed */
419 #define LDAP_RES_MODIFY         ((ber_tag_t) 0x67U)     /* application + constructed */
420 #define LDAP_RES_ADD            ((ber_tag_t) 0x69U)     /* application + constructed */
421 #define LDAP_RES_DELETE         ((ber_tag_t) 0x6bU)     /* application + constructed */
422 #define LDAP_RES_MODDN          ((ber_tag_t) 0x6dU)     /* application + constructed */
423 #define LDAP_RES_MODRDN         LDAP_RES_MODDN  /* application + constructed */
424 #define LDAP_RES_RENAME         LDAP_RES_MODDN  /* application + constructed */
425 #define LDAP_RES_COMPARE        ((ber_tag_t) 0x6fU)     /* application + constructed */
426 #define LDAP_RES_EXTENDED       ((ber_tag_t) 0x78U)     /* V3: application + constructed */
427 #define LDAP_RES_INTERMEDIATE   ((ber_tag_t) 0x79U) /* V3+: application + constructed */
428
429 #define LDAP_RES_ANY                    (-1)
430 #define LDAP_RES_UNSOLICITED    (0)
431
432
433 /* sasl methods */
434 #define LDAP_SASL_SIMPLE        ((char*)0)
435 #define LDAP_SASL_NULL          ("")
436
437
438 /* authentication methods available */
439 #define LDAP_AUTH_NONE   ((ber_tag_t) 0x00U) /* no authentication */
440 #define LDAP_AUTH_SIMPLE ((ber_tag_t) 0x80U) /* context specific + primitive */
441 #define LDAP_AUTH_SASL   ((ber_tag_t) 0xa3U) /* context specific + constructed */
442 #define LDAP_AUTH_KRBV4  ((ber_tag_t) 0xffU) /* means do both of the following */
443 #define LDAP_AUTH_KRBV41 ((ber_tag_t) 0x81U) /* context specific + primitive */
444 #define LDAP_AUTH_KRBV42 ((ber_tag_t) 0x82U) /* context specific + primitive */
445
446
447 /* filter types */
448 #define LDAP_FILTER_AND ((ber_tag_t) 0xa0U)     /* context specific + constructed */
449 #define LDAP_FILTER_OR  ((ber_tag_t) 0xa1U)     /* context specific + constructed */
450 #define LDAP_FILTER_NOT ((ber_tag_t) 0xa2U)     /* context specific + constructed */
451 #define LDAP_FILTER_EQUALITY ((ber_tag_t) 0xa3U) /* context specific + constructed */
452 #define LDAP_FILTER_SUBSTRINGS ((ber_tag_t) 0xa4U) /* context specific + constructed */
453 #define LDAP_FILTER_GE ((ber_tag_t) 0xa5U) /* context specific + constructed */
454 #define LDAP_FILTER_LE ((ber_tag_t) 0xa6U) /* context specific + constructed */
455 #define LDAP_FILTER_PRESENT ((ber_tag_t) 0x87U) /* context specific + primitive   */
456 #define LDAP_FILTER_APPROX ((ber_tag_t) 0xa8U)  /* context specific + constructed */
457 #define LDAP_FILTER_EXT ((ber_tag_t) 0xa9U)     /* context specific + constructed */
458
459 /* extended filter component types */
460 #define LDAP_FILTER_EXT_OID             ((ber_tag_t) 0x81U)     /* context specific */
461 #define LDAP_FILTER_EXT_TYPE    ((ber_tag_t) 0x82U)     /* context specific */
462 #define LDAP_FILTER_EXT_VALUE   ((ber_tag_t) 0x83U)     /* context specific */
463 #define LDAP_FILTER_EXT_DNATTRS ((ber_tag_t) 0x84U)     /* context specific */
464
465 /* substring filter component types */
466 #define LDAP_SUBSTRING_INITIAL  ((ber_tag_t) 0x80U)     /* context specific */
467 #define LDAP_SUBSTRING_ANY              ((ber_tag_t) 0x81U)     /* context specific */
468 #define LDAP_SUBSTRING_FINAL    ((ber_tag_t) 0x82U)     /* context specific */
469
470 /* search scopes */
471 #define LDAP_SCOPE_DEFAULT              ((ber_int_t) -1)         /* OpenLDAP extension */
472 #define LDAP_SCOPE_BASE                 ((ber_int_t) 0x0000)
473 #define LDAP_SCOPE_BASEOBJECT   LDAP_SCOPE_BASE
474 #define LDAP_SCOPE_ONELEVEL             ((ber_int_t) 0x0001)
475 #define LDAP_SCOPE_ONE                  LDAP_SCOPE_ONELEVEL
476 #define LDAP_SCOPE_SUBTREE              ((ber_int_t) 0x0002)
477 #define LDAP_SCOPE_SUB                  LDAP_SCOPE_SUBTREE
478 #define LDAP_SCOPE_SUBORDINATE  ((ber_int_t) 0x0003) /* OpenLDAP extension */
479 #define LDAP_SCOPE_CHILDREN             LDAP_SCOPE_SUBORDINATE
480
481 /* substring filter component types */
482 #define LDAP_SUBSTRING_INITIAL  ((ber_tag_t) 0x80U)     /* context specific */
483 #define LDAP_SUBSTRING_ANY              ((ber_tag_t) 0x81U)     /* context specific */
484 #define LDAP_SUBSTRING_FINAL    ((ber_tag_t) 0x82U)     /* context specific */
485
486 /*
487  * LDAP Result Codes
488  */
489 #define LDAP_SUCCESS                            0x00
490
491 #define LDAP_RANGE(n,x,y)       (((x) <= (n)) && ((n) <= (y)))
492
493 #define LDAP_OPERATIONS_ERROR           0x01
494 #define LDAP_PROTOCOL_ERROR                     0x02
495 #define LDAP_TIMELIMIT_EXCEEDED         0x03
496 #define LDAP_SIZELIMIT_EXCEEDED         0x04
497 #define LDAP_COMPARE_FALSE                      0x05
498 #define LDAP_COMPARE_TRUE                       0x06
499 #define LDAP_AUTH_METHOD_NOT_SUPPORTED  0x07
500 #define LDAP_STRONG_AUTH_NOT_SUPPORTED  LDAP_AUTH_METHOD_NOT_SUPPORTED
501 #define LDAP_STRONG_AUTH_REQUIRED       0x08
502 #define LDAP_STRONGER_AUTH_REQUIRED     LDAP_STRONG_AUTH_REQUIRED
503 #define LDAP_PARTIAL_RESULTS            0x09    /* LDAPv2+ (not LDAPv3) */
504
505 #define LDAP_REFERRAL                           0x0a /* LDAPv3 */
506 #define LDAP_ADMINLIMIT_EXCEEDED        0x0b /* LDAPv3 */
507 #define LDAP_UNAVAILABLE_CRITICAL_EXTENSION     0x0c /* LDAPv3 */
508 #define LDAP_CONFIDENTIALITY_REQUIRED   0x0d /* LDAPv3 */
509 #define LDAP_SASL_BIND_IN_PROGRESS      0x0e /* LDAPv3 */
510
511 #define LDAP_ATTR_ERROR(n)      LDAP_RANGE((n),0x10,0x15) /* 16-21 */
512
513 #define LDAP_NO_SUCH_ATTRIBUTE          0x10
514 #define LDAP_UNDEFINED_TYPE                     0x11
515 #define LDAP_INAPPROPRIATE_MATCHING     0x12
516 #define LDAP_CONSTRAINT_VIOLATION       0x13
517 #define LDAP_TYPE_OR_VALUE_EXISTS       0x14
518 #define LDAP_INVALID_SYNTAX                     0x15
519
520 #define LDAP_NAME_ERROR(n)      LDAP_RANGE((n),0x20,0x24) /* 32-34,36 */
521
522 #define LDAP_NO_SUCH_OBJECT                     0x20
523 #define LDAP_ALIAS_PROBLEM                      0x21
524 #define LDAP_INVALID_DN_SYNTAX          0x22
525 #define LDAP_IS_LEAF                            0x23 /* not LDAPv3 */
526 #define LDAP_ALIAS_DEREF_PROBLEM        0x24
527
528 #define LDAP_SECURITY_ERROR(n)  LDAP_RANGE((n),0x2F,0x32) /* 47-50 */
529
530 #define LDAP_PROXY_AUTHZ_FAILURE        0x2F /* LDAPv3 proxy authorization */
531 #define LDAP_INAPPROPRIATE_AUTH         0x30
532 #define LDAP_INVALID_CREDENTIALS        0x31
533 #define LDAP_INSUFFICIENT_ACCESS        0x32
534
535 #define LDAP_SERVICE_ERROR(n)   LDAP_RANGE((n),0x33,0x36) /* 51-54 */
536
537 #define LDAP_BUSY                                       0x33
538 #define LDAP_UNAVAILABLE                        0x34
539 #define LDAP_UNWILLING_TO_PERFORM       0x35
540 #define LDAP_LOOP_DETECT                        0x36
541
542 #define LDAP_UPDATE_ERROR(n)    LDAP_RANGE((n),0x40,0x47) /* 64-69,71 */
543
544 #define LDAP_NAMING_VIOLATION           0x40
545 #define LDAP_OBJECT_CLASS_VIOLATION     0x41
546 #define LDAP_NOT_ALLOWED_ON_NONLEAF     0x42
547 #define LDAP_NOT_ALLOWED_ON_RDN         0x43
548 #define LDAP_ALREADY_EXISTS                     0x44
549 #define LDAP_NO_OBJECT_CLASS_MODS       0x45
550 #define LDAP_RESULTS_TOO_LARGE          0x46 /* CLDAP */
551 #define LDAP_AFFECTS_MULTIPLE_DSAS      0x47 /* LDAPv3 */
552
553 #define LDAP_OTHER                                      0x50
554
555 /* LCUP operation codes (113-117) - not implemented */
556 #define LDAP_CUP_RESOURCES_EXHAUSTED    0x71
557 #define LDAP_CUP_SECURITY_VIOLATION             0x72
558 #define LDAP_CUP_INVALID_DATA                   0x73
559 #define LDAP_CUP_UNSUPPORTED_SCHEME             0x74
560 #define LDAP_CUP_RELOAD_REQUIRED                0x75
561
562 /* Cancel operation codes (118-121) */
563 #define LDAP_CANCELLED                          0x76
564 #define LDAP_NO_SUCH_OPERATION          0x77
565 #define LDAP_TOO_LATE                           0x78
566 #define LDAP_CANNOT_CANCEL                      0x79
567
568
569 /* Experimental result codes */
570 #define LDAP_E_ERROR(n) LDAP_RANGE((n),0x1000,0x3FFF) /* experimental */
571 #define LDAP_X_ERROR(n) LDAP_RANGE((n),0x4000,0xFFFF) /* private use */
572
573 /* for the LDAP Sync operation */
574 #define LDAP_SYNC_REFRESH_REQUIRED              0x4100
575
576 /* for the LDAP No-Op control */
577 #define LDAP_NO_OPERATION                               0x410e
578
579 /* for the Assertion control */
580 #define LDAP_ASSERTION_FAILED                   0x410f
581
582 /* for the Chaining Behavior control (consecutive result codes requested;
583  * see <draft-sermersheim-ldap-chaining> ) */
584 #ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
585 #define LDAP_NO_REFERRALS_FOUND                 0x4110
586 #define LDAP_CANNOT_CHAIN                       0x4111
587 #endif
588
589 /* API Error Codes
590  *
591  * Based on draft-ietf-ldap-c-api-xx
592  * but with new negative code values
593  */
594 #define LDAP_API_ERROR(n)               ((n)<0)
595 #define LDAP_API_RESULT(n)              ((n)<=0)
596
597 #define LDAP_SERVER_DOWN                                (-1)
598 #define LDAP_LOCAL_ERROR                                (-2)
599 #define LDAP_ENCODING_ERROR                             (-3)
600 #define LDAP_DECODING_ERROR                             (-4)
601 #define LDAP_TIMEOUT                                    (-5)
602 #define LDAP_AUTH_UNKNOWN                               (-6)
603 #define LDAP_FILTER_ERROR                               (-7)
604 #define LDAP_USER_CANCELLED                             (-8)
605 #define LDAP_PARAM_ERROR                                (-9)
606 #define LDAP_NO_MEMORY                                  (-10)
607 #define LDAP_CONNECT_ERROR                              (-11)
608 #define LDAP_NOT_SUPPORTED                              (-12)
609 #define LDAP_CONTROL_NOT_FOUND                  (-13)
610 #define LDAP_NO_RESULTS_RETURNED                (-14)
611 #define LDAP_MORE_RESULTS_TO_RETURN             (-15)
612 #define LDAP_CLIENT_LOOP                                (-16)
613 #define LDAP_REFERRAL_LIMIT_EXCEEDED    (-17)
614
615
616 /*
617  * This structure represents both ldap messages and ldap responses.
618  * These are really the same, except in the case of search responses,
619  * where a response has multiple messages.
620  */
621
622 typedef struct ldapmsg LDAPMessage;
623
624 /* for modifications */
625 typedef struct ldapmod {
626         int             mod_op;
627
628 #define LDAP_MOD_OP                     (0x0007)
629 #define LDAP_MOD_ADD            (0x0000)
630 #define LDAP_MOD_DELETE         (0x0001)
631 #define LDAP_MOD_REPLACE        (0x0002)
632 #define LDAP_MOD_INCREMENT      (0x0003) /* OpenLDAP extension */
633 #define LDAP_MOD_BVALUES        (0x0080)
634 /* IMPORTANT: do not use code 0x1000 (or above),
635  * it is used internally by the backends!
636  * (see ldap/servers/slapd/slap.h)
637  */
638
639         char            *mod_type;
640         union mod_vals_u {
641                 char            **modv_strvals;
642                 struct berval   **modv_bvals;
643         } mod_vals;
644 #define mod_values      mod_vals.modv_strvals
645 #define mod_bvalues     mod_vals.modv_bvals
646 } LDAPMod;
647
648 /*
649  * structure representing an ldap session which can
650  * encompass connections to multiple servers (in the
651  * face of referrals).
652  */
653 typedef struct ldap LDAP;
654
655 #define LDAP_DEREF_NEVER                0x00
656 #define LDAP_DEREF_SEARCHING    0x01
657 #define LDAP_DEREF_FINDING              0x02
658 #define LDAP_DEREF_ALWAYS               0x03
659
660 #define LDAP_NO_LIMIT                   0
661
662 /* how many messages to retrieve results for */
663 #define LDAP_MSG_ONE                    0x00
664 #define LDAP_MSG_ALL                    0x01
665 #define LDAP_MSG_RECEIVED               0x02
666
667 /*
668  * types for ldap URL handling
669  */
670 typedef struct ldap_url_desc {
671         struct ldap_url_desc *lud_next;
672         char    *lud_scheme;
673         char    *lud_host;
674         int             lud_port;
675         char    *lud_dn;
676         char    **lud_attrs;
677         int             lud_scope;
678         char    *lud_filter;
679         char    **lud_exts;
680         int             lud_crit_exts;
681 } LDAPURLDesc;
682
683 #define LDAP_URL_SUCCESS                0x00    /* Success */
684 #define LDAP_URL_ERR_MEM                0x01    /* can't allocate memory space */
685 #define LDAP_URL_ERR_PARAM              0x02    /* parameter is bad */
686
687 #define LDAP_URL_ERR_BADSCHEME  0x03    /* URL doesn't begin with "ldap[si]://" */
688 #define LDAP_URL_ERR_BADENCLOSURE 0x04  /* URL is missing trailing ">" */
689 #define LDAP_URL_ERR_BADURL             0x05    /* URL is bad */
690 #define LDAP_URL_ERR_BADHOST    0x06    /* host port is bad */
691 #define LDAP_URL_ERR_BADATTRS   0x07    /* bad (or missing) attributes */
692 #define LDAP_URL_ERR_BADSCOPE   0x08    /* scope string is invalid (or missing) */
693 #define LDAP_URL_ERR_BADFILTER  0x09    /* bad or missing filter */
694 #define LDAP_URL_ERR_BADEXTS    0x0a    /* bad or missing extensions */
695
696 /*
697  * The API draft spec says we should declare (or cause to be declared)
698  * 'struct timeval'.   We don't.  See IETF LDAPext discussions.
699  */
700 struct timeval;
701
702 /*
703  * in options.c:
704  */
705 LDAP_F( int )
706 ldap_get_option LDAP_P((
707         LDAP *ld,
708         int option,
709         void *outvalue));
710
711 LDAP_F( int )
712 ldap_set_option LDAP_P((
713         LDAP *ld,
714         int option,
715         LDAP_CONST void *invalue));
716
717 /* V3 REBIND Function Callback Prototype */
718 typedef int (LDAP_REBIND_PROC) LDAP_P((
719         LDAP *ld, LDAP_CONST char *url,
720         ber_tag_t request, ber_int_t msgid,
721         void *params ));
722
723 LDAP_F( int )
724 ldap_set_rebind_proc LDAP_P((
725         LDAP *ld,
726         LDAP_REBIND_PROC *rebind_proc,
727         void *params ));
728
729 /* V3 referral selection Function Callback Prototype */
730 typedef int (LDAP_NEXTREF_PROC) LDAP_P((
731         LDAP *ld, char ***refsp, int *cntp,
732         void *params ));
733
734 LDAP_F( int )
735 ldap_set_nextref_proc LDAP_P((
736         LDAP *ld,
737         LDAP_NEXTREF_PROC *nextref_proc,
738         void *params ));
739
740 /*
741  * in controls.c:
742  */
743 LDAP_F( int )
744 ldap_create_control LDAP_P((
745         LDAP_CONST char *requestOID,
746         BerElement *ber,
747         int iscritical,
748         LDAPControl **ctrlp ));
749
750 LDAP_F( LDAPControl * )
751 ldap_find_control LDAP_P((
752         LDAP_CONST char *oid,
753         LDAPControl **ctrls ));
754
755 LDAP_F( void )
756 ldap_control_free LDAP_P((
757         LDAPControl *ctrl ));
758
759 LDAP_F( void )
760 ldap_controls_free LDAP_P((
761         LDAPControl **ctrls ));
762
763 /*
764  * in dnssrv.c:
765  */
766 LDAP_F( int )
767 ldap_domain2dn LDAP_P((
768         LDAP_CONST char* domain,
769         char** dn ));
770
771 LDAP_F( int )
772 ldap_dn2domain LDAP_P((
773         LDAP_CONST char* dn,
774         char** domain ));
775
776 LDAP_F( int )
777 ldap_domain2hostlist LDAP_P((
778         LDAP_CONST char *domain,
779         char** hostlist ));
780
781 /*
782  * in extended.c:
783  */
784 LDAP_F( int )
785 ldap_extended_operation LDAP_P((
786         LDAP                    *ld,
787         LDAP_CONST char *reqoid,
788         struct berval   *reqdata,
789         LDAPControl             **serverctrls,
790         LDAPControl             **clientctrls,
791         int                             *msgidp ));
792
793 LDAP_F( int )
794 ldap_extended_operation_s LDAP_P((
795         LDAP                    *ld,
796         LDAP_CONST char *reqoid,
797         struct berval   *reqdata,
798         LDAPControl             **serverctrls,
799         LDAPControl             **clientctrls,
800         char                    **retoidp,
801         struct berval   **retdatap ));
802
803 LDAP_F( int )
804 ldap_parse_extended_result LDAP_P((
805         LDAP                    *ld,
806         LDAPMessage             *res,
807         char                    **retoidp,
808         struct berval   **retdatap,
809         int                             freeit ));
810
811 LDAP_F( int )
812 ldap_parse_intermediate LDAP_P((
813         LDAP                    *ld,
814         LDAPMessage             *res,
815         char                    **retoidp,
816         struct berval   **retdatap,
817         LDAPControl             ***serverctrls,
818         int                             freeit ));
819
820 /*
821  * in groupings.c:
822  */
823 #ifdef LDAP_EXOP_GROUPING_CREATE
824
825 LDAP_F( int )
826 ldap_grouping_create LDAP_P((
827         LDAP                    *ld,
828         LDAP_CONST char *grpoid,
829         struct berval   *grpdata,
830         LDAPControl             **serverctrls,
831         LDAPControl             **clientctrls,
832         int                             *msgidp ));
833
834 LDAP_F( int )
835 ldap_grouping_create_s LDAP_P((
836         LDAP                    *ld,
837         LDAP_CONST char *grpoid,
838         struct berval   *grpdata,
839         LDAPControl             **serverctrls,
840         LDAPControl             **clientctrls,
841         struct berval   **retgrpcookiep,
842         struct berval   **retgrpdatap ));
843
844 LDAP_F( int )
845 ldap_parse_grouping_create_result LDAP_P((
846         LDAP                    *ld,
847         LDAPMessage             *res,
848         struct berval   **retgrpcookiep,
849         struct berval   **retgrpdatap,
850         LDAPControl             ***serverctrls,
851         int                             freeit ));
852
853 LDAP_F( int )
854 ldap_grouping_end LDAP_P((
855         LDAP                    *ld,
856         LDAP_CONST char *grpoid,
857         struct berval   *grpdata,
858         LDAPControl             **serverctrls,
859         LDAPControl             **clientctrls,
860         int                             *msgidp ));
861
862 LDAP_F( int )
863 ldap_grouping_end_s LDAP_P((
864         LDAP                    *ld,
865         LDAP_CONST char *grpoid,
866         struct berval   *grpdata,
867         LDAPControl             **serverctrls,
868         LDAPControl             **clientctrls,
869         struct berval   **retgrpdatap ));
870
871 LDAP_F( int )
872 ldap_parse_grouping_end_result LDAP_P((
873         LDAP                    *ld,
874         LDAPMessage             *res,
875         struct berval   **retgrpdatap,
876         LDAPControl             ***serverctrls,
877         int                             freeit ));
878
879 LDAP_F( int )
880 ldap_grouping_action_operation LDAP_P((
881         LDAP                    *ld,
882         LDAP_CONST char *grpoid,
883         struct berval   *grpdata,
884         LDAPControl             **serverctrls,
885         LDAPControl             **clientctrls,
886         int                             *msgidp ));
887
888 LDAP_F( int )
889 ldap_grouping_action_operation_s LDAP_P((
890         LDAP                    *ld,
891         LDAP_CONST char *grpoid,
892         struct berval   *grpdata,
893         LDAPControl             **serverctrls,
894         LDAPControl             **clientctrls,
895         struct berval   **retgrpcookiep,
896         struct berval   **retgrpdatap ));
897
898 LDAP_F( int )
899 ldap_parse_grouping_action_result LDAP_P((
900         LDAP                    *ld,
901         LDAPMessage             *res,
902         struct berval   **retgrpcookiep,
903         struct berval   **retgrpdatap,
904         LDAPControl             ***serverctrls,
905         int                             freeit ));
906
907 LDAP_F( int )
908 ldap_parse_grouping_end_notice LDAP_P((
909         LDAP                    *ld,
910         LDAPMessage             *res,
911         struct berval   **retdatap,
912         struct berval   **retgrpcookiep,
913         struct berval   **retgrpdatap,
914         int                             freeit ));
915
916 LDAP_F( int )
917 ldap_parse_grouping_info_notice LDAP_P((
918         LDAP                    *ld,
919         LDAPMessage             *res,
920         struct berval   **retdatap,
921         struct berval   **retgrpcookiep,
922         struct berval   **retgrpdatap,
923         int                             freeit ));
924 #endif
925
926 /*
927  * in abandon.c:
928  */
929 LDAP_F( int )
930 ldap_abandon_ext LDAP_P((
931         LDAP                    *ld,
932         int                             msgid,
933         LDAPControl             **serverctrls,
934         LDAPControl             **clientctrls ));
935
936 #if LDAP_DEPRECATED
937 LDAP_F( int )
938 ldap_abandon LDAP_P((   /* deprecated */
939         LDAP *ld,
940         int msgid ));
941 #endif
942
943
944 /*
945  * in add.c:
946  */
947 LDAP_F( int )
948 ldap_add_ext LDAP_P((
949         LDAP                    *ld,
950         LDAP_CONST char *dn,
951         LDAPMod                 **attrs,
952         LDAPControl             **serverctrls,
953         LDAPControl             **clientctrls,
954         int                     *msgidp ));
955
956 LDAP_F( int )
957 ldap_add_ext_s LDAP_P((
958         LDAP                    *ld,
959         LDAP_CONST char *dn,
960         LDAPMod                 **attrs,
961         LDAPControl             **serverctrls,
962         LDAPControl             **clientctrls ));
963
964 #if LDAP_DEPRECATED
965 LDAP_F( int )
966 ldap_add LDAP_P((       /* deprecated */
967         LDAP *ld,
968         LDAP_CONST char *dn,
969         LDAPMod **attrs ));
970
971 LDAP_F( int )
972 ldap_add_s LDAP_P((     /* deprecated */
973         LDAP *ld,
974         LDAP_CONST char *dn,
975         LDAPMod **attrs ));
976 #endif
977
978
979 /*
980  * in sasl.c:
981  */
982 LDAP_F( int )
983 ldap_sasl_bind LDAP_P((
984         LDAP                    *ld,
985         LDAP_CONST char *dn,
986         LDAP_CONST char *mechanism,
987         struct berval   *cred,
988         LDAPControl             **serverctrls,
989         LDAPControl             **clientctrls,
990         int                             *msgidp ));
991
992 /* Interaction flags (should be passed about in a control)
993  *  Automatic (default): use defaults, prompt otherwise
994  *  Interactive: prompt always
995  *  Quiet: never prompt
996  */
997 #define LDAP_SASL_AUTOMATIC             0U
998 #define LDAP_SASL_INTERACTIVE   1U
999 #define LDAP_SASL_QUIET                 2U
1000
1001 /*
1002  * V3 SASL Interaction Function Callback Prototype
1003  *      when using Cyrus SASL, interact is pointer to sasl_interact_t
1004  *  should likely passed in a control (and provided controls)
1005  */
1006 typedef int (LDAP_SASL_INTERACT_PROC) LDAP_P((
1007         LDAP *ld, unsigned flags, void* defaults, void *interact ));
1008
1009 LDAP_F( int )
1010 ldap_sasl_interactive_bind_s LDAP_P((
1011         LDAP *ld,
1012         LDAP_CONST char *dn, /* usually NULL */
1013         LDAP_CONST char *saslMechanism,
1014         LDAPControl **serverControls,
1015         LDAPControl **clientControls,
1016
1017         /* should be client controls */
1018         unsigned flags,
1019         LDAP_SASL_INTERACT_PROC *proc,
1020         void *defaults ));
1021
1022 LDAP_F( int )
1023 ldap_sasl_bind_s LDAP_P((
1024         LDAP                    *ld,
1025         LDAP_CONST char *dn,
1026         LDAP_CONST char *mechanism,
1027         struct berval   *cred,
1028         LDAPControl             **serverctrls,
1029         LDAPControl             **clientctrls,
1030         struct berval   **servercredp ));
1031
1032 LDAP_F( int )
1033 ldap_parse_sasl_bind_result LDAP_P((
1034         LDAP                    *ld,
1035         LDAPMessage             *res,
1036         struct berval   **servercredp,
1037         int                             freeit ));
1038
1039 #if LDAP_DEPRECATED
1040 /*
1041  * in bind.c:
1042  *      (deprecated)
1043  */
1044 LDAP_F( int )
1045 ldap_bind LDAP_P((      /* deprecated */
1046         LDAP *ld,
1047         LDAP_CONST char *who,
1048         LDAP_CONST char *passwd,
1049         int authmethod ));
1050
1051 LDAP_F( int )
1052 ldap_bind_s LDAP_P((    /* deprecated */
1053         LDAP *ld,
1054         LDAP_CONST char *who,
1055         LDAP_CONST char *cred,
1056         int authmethod ));
1057
1058 /*
1059  * in sbind.c:
1060  */
1061 LDAP_F( int )
1062 ldap_simple_bind LDAP_P(( /* deprecated */
1063         LDAP *ld,
1064         LDAP_CONST char *who,
1065         LDAP_CONST char *passwd ));
1066
1067 LDAP_F( int )
1068 ldap_simple_bind_s LDAP_P(( /* deprecated */
1069         LDAP *ld,
1070         LDAP_CONST char *who,
1071         LDAP_CONST char *passwd ));
1072
1073
1074 /*
1075  * in kbind.c:
1076  *      (deprecated)
1077  */
1078 LDAP_F( int )
1079 ldap_kerberos_bind_s LDAP_P((   /* deprecated */
1080         LDAP *ld,
1081         LDAP_CONST char *who ));
1082
1083 LDAP_F( int )
1084 ldap_kerberos_bind1 LDAP_P((    /* deprecated */
1085         LDAP *ld,
1086         LDAP_CONST char *who ));
1087
1088 LDAP_F( int )
1089 ldap_kerberos_bind1_s LDAP_P((  /* deprecated */
1090         LDAP *ld,
1091         LDAP_CONST char *who ));
1092
1093 LDAP_F( int )
1094 ldap_kerberos_bind2 LDAP_P((    /* deprecated */
1095         LDAP *ld,
1096         LDAP_CONST char *who ));
1097
1098 LDAP_F( int )
1099 ldap_kerberos_bind2_s LDAP_P((  /* deprecated */
1100         LDAP *ld,
1101         LDAP_CONST char *who ));
1102 #endif
1103
1104
1105 /*
1106  * in compare.c:
1107  */
1108 LDAP_F( int )
1109 ldap_compare_ext LDAP_P((
1110         LDAP                    *ld,
1111         LDAP_CONST char *dn,
1112         LDAP_CONST char *attr,
1113         struct berval   *bvalue,
1114         LDAPControl             **serverctrls,
1115         LDAPControl             **clientctrls,
1116         int                     *msgidp ));
1117
1118 LDAP_F( int )
1119 ldap_compare_ext_s LDAP_P((
1120         LDAP                    *ld,
1121         LDAP_CONST char *dn,
1122         LDAP_CONST char *attr,
1123         struct berval   *bvalue,
1124         LDAPControl             **serverctrls,
1125         LDAPControl             **clientctrls ));
1126
1127 #if LDAP_DEPRECATED
1128 LDAP_F( int )
1129 ldap_compare LDAP_P((   /* deprecated */
1130         LDAP *ld,
1131         LDAP_CONST char *dn,
1132         LDAP_CONST char *attr,
1133         LDAP_CONST char *value ));
1134
1135 LDAP_F( int )
1136 ldap_compare_s LDAP_P(( /* deprecated */
1137         LDAP *ld,
1138         LDAP_CONST char *dn,
1139         LDAP_CONST char *attr,
1140         LDAP_CONST char *value ));
1141 #endif
1142
1143
1144 /*
1145  * in delete.c:
1146  */
1147 LDAP_F( int )
1148 ldap_delete_ext LDAP_P((
1149         LDAP                    *ld,
1150         LDAP_CONST char *dn,
1151         LDAPControl             **serverctrls,
1152         LDAPControl             **clientctrls,
1153         int                     *msgidp ));
1154
1155 LDAP_F( int )
1156 ldap_delete_ext_s LDAP_P((
1157         LDAP                    *ld,
1158         LDAP_CONST char *dn,
1159         LDAPControl             **serverctrls,
1160         LDAPControl             **clientctrls ));
1161
1162 #if LDAP_DEPRECATED
1163 LDAP_F( int )
1164 ldap_delete LDAP_P((    /* deprecated */
1165         LDAP *ld,
1166         LDAP_CONST char *dn ));
1167
1168 LDAP_F( int )
1169 ldap_delete_s LDAP_P((  /* deprecated */
1170         LDAP *ld,
1171         LDAP_CONST char *dn ));
1172 #endif
1173
1174
1175 /*
1176  * in error.c:
1177  */
1178 LDAP_F( int )
1179 ldap_parse_result LDAP_P((
1180         LDAP                    *ld,
1181         LDAPMessage             *res,
1182         int                             *errcodep,
1183         char                    **matcheddnp,
1184         char                    **errmsgp,
1185         char                    ***referralsp,
1186         LDAPControl             ***serverctrls,
1187         int                             freeit ));
1188
1189 LDAP_F( char * )
1190 ldap_err2string LDAP_P((
1191         int err ));
1192
1193 #if LDAP_DEPRECATED
1194 LDAP_F( int )
1195 ldap_result2error LDAP_P((      /* deprecated */
1196         LDAP *ld,
1197         LDAPMessage *r,
1198         int freeit ));
1199
1200 LDAP_F( void )
1201 ldap_perror LDAP_P((    /* deprecated */
1202         LDAP *ld,
1203         LDAP_CONST char *s ));
1204 #endif
1205
1206
1207 /*
1208  * in modify.c:
1209  */
1210 LDAP_F( int )
1211 ldap_modify_ext LDAP_P((
1212         LDAP                    *ld,
1213         LDAP_CONST char *dn,
1214         LDAPMod                 **mods,
1215         LDAPControl             **serverctrls,
1216         LDAPControl             **clientctrls,
1217         int                     *msgidp ));
1218
1219 LDAP_F( int )
1220 ldap_modify_ext_s LDAP_P((
1221         LDAP                    *ld,
1222         LDAP_CONST char *dn,
1223         LDAPMod                 **mods,
1224         LDAPControl             **serverctrls,
1225         LDAPControl             **clientctrls ));
1226
1227 #if LDAP_DEPRECATED
1228 LDAP_F( int )
1229 ldap_modify LDAP_P((    /* deprecated */
1230         LDAP *ld,
1231         LDAP_CONST char *dn,
1232         LDAPMod **mods ));
1233
1234 LDAP_F( int )
1235 ldap_modify_s LDAP_P((  /* deprecated */
1236         LDAP *ld,
1237         LDAP_CONST char *dn,
1238         LDAPMod **mods ));
1239 #endif
1240
1241
1242 /*
1243  * in modrdn.c:
1244  */
1245 LDAP_F( int )
1246 ldap_rename LDAP_P((
1247         LDAP *ld,
1248         LDAP_CONST char *dn,
1249         LDAP_CONST char *newrdn,
1250         LDAP_CONST char *newSuperior,
1251         int deleteoldrdn,
1252         LDAPControl **sctrls,
1253         LDAPControl **cctrls,
1254         int *msgidp ));
1255
1256 LDAP_F( int )
1257 ldap_rename_s LDAP_P((
1258         LDAP *ld,
1259         LDAP_CONST char *dn,
1260         LDAP_CONST char *newrdn,
1261         LDAP_CONST char *newSuperior,
1262         int deleteoldrdn,
1263         LDAPControl **sctrls,
1264         LDAPControl **cctrls ));
1265
1266 #if LDAP_DEPRECATED
1267 LDAP_F( int )
1268 ldap_rename2 LDAP_P((   /* deprecated */
1269         LDAP *ld,
1270         LDAP_CONST char *dn,
1271         LDAP_CONST char *newrdn,
1272         LDAP_CONST char *newSuperior,
1273         int deleteoldrdn ));
1274
1275 LDAP_F( int )
1276 ldap_rename2_s LDAP_P(( /* deprecated */
1277         LDAP *ld,
1278         LDAP_CONST char *dn,
1279         LDAP_CONST char *newrdn,
1280         LDAP_CONST char *newSuperior,
1281         int deleteoldrdn ));
1282
1283 LDAP_F( int )
1284 ldap_modrdn LDAP_P((    /* deprecated */
1285         LDAP *ld,
1286         LDAP_CONST char *dn,
1287         LDAP_CONST char *newrdn ));
1288
1289 LDAP_F( int )
1290 ldap_modrdn_s LDAP_P((  /* deprecated */
1291         LDAP *ld,
1292         LDAP_CONST char *dn,
1293         LDAP_CONST char *newrdn ));
1294
1295 LDAP_F( int )
1296 ldap_modrdn2 LDAP_P((   /* deprecated */
1297         LDAP *ld,
1298         LDAP_CONST char *dn,
1299         LDAP_CONST char *newrdn,
1300         int deleteoldrdn ));
1301
1302 LDAP_F( int )
1303 ldap_modrdn2_s LDAP_P(( /* deprecated */
1304         LDAP *ld,
1305         LDAP_CONST char *dn,
1306         LDAP_CONST char *newrdn,
1307         int deleteoldrdn));
1308 #endif
1309
1310
1311 /*
1312  * in open.c:
1313  */
1314 #if LDAP_DEPRECATED
1315 LDAP_F( LDAP * )
1316 ldap_init LDAP_P(( /* deprecated */
1317         LDAP_CONST char *host,
1318         int port ));
1319
1320 LDAP_F( LDAP * )
1321 ldap_open LDAP_P((      /* deprecated */
1322         LDAP_CONST char *host,
1323         int port ));
1324 #endif
1325
1326 LDAP_F( int )
1327 ldap_create LDAP_P((
1328         LDAP **ldp ));
1329
1330 LDAP_F( int )
1331 ldap_initialize LDAP_P((
1332         LDAP **ldp,
1333         LDAP_CONST char *url ));
1334
1335 /*
1336  * in tls.c
1337  */
1338
1339 LDAP_F( int )
1340 ldap_start_tls LDAP_P((
1341         LDAP *ld,
1342         LDAPControl **serverctrls,
1343         LDAPControl **clientctrls,
1344         int *msgidp ));
1345
1346 LDAP_F( int )
1347 ldap_install_tls LDAP_P((
1348         LDAP *ld ));
1349
1350 LDAP_F( int )
1351 ldap_start_tls_s LDAP_P((
1352         LDAP *ld,
1353         LDAPControl **serverctrls,
1354         LDAPControl **clientctrls ));
1355
1356 /*
1357  * in messages.c:
1358  */
1359 LDAP_F( LDAPMessage * )
1360 ldap_first_message LDAP_P((
1361         LDAP *ld,
1362         LDAPMessage *chain ));
1363
1364 LDAP_F( LDAPMessage * )
1365 ldap_next_message LDAP_P((
1366         LDAP *ld,
1367         LDAPMessage *msg ));
1368
1369 LDAP_F( int )
1370 ldap_count_messages LDAP_P((
1371         LDAP *ld,
1372         LDAPMessage *chain ));
1373
1374 /*
1375  * in references.c:
1376  */
1377 LDAP_F( LDAPMessage * )
1378 ldap_first_reference LDAP_P((
1379         LDAP *ld,
1380         LDAPMessage *chain ));
1381
1382 LDAP_F( LDAPMessage * )
1383 ldap_next_reference LDAP_P((
1384         LDAP *ld,
1385         LDAPMessage *ref ));
1386
1387 LDAP_F( int )
1388 ldap_count_references LDAP_P((
1389         LDAP *ld,
1390         LDAPMessage *chain ));
1391
1392 LDAP_F( int )
1393 ldap_parse_reference LDAP_P((
1394         LDAP                    *ld,
1395         LDAPMessage             *ref,
1396         char                    ***referralsp,
1397         LDAPControl             ***serverctrls,
1398         int                             freeit));
1399
1400
1401 /*
1402  * in getentry.c:
1403  */
1404 LDAP_F( LDAPMessage * )
1405 ldap_first_entry LDAP_P((
1406         LDAP *ld,
1407         LDAPMessage *chain ));
1408
1409 LDAP_F( LDAPMessage * )
1410 ldap_next_entry LDAP_P((
1411         LDAP *ld,
1412         LDAPMessage *entry ));
1413
1414 LDAP_F( int )
1415 ldap_count_entries LDAP_P((
1416         LDAP *ld,
1417         LDAPMessage *chain ));
1418
1419 LDAP_F( int )
1420 ldap_get_entry_controls LDAP_P((
1421         LDAP                    *ld,
1422         LDAPMessage             *entry,
1423         LDAPControl             ***serverctrls));
1424
1425
1426 /*
1427  * in addentry.c
1428  */
1429 LDAP_F( LDAPMessage * )
1430 ldap_delete_result_entry LDAP_P((
1431         LDAPMessage **list,
1432         LDAPMessage *e ));
1433
1434 LDAP_F( void )
1435 ldap_add_result_entry LDAP_P((
1436         LDAPMessage **list,
1437         LDAPMessage *e ));
1438
1439
1440 /*
1441  * in getdn.c
1442  */
1443 LDAP_F( char * )
1444 ldap_get_dn LDAP_P((
1445         LDAP *ld,
1446         LDAPMessage *entry ));
1447
1448 typedef struct ldap_ava {
1449         struct berval la_attr;
1450         struct berval la_value;
1451         unsigned la_flags;
1452 #define LDAP_AVA_NULL                           0x0000U
1453 #define LDAP_AVA_STRING                         0x0001U
1454 #define LDAP_AVA_BINARY                         0x0002U
1455 #define LDAP_AVA_NONPRINTABLE           0x0004U
1456 #define LDAP_AVA_FREE_ATTR                      0x0010U
1457 #define LDAP_AVA_FREE_VALUE                     0x0020U
1458
1459         void *la_private;
1460 } LDAPAVA;
1461
1462 typedef LDAPAVA** LDAPRDN;
1463 typedef LDAPRDN* LDAPDN;
1464
1465 /* DN formats */
1466 #define LDAP_DN_FORMAT_LDAP                     0x0000U
1467 #define LDAP_DN_FORMAT_LDAPV3           0x0010U
1468 #define LDAP_DN_FORMAT_LDAPV2           0x0020U
1469 #define LDAP_DN_FORMAT_DCE                      0x0030U
1470 #define LDAP_DN_FORMAT_UFN                      0x0040U /* dn2str only */
1471 #define LDAP_DN_FORMAT_AD_CANONICAL     0x0050U /* dn2str only */
1472 #define LDAP_DN_FORMAT_LBER                     0x00F0U /* for testing only */
1473 #define LDAP_DN_FORMAT_MASK                     0x00F0U
1474
1475 /* DN flags */
1476 #define LDAP_DN_PRETTY                          0x0100U
1477 #define LDAP_DN_SKIP                            0x0200U
1478 #define LDAP_DN_P_NOLEADTRAILSPACES     0x1000U
1479 #define LDAP_DN_P_NOSPACEAFTERRDN       0x2000U
1480 #define LDAP_DN_PEDANTIC                        0xF000U
1481
1482 LDAP_F( void ) ldap_rdnfree LDAP_P(( LDAPRDN rdn ));
1483 LDAP_F( void ) ldap_dnfree LDAP_P(( LDAPDN dn ));
1484
1485 LDAP_F( int )
1486 ldap_bv2dn LDAP_P(( 
1487         struct berval *bv, 
1488         LDAPDN *dn, 
1489         unsigned flags ));
1490
1491 LDAP_F( int )
1492 ldap_str2dn LDAP_P((
1493         LDAP_CONST char *str,
1494         LDAPDN *dn,
1495         unsigned flags ));
1496
1497 LDAP_F( int )
1498 ldap_dn2bv LDAP_P((
1499         LDAPDN dn,
1500         struct berval *bv,
1501         unsigned flags ));
1502
1503 LDAP_F( int )
1504 ldap_dn2str LDAP_P((
1505         LDAPDN dn,
1506         char **str,
1507         unsigned flags ));
1508
1509 LDAP_F( int )
1510 ldap_bv2rdn LDAP_P((
1511         struct berval *bv,
1512         LDAPRDN *rdn,
1513         char **next,
1514         unsigned flags ));
1515
1516 LDAP_F( int )
1517 ldap_str2rdn LDAP_P((
1518         LDAP_CONST char *str,
1519         LDAPRDN *rdn,
1520         char **next,
1521         unsigned flags ));
1522
1523 LDAP_F( int )
1524 ldap_rdn2bv LDAP_P((
1525         LDAPRDN rdn,
1526         struct berval *bv,
1527         unsigned flags ));
1528
1529 LDAP_F( int )
1530 ldap_rdn2str LDAP_P((
1531         LDAPRDN rdn,
1532         char **str,
1533         unsigned flags ));
1534
1535 LDAP_F( int )
1536 ldap_dn_normalize LDAP_P((
1537         LDAP_CONST char *in, unsigned iflags,
1538         char **out, unsigned oflags ));
1539
1540 LDAP_F( char * )
1541 ldap_dn2ufn LDAP_P(( /* deprecated */
1542         LDAP_CONST char *dn ));
1543
1544 LDAP_F( char ** )
1545 ldap_explode_dn LDAP_P(( /* deprecated */
1546         LDAP_CONST char *dn,
1547         int notypes ));
1548
1549 LDAP_F( char ** )
1550 ldap_explode_rdn LDAP_P(( /* deprecated */
1551         LDAP_CONST char *rdn,
1552         int notypes ));
1553
1554 typedef int LDAPDN_rewrite_func
1555         LDAP_P(( LDAPDN dn, unsigned flags, void *ctx ));
1556
1557 LDAP_F( int )
1558 ldap_X509dn2bv LDAP_P(( void *x509_name, struct berval *dn,
1559         LDAPDN_rewrite_func *func, unsigned flags ));
1560
1561 LDAP_F( char * )
1562 ldap_dn2dcedn LDAP_P(( LDAP_CONST char *dn ));  /* deprecated */
1563
1564 LDAP_F( char * )
1565 ldap_dcedn2dn LDAP_P(( LDAP_CONST char *dce )); /* deprecated */
1566
1567 LDAP_F( char * )
1568 ldap_dn2ad_canonical LDAP_P(( LDAP_CONST char *dn ));   /* deprecated */
1569
1570 LDAP_F( int )
1571 ldap_get_dn_ber LDAP_P((
1572         LDAP *ld, LDAPMessage *e, BerElement **berout, struct berval *dn ));
1573
1574 LDAP_F( int )
1575 ldap_get_attribute_ber LDAP_P((
1576         LDAP *ld, LDAPMessage *e, BerElement *ber, struct berval *attr,
1577         struct berval **vals ));
1578
1579 /*
1580  * in getattr.c
1581  */
1582 LDAP_F( char * )
1583 ldap_first_attribute LDAP_P((
1584         LDAP *ld,
1585         LDAPMessage *entry,
1586         BerElement **ber ));
1587
1588 LDAP_F( char * )
1589 ldap_next_attribute LDAP_P((
1590         LDAP *ld,
1591         LDAPMessage *entry,
1592         BerElement *ber ));
1593
1594
1595 /*
1596  * in getvalues.c
1597  */
1598 LDAP_F( struct berval ** )
1599 ldap_get_values_len LDAP_P((
1600         LDAP *ld,
1601         LDAPMessage *entry,
1602         LDAP_CONST char *target ));
1603
1604 LDAP_F( int )
1605 ldap_count_values_len LDAP_P((
1606         struct berval **vals ));
1607
1608 LDAP_F( void )
1609 ldap_value_free_len LDAP_P((
1610         struct berval **vals ));
1611
1612 #if LDAP_DEPRECATED
1613 LDAP_F( char ** )
1614 ldap_get_values LDAP_P((        /* deprecated */
1615         LDAP *ld,
1616         LDAPMessage *entry,
1617         LDAP_CONST char *target ));
1618
1619 LDAP_F( int )
1620 ldap_count_values LDAP_P((      /* deprecated */
1621         char **vals ));
1622
1623 LDAP_F( void )
1624 ldap_value_free LDAP_P((        /* deprecated */
1625         char **vals ));
1626 #endif
1627
1628 /*
1629  * in result.c:
1630  */
1631 LDAP_F( int )
1632 ldap_result LDAP_P((
1633         LDAP *ld,
1634         int msgid,
1635         int all,
1636         struct timeval *timeout,
1637         LDAPMessage **result ));
1638
1639 LDAP_F( int )
1640 ldap_msgtype LDAP_P((
1641         LDAPMessage *lm ));
1642
1643 LDAP_F( int )
1644 ldap_msgid   LDAP_P((
1645         LDAPMessage *lm ));
1646
1647 LDAP_F( int )
1648 ldap_msgfree LDAP_P((
1649         LDAPMessage *lm ));
1650
1651 LDAP_F( int )
1652 ldap_msgdelete LDAP_P((
1653         LDAP *ld,
1654         int msgid ));
1655
1656
1657 /*
1658  * in search.c:
1659  */
1660 LDAP_F( int )
1661 ldap_search_ext LDAP_P((
1662         LDAP                    *ld,
1663         LDAP_CONST char *base,
1664         int                             scope,
1665         LDAP_CONST char *filter,
1666         char                    **attrs,
1667         int                             attrsonly,
1668         LDAPControl             **serverctrls,
1669         LDAPControl             **clientctrls,
1670         struct timeval  *timeout,
1671         int                             sizelimit,
1672         int                             *msgidp ));
1673
1674 LDAP_F( int )
1675 ldap_search_ext_s LDAP_P((
1676         LDAP                    *ld,
1677         LDAP_CONST char *base,
1678         int                             scope,
1679         LDAP_CONST char *filter,
1680         char                    **attrs,
1681         int                             attrsonly,
1682         LDAPControl             **serverctrls,
1683         LDAPControl             **clientctrls,
1684         struct timeval  *timeout,
1685         int                             sizelimit,
1686         LDAPMessage             **res ));
1687
1688 #if LDAP_DEPRECATED
1689 LDAP_F( int )
1690 ldap_search LDAP_P((    /* deprecated */
1691         LDAP *ld,
1692         LDAP_CONST char *base,
1693         int scope,
1694         LDAP_CONST char *filter,
1695         char **attrs,
1696         int attrsonly ));
1697
1698 LDAP_F( int )
1699 ldap_search_s LDAP_P((  /* deprecated */
1700         LDAP *ld,
1701         LDAP_CONST char *base,
1702         int scope,
1703         LDAP_CONST char *filter,
1704         char **attrs,
1705         int attrsonly,
1706         LDAPMessage **res ));
1707
1708 LDAP_F( int )
1709 ldap_search_st LDAP_P(( /* deprecated */
1710         LDAP *ld,
1711         LDAP_CONST char *base,
1712         int scope,
1713         LDAP_CONST char *filter,
1714     char **attrs,
1715         int attrsonly,
1716         struct timeval *timeout,
1717         LDAPMessage **res ));
1718 #endif
1719
1720 /*
1721  * in unbind.c
1722  */
1723 LDAP_F( int )
1724 ldap_unbind_ext LDAP_P((
1725         LDAP                    *ld,
1726         LDAPControl             **serverctrls,
1727         LDAPControl             **clientctrls));
1728
1729 LDAP_F( int )
1730 ldap_unbind_ext_s LDAP_P((
1731         LDAP                    *ld,
1732         LDAPControl             **serverctrls,
1733         LDAPControl             **clientctrls));
1734
1735 #if LDAP_DEPRECATED
1736 LDAP_F( int )
1737 ldap_unbind LDAP_P(( /* deprecated */
1738         LDAP *ld ));
1739
1740 LDAP_F( int )
1741 ldap_unbind_s LDAP_P(( /* deprecated */
1742         LDAP *ld ));
1743 #endif
1744
1745 /*
1746  * in filter.c
1747  */
1748 LDAP_F( int )
1749 ldap_put_vrFilter LDAP_P((
1750         BerElement *ber,
1751         const char *vrf ));
1752
1753 /*
1754  * in free.c
1755  */
1756
1757 LDAP_F( void * )
1758 ldap_memalloc LDAP_P((
1759         ber_len_t s ));
1760
1761 LDAP_F( void * )
1762 ldap_memrealloc LDAP_P((
1763         void* p,
1764         ber_len_t s ));
1765
1766 LDAP_F( void * )
1767 ldap_memcalloc LDAP_P((
1768         ber_len_t n,
1769         ber_len_t s ));
1770
1771 LDAP_F( void )
1772 ldap_memfree LDAP_P((
1773         void* p ));
1774
1775 LDAP_F( void )
1776 ldap_memvfree LDAP_P((
1777         void** v ));
1778
1779 LDAP_F( char * )
1780 ldap_strdup LDAP_P((
1781         LDAP_CONST char * ));
1782
1783 LDAP_F( void )
1784 ldap_mods_free LDAP_P((
1785         LDAPMod **mods,
1786         int freemods ));
1787
1788
1789 #if LDAP_DEPRECATED
1790 /*
1791  * in sort.c (deprecated)
1792  */
1793 typedef int (LDAP_SORT_AD_CMP_PROC) LDAP_P(( /* deprecated */
1794         LDAP_CONST char *left,
1795         LDAP_CONST char *right ));
1796
1797 typedef int (LDAP_SORT_AV_CMP_PROC) LDAP_P(( /* deprecated */
1798         LDAP_CONST void *left,
1799         LDAP_CONST void *right ));
1800
1801 LDAP_F( int )   /* deprecated */
1802 ldap_sort_entries LDAP_P(( LDAP *ld,
1803         LDAPMessage **chain,
1804         LDAP_CONST char *attr,
1805         LDAP_SORT_AD_CMP_PROC *cmp ));
1806
1807 LDAP_F( int )   /* deprecated */
1808 ldap_sort_values LDAP_P((
1809         LDAP *ld,
1810         char **vals,
1811         LDAP_SORT_AV_CMP_PROC *cmp ));
1812
1813 LDAP_F( int ) /* deprecated */
1814 ldap_sort_strcasecmp LDAP_P((
1815         LDAP_CONST void *a,
1816         LDAP_CONST void *b ));
1817 #endif
1818
1819 /*
1820  * in url.c
1821  */
1822 LDAP_F( int )
1823 ldap_is_ldap_url LDAP_P((
1824         LDAP_CONST char *url ));
1825
1826 LDAP_F( int )
1827 ldap_is_ldaps_url LDAP_P((
1828         LDAP_CONST char *url ));
1829
1830 LDAP_F( int )
1831 ldap_is_ldapi_url LDAP_P((
1832         LDAP_CONST char *url ));
1833
1834 LDAP_F( int )
1835 ldap_url_parse LDAP_P((
1836         LDAP_CONST char *url,
1837         LDAPURLDesc **ludpp ));
1838
1839 LDAP_F( char * )
1840 ldap_url_desc2str LDAP_P((
1841         LDAPURLDesc *ludp ));
1842
1843 LDAP_F( void )
1844 ldap_free_urldesc LDAP_P((
1845         LDAPURLDesc *ludp ));
1846
1847
1848 /*
1849  * LDAP Cancel Extended Operation <draft-zeilenga-ldap-cancel-xx.txt>
1850  *  in cancel.c
1851  */
1852 #define LDAP_API_FEATURE_CANCEL 1000
1853
1854 LDAP_F( int )
1855 ldap_cancel LDAP_P(( LDAP *ld,
1856         int cancelid,
1857         LDAPControl             **sctrls,
1858         LDAPControl             **cctrls,
1859         int                             *msgidp ));
1860
1861 LDAP_F( int )
1862 ldap_cancel_s LDAP_P(( LDAP *ld,
1863         int cancelid,
1864         LDAPControl **sctrl,
1865         LDAPControl **cctrl ));
1866
1867 /*
1868  * LDAP Turn Extended Operation <draft-zeilenga-ldap-turn-xx.txt>
1869  *  in turn.c
1870  */
1871 #define LDAP_API_FEATURE_TURN 1000
1872
1873 LDAP_F( int )
1874 ldap_turn LDAP_P(( LDAP *ld,
1875         int mutual,
1876         LDAP_CONST char* identifier,
1877         LDAPControl             **sctrls,
1878         LDAPControl             **cctrls,
1879         int                             *msgidp ));
1880
1881 LDAP_F( int )
1882 ldap_turn_s LDAP_P(( LDAP *ld,
1883         int mutual,
1884         LDAP_CONST char* identifier,
1885         LDAPControl **sctrl,
1886         LDAPControl **cctrl ));
1887
1888 /*
1889  * LDAP Server Side Sort
1890  *      in sortctrl.c
1891  */
1892 #define LDAP_API_FEATURE_SERVER_SIDE_SORT 1000
1893
1894 /* structure for a sort-key */
1895 typedef struct ldapsortkey {
1896         char *  attributeType;
1897         char *  orderingRule;
1898         int     reverseOrder;
1899 } LDAPSortKey;
1900
1901 LDAP_F( int )
1902 ldap_create_sort_keylist LDAP_P((
1903         LDAPSortKey ***sortKeyList,
1904         char        *keyString ));
1905
1906 LDAP_F( void )
1907 ldap_free_sort_keylist LDAP_P((
1908         LDAPSortKey **sortkeylist ));
1909
1910 LDAP_F( int )
1911 ldap_create_sort_control LDAP_P((
1912         LDAP *ld,
1913         LDAPSortKey **keyList,
1914         int ctl_iscritical,
1915         LDAPControl **ctrlp ));
1916
1917 LDAP_F( int )
1918 ldap_parse_sort_control LDAP_P((
1919         LDAP           *ld,
1920         LDAPControl    **ctrlp,
1921         unsigned long  *result,
1922         char           **attribute ));
1923
1924
1925 /*
1926  * LDAP Virtual List View
1927  *      in vlvctrl.c
1928  */
1929 #define LDAP_API_FEATURE_VIRTUAL_LIST_VIEW 1000
1930
1931 /* structure for virtual list */
1932 typedef struct ldapvlvinfo {
1933         int             ldvlv_version;
1934     unsigned long   ldvlv_before_count;
1935     unsigned long   ldvlv_after_count;
1936     unsigned long   ldvlv_offset;
1937     unsigned long   ldvlv_count;
1938     struct berval *     ldvlv_attrvalue;
1939     struct berval *     ldvlv_context;
1940     void *                      ldvlv_extradata;
1941 } LDAPVLVInfo;
1942
1943 LDAP_F( int )
1944 ldap_create_vlv_control LDAP_P((
1945         LDAP *ld,
1946         LDAPVLVInfo *ldvlistp,
1947         LDAPControl **ctrlp ));
1948
1949 LDAP_F( int )
1950 ldap_parse_vlv_control LDAP_P((
1951         LDAP          *ld,
1952         LDAPControl   **ctrls,
1953         unsigned long *target_posp,
1954         unsigned long *list_countp,
1955         struct berval **contextp,
1956         int           *errcodep ));
1957
1958 /*
1959  * LDAP Transactions
1960  *      in txn.c
1961  */
1962 #ifdef LDAP_GROUP_TRANSACTION
1963 LDAP_F( int )
1964 ldap_parse_txn_create LDAP_P((
1965         LDAP *ld,
1966         LDAPMessage *res,
1967         struct berval **cookie ));
1968
1969 LDAP_F( int )
1970 ldap_txn_create LDAP_P((
1971         LDAP *ld,
1972         LDAPControl             **sctrls,
1973         LDAPControl             **cctrls,
1974         int                             *msgidp ));
1975
1976 LDAP_F( int )
1977 ldap_txn_create_s LDAP_P((
1978         LDAP *ld,
1979         struct berval **cookie,
1980         LDAPControl **sctrls,
1981         LDAPControl **cctrls ));
1982
1983 LDAP_F( int )
1984 ldap_txn_end LDAP_P((
1985         LDAP *ld,
1986         struct berval *cookie,
1987         int commit,
1988         LDAPControl             **sctrls,
1989         LDAPControl             **cctrls,
1990         int                             *msgidp ));
1991
1992 LDAP_F( int )
1993 ldap_txn_end_s LDAP_P((
1994         LDAP *ld,
1995         struct berval *cookie,
1996         int commit,
1997         LDAPControl **sctrls,
1998         LDAPControl **cctrls ));
1999 #endif
2000
2001 /*
2002  * LDAP Who Am I?
2003  *      in whoami.c
2004  */
2005 #define LDAP_API_FEATURE_WHOAMI 1000
2006
2007 LDAP_F( int )
2008 ldap_parse_whoami LDAP_P((
2009         LDAP *ld,
2010         LDAPMessage *res,
2011         struct berval **authzid ));
2012
2013 LDAP_F( int )
2014 ldap_whoami LDAP_P(( LDAP *ld,
2015         LDAPControl             **sctrls,
2016         LDAPControl             **cctrls,
2017         int                             *msgidp ));
2018
2019 LDAP_F( int )
2020 ldap_whoami_s LDAP_P((
2021         LDAP *ld,
2022         struct berval **authzid,
2023         LDAPControl **sctrls,
2024         LDAPControl **cctrls ));
2025
2026 /*
2027  * LDAP Password Modify
2028  *      in passwd.c
2029  */
2030 #define LDAP_API_FEATURE_PASSWD_MODIFY 1000
2031
2032 LDAP_F( int )
2033 ldap_parse_passwd LDAP_P((
2034         LDAP *ld,
2035         LDAPMessage *res,
2036         struct berval *newpasswd ));
2037
2038 LDAP_F( int )
2039 ldap_passwd LDAP_P(( LDAP *ld,
2040         struct berval   *user,
2041         struct berval   *oldpw,
2042         struct berval   *newpw,
2043         LDAPControl             **sctrls,
2044         LDAPControl             **cctrls,
2045         int                             *msgidp ));
2046
2047 LDAP_F( int )
2048 ldap_passwd_s LDAP_P((
2049         LDAP *ld,
2050         struct berval   *user,
2051         struct berval   *oldpw,
2052         struct berval   *newpw,
2053         struct berval *newpasswd,
2054         LDAPControl **sctrls,
2055         LDAPControl **cctrls ));
2056
2057 #ifdef LDAP_CONTROL_PASSWORDPOLICYREQUEST
2058 /*
2059  * LDAP Password Policy controls
2060  *      in ppolicy.c
2061  */
2062 #define LDAP_API_FEATURE_PASSWORD_POLICY 1000
2063
2064 typedef enum passpolicyerror_enum {
2065        PP_passwordExpired = 0,
2066        PP_accountLocked = 1,
2067        PP_changeAfterReset = 2,
2068        PP_passwordModNotAllowed = 3,
2069        PP_mustSupplyOldPassword = 4,
2070        PP_insufficientPasswordQuality = 5,
2071        PP_passwordTooShort = 6,
2072        PP_passwordTooYoung = 7,
2073        PP_passwordInHistory = 8,
2074        PP_noError = 65535
2075 } LDAPPasswordPolicyError;
2076
2077 LDAP_F( int )
2078 ldap_create_passwordpolicy_control LDAP_P((
2079         LDAP *ld,
2080         LDAPControl **ctrlp ));
2081
2082 LDAP_F( int )
2083 ldap_parse_passwordpolicy_control LDAP_P((
2084         LDAP *ld,
2085         LDAPControl *ctrl,
2086         int *expirep,
2087         int *gracep,
2088         LDAPPasswordPolicyError *errorp ));
2089
2090 LDAP_F( const char * )
2091 ldap_passwordpolicy_err2txt LDAP_P(( LDAPPasswordPolicyError ));
2092 #endif /* LDAP_CONTROL_PASSWORDPOLICYREQUEST */
2093
2094 LDAP_END_DECL
2095 #endif /* _LDAP_H */