]> git.sur5r.net Git - openldap/blob - include/ldap.h
d0021a9d37888fe3eecdf073bb5655b07a4d6df7
[openldap] / include / ldap.h
1 /*
2  * Copyright (c) 1990 Regents of the University of Michigan.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms are permitted
6  * provided that this notice is preserved and that due credit is given
7  * to the University of Michigan at Ann Arbor. The name of the University
8  * may not be used to endorse or promote products derived from this
9  * software without specific prior written permission. This software
10  * is provided ``as is'' without express or implied warranty.
11  */
12
13 #ifndef _LDAP_H
14 #define _LDAP_H
15
16 #include <ldap_cdefs.h>
17
18 LDAP_BEGIN_DECL
19
20 #define LDAP_VERSION1   1
21 #define LDAP_VERSION2   2
22 #define LDAP_VERSION3   3
23
24 #define LDAP_VERSION            LDAP_VERSION2
25 #define LDAP_VERSION_MIN        LDAP_VERSION2
26 #define LDAP_VERSION_MAX        LDAP_VERSION2
27
28 /*
29  * We'll use 2000+draft revision for our API version number
30  * As such, the number will be above the old RFC but below 
31  * whatever number does finally get assigned
32  */
33 #define LDAP_API_VERSION        2001
34 #define LDAP_VENDOR_NAME        "OpenLDAP"
35 /* We'll eventually release as 200 */
36 #define LDAP_VENDOR_VERSION     190
37
38 /* include LDAP_API_FEATURE defines */
39 #include <ldap_features.h>
40
41 #if defined( LDAP_API_FEATURE_X_OPENLDAP_REENTRANT ) || \
42         ( defined( LDAP_THREAD_SAFE ) && \
43                 defined( LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE ) )
44         /* -lldap may or may not be thread safe */
45         /* -lldap_r, if available, is always thread safe */
46 #       define  LDAP_API_FEATURE_THREAD_SAFE 1
47 #endif
48 #if defined( LDAP_THREAD_SAFE ) && \
49         defined( LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE )
50 /* #define LDAP_API_FEATURE_SESSION_SAFE        1       */
51 /* #define LDAP_API_OPERATION_SESSION_SAFE      1       */
52 #endif
53
54 #define LDAP_PORT               389
55 #define LDAP_MAX_PORT   65535
56
57 #define LDAP_ROOT_DSE                           ""
58 #define LDAP_NO_ATTRS                           "1.1"
59 #define LDAP_ALL_USER_ATTRIBUTES        "*"
60
61 #define LDAP_URL_PREFIX                 "ldap://"
62 #define LDAP_URL_PREFIX_LEN             (sizeof(LDAP_URL_PREFIX) - 1)
63 #define LDAP_REFERRAL_STR               "Referral:\n"
64 #define LDAP_RERERRAL_STR_LEN   (sizeof(LDAP_REFERRAL_STR) - 1)
65
66 #define LDAP_COMPAT20
67 #define LDAP_COMPAT30
68 #if defined(LDAP_COMPAT20) || defined(LDAP_COMPAT30)
69 #define LDAP_COMPAT
70 #endif
71
72 /* LDAP_OPTions defined by draft-ldapext-ldap-c-api-01 */
73 #define LDAP_OPT_API_INFO                       0x0000
74 #define LDAP_OPT_DESC                           0x0001
75 #define LDAP_OPT_DEREF                          0x0002
76 #define LDAP_OPT_SIZELIMIT                      0x0003
77 #define LDAP_OPT_TIMELIMIT                      0x0004
78 /* 0x05 - 0x07 not defined by current draft */
79 #define LDAP_OPT_REFERRALS                      0x0008
80 #define LDAP_OPT_RESTART                        0x0009
81 /* 0x0a - 0x10 not defined by current draft */
82 #define LDAP_OPT_PROTOCOL_VERSION       0x0011
83 #define LDAP_OPT_SERVER_CONTROLS        0x0012
84 #define LDAP_OPT_CLIENT_CONTROLS        0x0013
85 /* 0x14 - 0x2f not defined by current draft */
86 #define LDAP_OPT_HOST_NAME                      0x0030
87 #define LDAP_OPT_ERROR_NUMBER           0x0031
88 #define LDAP_OPT_ERROR_STRING           0x0032
89
90 /* not defined by current draft */
91 /*      for LDAPv2 compatibility */
92 #define LDAP_OPT_DNS                            0x1001  /* use DN & DNS */
93
94 /* on/off values */
95 #define LDAP_OPT_ON             ((void *) 1)
96 #define LDAP_OPT_OFF    ((void *) 0)
97
98 #define LDAP_OPT_SUCCESS        0
99 #define LDAP_OPT_ERROR          (-1)
100
101 #ifdef LDAP_DEBUG
102 extern int ldap_debug;
103 #endif
104
105 #define LDAP_API_INFO_VERSION   1
106 typedef struct ldapapiinfo {
107         int             ldapai_info_version;            /* version of LDAPAPIInfo (1) */
108         int             ldapai_api_version;                     /* revision of API supported */
109         int             ldapai_protocol_version;        /* highest LDAP version supported */
110         char    **ldapai_extensions;            /* names of API extensions */
111         char    *ldapai_vendor_name;            /* name of supplier */
112         int             ldapai_vendor_version;          /* supplier-specific version * 100 */
113 } LDAPAPIInfo;
114
115 typedef struct ldapcontrol {
116         char                    *ldctl_oid;
117         struct berval   ldctl_value;
118         char                    ldctl_iscritical;
119 } LDAPControl, *PLDAPControl;
120
121 #define LDAP_MAX_ATTR_LEN       100
122
123 /* 
124  * specific LDAP instantiations of BER types we know about
125  */
126
127 /* general stuff */
128 #define LDAP_TAG_MESSAGE        0x30L   /* tag is 16 + constructed bit */
129 #define OLD_LDAP_TAG_MESSAGE    0x10L   /* forgot the constructed bit  */
130 #define LDAP_TAG_MSGID          0x02L
131 /* need to add other LDAP_TAGs here */
132
133 /* possible operations a client can invoke */
134 #define LDAP_REQ_BIND                   0x60L   /* application + constructed */
135 #define LDAP_REQ_UNBIND                 0x42L   /* application + primitive   */
136 #define LDAP_REQ_SEARCH                 0x63L   /* application + constructed */
137 #define LDAP_REQ_MODIFY                 0x66L   /* application + constructed */
138 #define LDAP_REQ_ADD                    0x68L   /* application + constructed */
139 #define LDAP_REQ_DELETE                 0x4aL   /* application + primitive   */
140 #define LDAP_REQ_MODRDN                 0x6cL   /* application + constructed */
141 #define LDAP_REQ_MODDN                  LDAP_REQ_MODRDN 
142 #define LDAP_REQ_RENAME                 LDAP_REQ_MODRDN 
143 #define LDAP_REQ_COMPARE                0x6eL   /* application + constructed */
144 #define LDAP_REQ_ABANDON                0x50L   /* application + primitive   */
145 #define LDAP_REQ_ABANDON                0x77L   /* application + constructed */
146
147 /* U-Mich version 3.0 compatibility stuff */
148 #define LDAP_REQ_UNBIND_30              0x62L
149 #define LDAP_REQ_DELETE_30              0x6aL
150 #define LDAP_REQ_ABANDON_30             0x70L
151
152 /* 
153  * old broken stuff for backwards compatibility - forgot application tag
154  * and constructed/primitive bit
155  */
156 #define OLD_LDAP_REQ_BIND               0x00L
157 #define OLD_LDAP_REQ_UNBIND             0x02L
158 #define OLD_LDAP_REQ_SEARCH             0x03L
159 #define OLD_LDAP_REQ_MODIFY             0x06L
160 #define OLD_LDAP_REQ_ADD                0x08L
161 #define OLD_LDAP_REQ_DELETE             0x0aL
162 #define OLD_LDAP_REQ_MODRDN             0x0cL
163 #define OLD_LDAP_REQ_COMPARE            0x0eL
164 #define OLD_LDAP_REQ_ABANDON            0x10L
165
166 /* possible result types a server can return */
167 #define LDAP_RES_BIND                   0x61L   /* application + constructed */
168 #define LDAP_RES_SEARCH_ENTRY           0x64L   /* application + constructed */
169 #define LDAP_RES_SEARCH_REFERENCE       0x73L   /* V3: application + constructed */
170 #define LDAP_RES_SEARCH_RESULT          0x65L   /* application + constructed */
171 #define LDAP_RES_MODIFY                 0x67L   /* application + constructed */
172 #define LDAP_RES_ADD                    0x69L   /* application + constructed */
173 #define LDAP_RES_DELETE                 0x6bL   /* application + constructed */
174 #define LDAP_RES_MODRDN                 0x6dL   /* application + constructed */
175 #define LDAP_RES_MODDN                  LDAP_RES_MODRDN /* application + constructed */
176 #define LDAP_RES_RENAME                 LDAP_RES_MODRDN /* application + constructed */
177 #define LDAP_RES_COMPARE                0x6fL   /* application + constructed */
178 #define LDAP_RES_EXTENDED               0x78L   /* V3: application + constructed */
179 #define LDAP_RES_ANY                    (-1L)
180
181 /* old broken stuff for backwards compatibility */
182 #define OLD_LDAP_RES_BIND               0x01L
183 #define OLD_LDAP_RES_SEARCH_ENTRY       0x04L
184 #define OLD_LDAP_RES_SEARCH_RESULT      0x05L
185 #define OLD_LDAP_RES_MODIFY             0x07L
186 #define OLD_LDAP_RES_ADD                0x09L
187 #define OLD_LDAP_RES_DELETE             0x0bL
188 #define OLD_LDAP_RES_MODRDN             0x0dL
189 #define OLD_LDAP_RES_MODDN              OLD_LDAP_RES_MODRDN
190 #define OLD_LDAP_RES_COMPARE            0x0fL
191
192 /* authentication methods available */
193 #define LDAP_AUTH_NONE          0x00L   /* no authentication              */
194 #define LDAP_AUTH_SIMPLE        0x80L   /* context specific + primitive   */
195 #define LDAP_AUTH_SASL          0xa3L   /* context specific + primitive   */
196 #define LDAP_AUTH_KRBV4         0xffL   /* means do both of the following */
197 #define LDAP_AUTH_KRBV41        0x81L   /* context specific + primitive   */
198 #define LDAP_AUTH_KRBV42        0x82L   /* context specific + primitive   */
199
200 /* U-Mich version 3.0 compatibility auth methods */
201 #define LDAP_AUTH_SIMPLE_30     0xa0L   /* context specific + constructed */
202 #define LDAP_AUTH_KRBV41_30     0xa1L   /* context specific + constructed */
203 #define LDAP_AUTH_KRBV42_30     0xa2L   /* context specific + constructed */
204
205 /* old broken stuff */
206 #define OLD_LDAP_AUTH_SIMPLE    0x00L
207 #define OLD_LDAP_AUTH_KRBV4     0x01L
208 #define OLD_LDAP_AUTH_KRBV42    0x02L
209
210 /* filter types */
211 #define LDAP_FILTER_AND         0xa0L   /* context specific + constructed */
212 #define LDAP_FILTER_OR          0xa1L   /* context specific + constructed */
213 #define LDAP_FILTER_NOT         0xa2L   /* context specific + constructed */
214 #define LDAP_FILTER_EQUALITY    0xa3L   /* context specific + constructed */
215 #define LDAP_FILTER_SUBSTRINGS  0xa4L   /* context specific + constructed */
216 #define LDAP_FILTER_GE          0xa5L   /* context specific + constructed */
217 #define LDAP_FILTER_LE          0xa6L   /* context specific + constructed */
218 #define LDAP_FILTER_PRESENT     0x87L   /* context specific + primitive   */
219 #define LDAP_FILTER_APPROX      0xa8L   /* context specific + constructed */
220 #define LDAP_FILTER_EXTENDED    0xa9L   /* context specific + constructed */
221
222 /* U-Mich version 3.0 compatibility filter types */
223 #define LDAP_FILTER_PRESENT_30  0xa7L   /* context specific + constructed */
224
225 /* old broken stuff */
226 #define OLD_LDAP_FILTER_AND             0x00L
227 #define OLD_LDAP_FILTER_OR              0x01L
228 #define OLD_LDAP_FILTER_NOT             0x02L
229 #define OLD_LDAP_FILTER_EQUALITY        0x03L
230 #define OLD_LDAP_FILTER_SUBSTRINGS      0x04L
231 #define OLD_LDAP_FILTER_GE              0x05L
232 #define OLD_LDAP_FILTER_LE              0x06L
233 #define OLD_LDAP_FILTER_PRESENT         0x07L
234 #define OLD_LDAP_FILTER_APPROX          0x08L
235
236 /* extended filter component types */
237 #define LDAP_FILTER_EXTENDED_OID        0x81L   /* context specific */
238 #define LDAP_FILTER_EXTENDED_TYPE       0x82L   /* context specific */
239 #define LDAP_FILTER_EXTENDED_VALUE      0x83L   /* context specific */
240 #define LDAP_FILTER_EXTENDED_DNATTRS    0x84L   /* context specific */
241
242 /* substring filter component types */
243 #define LDAP_SUBSTRING_INITIAL  0x80L   /* context specific */
244 #define LDAP_SUBSTRING_ANY      0x81L   /* context specific */
245 #define LDAP_SUBSTRING_FINAL    0x82L   /* context specific */
246
247 /* U-Mich version 3.0 compatibility substring filter component types */
248 #define LDAP_SUBSTRING_INITIAL_30       0xa0L   /* context specific */
249 #define LDAP_SUBSTRING_ANY_30           0xa1L   /* context specific */
250 #define LDAP_SUBSTRING_FINAL_30         0xa2L   /* context specific */
251
252 /* old broken stuff */
253 #define OLD_LDAP_SUBSTRING_INITIAL      0x00L
254 #define OLD_LDAP_SUBSTRING_ANY          0x01L
255 #define OLD_LDAP_SUBSTRING_FINAL        0x02L
256
257 /* search scopes */
258 #define LDAP_SCOPE_BASE         0x00
259 #define LDAP_SCOPE_ONELEVEL     0x01
260 #define LDAP_SCOPE_SUBTREE      0x02
261
262 /* for modifications */
263 typedef struct ldapmod {
264         int             mod_op;
265 #define LDAP_MOD_ADD            0x00
266 #define LDAP_MOD_DELETE         0x01
267 #define LDAP_MOD_REPLACE        0x02
268 #define LDAP_MOD_BVALUES        0x80
269         char            *mod_type;
270         union {
271                 char            **modv_strvals;
272                 struct berval   **modv_bvals;
273         } mod_vals;
274 #define mod_values      mod_vals.modv_strvals
275 #define mod_bvalues     mod_vals.modv_bvals
276 } LDAPMod;
277
278 /* 
279  * possible error codes we can return
280  */
281
282 #define LDAP_SUCCESS                    0x00
283 #define LDAP_OPERATIONS_ERROR           0x01
284 #define LDAP_PROTOCOL_ERROR             0x02
285 #define LDAP_TIMELIMIT_EXCEEDED         0x03
286 #define LDAP_SIZELIMIT_EXCEEDED         0x04
287 #define LDAP_COMPARE_FALSE              0x05
288 #define LDAP_COMPARE_TRUE               0x06
289 #define LDAP_STRONG_AUTH_NOT_SUPPORTED  0x07
290 #define LDAP_STRONG_AUTH_REQUIRED       0x08
291 #define LDAP_PARTIAL_RESULTS            0x09
292 #define LDAP_REFERRAL           0x0a /* LDAPv3 */
293 #define LDAP_ADMINLIMIT_EXCEEDED        0x0b /* LDAPv3 */
294 #define LDAP_UNAVAILABLE_CRITICIAL_EXTENSION    0x0c /* LDAPv3 */
295 #define LDAP_CONFIDENTIALITY_REQUIRED   0x0d /* LDAPv3 */
296 #define LDAP_SASL_BIND_IN_PROGRESS      0x0e /* LDAPv3 */       
297
298 #define LDAP_NO_SUCH_ATTRIBUTE          0x10
299 #define LDAP_UNDEFINED_TYPE             0x11
300 #define LDAP_INAPPROPRIATE_MATCHING     0x12
301 #define LDAP_CONSTRAINT_VIOLATION       0x13
302 #define LDAP_TYPE_OR_VALUE_EXISTS       0x14
303 #define LDAP_INVALID_SYNTAX             0x15
304
305 #define LDAP_NO_SUCH_OBJECT             0x20
306 #define LDAP_ALIAS_PROBLEM              0x21
307 #define LDAP_INVALID_DN_SYNTAX          0x22
308 #define LDAP_IS_LEAF                    0x23 /* not LDAPv3 */
309 #define LDAP_ALIAS_DEREF_PROBLEM        0x24
310
311 #define NAME_ERROR(n)   ((n & 0xf0) == 0x20)
312
313 #define LDAP_INAPPROPRIATE_AUTH         0x30
314 #define LDAP_INVALID_CREDENTIALS        0x31
315 #define LDAP_INSUFFICIENT_ACCESS        0x32
316 #define LDAP_BUSY                       0x33
317 #define LDAP_UNAVAILABLE                0x34
318 #define LDAP_UNWILLING_TO_PERFORM       0x35
319 #define LDAP_LOOP_DETECT                0x36
320
321 #define LDAP_NAMING_VIOLATION           0x40
322 #define LDAP_OBJECT_CLASS_VIOLATION     0x41
323 #define LDAP_NOT_ALLOWED_ON_NONLEAF     0x42
324 #define LDAP_NOT_ALLOWED_ON_RDN         0x43
325 #define LDAP_ALREADY_EXISTS             0x44
326 #define LDAP_NO_OBJECT_CLASS_MODS       0x45
327 #define LDAP_RESULTS_TOO_LARGE          0x46 /* CLDAP */
328 #define LDAP_AFFECTS_MULTIPLE_DSAS      0x47 /* LDAPv3 */
329
330 #define LDAP_OTHER                      0x50
331 #define LDAP_SERVER_DOWN                0x51
332 #define LDAP_LOCAL_ERROR                0x52
333 #define LDAP_ENCODING_ERROR             0x53
334 #define LDAP_DECODING_ERROR             0x54
335 #define LDAP_TIMEOUT                    0x55
336 #define LDAP_AUTH_UNKNOWN               0x56
337 #define LDAP_FILTER_ERROR               0x57
338 #define LDAP_USER_CANCELLED             0x58
339 #define LDAP_PARAM_ERROR                0x59
340 #define LDAP_NO_MEMORY                  0x5a
341
342
343 /* default limit on nesting of referrals */
344 #define LDAP_DEFAULT_REFHOPLIMIT        5
345
346 /*
347  * This structure represents both ldap messages and ldap responses.
348  * These are really the same, except in the case of search responses,
349  * where a response has multiple messages.
350  */
351
352 typedef struct ldapmsg LDAPMessage;
353 #define NULLMSG ((LDAPMessage *) NULL)
354
355
356 #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
357 /*
358  * structure for tracking LDAP server host, ports, DNs, etc.
359  */
360 typedef struct ldap_server {
361         char                    *lsrv_host;
362         char                    *lsrv_dn;       /* if NULL, use default */
363         int                     lsrv_port;
364         struct ldap_server      *lsrv_next;
365 } LDAPServer;
366
367
368 /*
369  * structure for representing an LDAP server connection
370  */
371 typedef struct ldap_conn {
372         Sockbuf                 *lconn_sb;
373         int                     lconn_refcnt;
374         time_t          lconn_lastused; /* time */
375         int                     lconn_status;
376 #define LDAP_CONNST_NEEDSOCKET          1
377 #define LDAP_CONNST_CONNECTING          2
378 #define LDAP_CONNST_CONNECTED           3
379         LDAPServer              *lconn_server;
380         char                    *lconn_krbinstance;
381         struct ldap_conn        *lconn_next;
382 } LDAPConn;
383
384
385 /*
386  * structure used to track outstanding requests
387  */
388 typedef struct ldapreq {
389         int             lr_msgid;       /* the message id */
390         int             lr_status;      /* status of request */
391 #define LDAP_REQST_INPROGRESS   1
392 #define LDAP_REQST_CHASINGREFS  2
393 #define LDAP_REQST_NOTCONNECTED 3
394 #define LDAP_REQST_WRITING      4
395         int             lr_outrefcnt;   /* count of outstanding referrals */
396         int             lr_origid;      /* original request's message id */
397         int             lr_parentcnt;   /* count of parent requests */
398         int             lr_res_msgtype; /* result message type */
399         int             lr_res_errno;   /* result LDAP errno */
400         char            *lr_res_error;  /* result error string */
401         char            *lr_res_matched;/* result matched DN string */
402         BerElement      *lr_ber;        /* ber encoded request contents */
403         LDAPConn        *lr_conn;       /* connection used to send request */
404         struct ldapreq  *lr_parent;     /* request that spawned this referral */
405         struct ldapreq  *lr_refnext;    /* next referral spawned */
406         struct ldapreq  *lr_prev;       /* previous request */
407         struct ldapreq  *lr_next;       /* next request */
408 } LDAPRequest;
409 #endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
410
411
412 /*
413  * structure for client cache
414  */
415 #define LDAP_CACHE_BUCKETS      31      /* cache hash table size */
416 typedef struct ldapcache {
417         LDAPMessage     *lc_buckets[LDAP_CACHE_BUCKETS];/* hash table */
418         LDAPMessage     *lc_requests;                   /* unfulfilled reqs */
419         long            lc_timeout;                     /* request timeout */
420         long            lc_maxmem;                      /* memory to use */
421         long            lc_memused;                     /* memory in use */
422         int             lc_enabled;                     /* enabled? */
423         unsigned long   lc_options;                     /* options */
424 #define LDAP_CACHE_OPT_CACHENOERRS      0x00000001
425 #define LDAP_CACHE_OPT_CACHEALLERRS     0x00000002
426 }  LDAPCache;
427 #define NULLLDCACHE ((LDAPCache *)NULL)
428
429 /*
430  * structures for ldap getfilter routines
431  */
432
433 typedef struct ldap_filt_info {
434         char                    *lfi_filter;
435         char                    *lfi_desc;
436         int                     lfi_scope;      /* LDAP_SCOPE_BASE, etc */
437         int                     lfi_isexact;    /* exact match filter? */
438         struct ldap_filt_info   *lfi_next;
439 } LDAPFiltInfo;
440
441 typedef struct ldap_filt_list {
442     char                        *lfl_tag;
443     char                        *lfl_pattern;
444     char                        *lfl_delims;
445     LDAPFiltInfo                *lfl_ilist;
446     struct ldap_filt_list       *lfl_next;
447 } LDAPFiltList;
448
449
450 #define LDAP_FILT_MAXSIZ        1024
451
452 typedef struct ldap_filt_desc {
453         LDAPFiltList            *lfd_filtlist;
454         LDAPFiltInfo            *lfd_curfip;
455         LDAPFiltInfo            lfd_retfi;
456         char                    lfd_filter[ LDAP_FILT_MAXSIZ ];
457         char                    *lfd_curval;
458         char                    *lfd_curvalcopy;
459         char                    **lfd_curvalwords;
460         char                    *lfd_filtprefix;
461         char                    *lfd_filtsuffix;
462 } LDAPFiltDesc;
463
464
465 /*
466  * structure representing an ldap connection
467  */
468
469 typedef struct ldap LDAP;
470
471 #define LDAP_DEREF_NEVER        0x00
472 #define LDAP_DEREF_SEARCHING    0x01
473 #define LDAP_DEREF_FINDING      0x02
474 #define LDAP_DEREF_ALWAYS       0x03
475
476 #define LDAP_NO_LIMIT           0
477
478 /* how many messages to retrieve results for */
479 #define LDAP_MSG_ONE            0x00
480 #define LDAP_MSG_ALL            0x01
481 #define LDAP_MSG_RECEIVED       0x02
482
483 /*
484  * structure for ldap friendly mapping routines
485  */
486
487 typedef struct ldap_friendly {
488         char    *lf_unfriendly;
489         char    *lf_friendly;
490 } LDAPFriendlyMap;
491
492
493 /*
494  * handy macro to check whether LDAP struct is set up for CLDAP or not
495  */
496 #define LDAP_IS_CLDAP( ld )     ( (ld)->ld_sb.sb_naddr > 0 )
497
498
499 /*
500  * types for ldap URL handling
501  */
502 typedef struct ldap_url_desc {
503     char        *lud_host;
504     int         lud_port;
505     char        *lud_dn;
506     char        **lud_attrs;
507     int         lud_scope;
508     char        *lud_filter;
509     char        *lud_string;    /* for internal use only */
510 } LDAPURLDesc;
511 #define NULLLDAPURLDESC ((LDAPURLDesc *)NULL)
512
513 #define LDAP_URL_ERR_NOTLDAP    1       /* URL doesn't begin with "ldap://" */
514 #define LDAP_URL_ERR_NODN       2       /* URL has no DN (required) */
515 #define LDAP_URL_ERR_BADSCOPE   3       /* URL scope string is invalid */
516 #define LDAP_URL_ERR_MEM        4       /* can't allocate memory space */
517
518 /* avoid pulling in headers */
519 struct timeval;
520
521 /*
522  * in options.c:
523  */
524 LDAP_F int ldap_get_option LDAP_P((LDAP *ld, int option, void *outvalue));
525 LDAP_F int ldap_set_option LDAP_P((LDAP *ld, int option, void *invalue));
526
527 /* Not yet */
528 LDAP_F void ldap_control_free LDAP_P(( LDAPControl *ctrl ));
529 LDAP_F void ldap_controls_free LDAP_P(( LDAPControl **ctrls ));
530   
531 /*
532  * in abandon.c:
533  */
534 LDAP_F int ldap_abandon LDAP_P(( LDAP *ld, int msgid ));
535
536 /*
537  * in add.c:
538  */
539 LDAP_F int ldap_add LDAP_P(( LDAP *ld, char *dn, LDAPMod **attrs ));
540 LDAP_F int ldap_add_s LDAP_P(( LDAP *ld, char *dn, LDAPMod **attrs ));
541
542 /*
543  * in bind.c:
544  */
545 LDAP_F int ldap_bind LDAP_P(( LDAP *ld, char *who, char *passwd, int authmethod ));
546 LDAP_F int ldap_bind_s LDAP_P(( LDAP *ld, char *who, char *cred, int method ));
547 LDAP_F void ldap_set_rebind_proc LDAP_P(( LDAP *ld,
548         int (*rebindproc) LDAP_P(( LDAP *ld, char **dnp, char **passwdp, int *authmethodp, int freeit ))
549 ));
550
551 /*
552  * in sbind.c:
553  */
554 LDAP_F int ldap_simple_bind LDAP_P(( LDAP *ld, char *who, char *passwd ));
555 LDAP_F int ldap_simple_bind_s LDAP_P(( LDAP *ld, char *who, char *passwd ));
556
557 /*
558  * in kbind.c:
559  */
560 LDAP_F int ldap_kerberos_bind_s LDAP_P(( LDAP *ld, char *who ));
561 LDAP_F int ldap_kerberos_bind1 LDAP_P(( LDAP *ld, char *who ));
562 LDAP_F int ldap_kerberos_bind1_s LDAP_P(( LDAP *ld, char *who ));
563 LDAP_F int ldap_kerberos_bind2 LDAP_P(( LDAP *ld, char *who ));
564 LDAP_F int ldap_kerberos_bind2_s LDAP_P(( LDAP *ld, char *who ));
565  
566
567 /*
568  * in cache.c
569  */
570 LDAP_F int ldap_enable_cache LDAP_P(( LDAP *ld, long timeout, long maxmem ));
571 LDAP_F void ldap_disable_cache LDAP_P(( LDAP *ld ));
572 LDAP_F void ldap_set_cache_options LDAP_P(( LDAP *ld, unsigned long opts ));
573 LDAP_F void ldap_destroy_cache LDAP_P(( LDAP *ld ));
574 LDAP_F void ldap_flush_cache LDAP_P(( LDAP *ld ));
575 LDAP_F void ldap_uncache_entry LDAP_P(( LDAP *ld, char *dn ));
576 LDAP_F void ldap_uncache_request LDAP_P(( LDAP *ld, int msgid ));
577
578 /*
579  * in compare.c:
580  */
581 LDAP_F int ldap_compare LDAP_P(( LDAP *ld, char *dn, char *attr, char *value ));
582 LDAP_F int ldap_compare_s LDAP_P(( LDAP *ld, char *dn, char *attr, char *value ));
583
584 /*
585  * in delete.c:
586  */
587 LDAP_F int ldap_delete LDAP_P(( LDAP *ld, char *dn ));
588 LDAP_F int ldap_delete_s LDAP_P(( LDAP *ld, char *dn ));
589
590 /*
591  * in error.c:
592  */
593 LDAP_F int ldap_result2error LDAP_P(( LDAP *ld, LDAPMessage *r, int freeit ));
594 LDAP_F char *ldap_err2string LDAP_P(( int err ));
595 LDAP_F void ldap_perror LDAP_P(( LDAP *ld, char *s ));
596 LDAP_F int ldap_get_lderrno LDAP_P((LDAP *ld, char **matched, char **msg));
597
598 /*
599  * in modify.c:
600  */
601 LDAP_F int ldap_modify LDAP_P(( LDAP *ld, char *dn, LDAPMod **mods ));
602 LDAP_F int ldap_modify_s LDAP_P(( LDAP *ld, char *dn, LDAPMod **mods ));
603
604 /*
605  * in modrdn.c:
606  */
607 LDAP_F int ldap_modrdn LDAP_P(( LDAP *ld, char *dn, char *newrdn ));
608 LDAP_F int ldap_modrdn_s LDAP_P(( LDAP *ld, char *dn, char *newrdn ));
609 LDAP_F int ldap_modrdn2 LDAP_P(( LDAP *ld, char *dn, char *newrdn,
610         int deleteoldrdn ));
611 LDAP_F int ldap_modrdn2_s LDAP_P(( LDAP *ld, char *dn, char *newrdn,
612         int deleteoldrdn));
613
614 /*
615  * in open.c:
616  */
617 LDAP_F LDAP *ldap_open LDAP_P(( char *host, int port ));
618 LDAP_F LDAP *ldap_init LDAP_P(( char *defhost, int defport ));
619
620 /*
621  * in getentry.c:
622  */
623 LDAP_F LDAPMessage *ldap_first_entry LDAP_P(( LDAP *ld, LDAPMessage *chain ));
624 LDAP_F LDAPMessage *ldap_next_entry LDAP_P(( LDAP *ld, LDAPMessage *entry ));
625 LDAP_F int ldap_count_entries LDAP_P(( LDAP *ld, LDAPMessage *chain ));
626
627 /*
628  * in addentry.c
629  */
630 LDAP_F LDAPMessage *ldap_delete_result_entry LDAP_P(( LDAPMessage **list,
631         LDAPMessage *e ));
632 LDAP_F void ldap_add_result_entry LDAP_P(( LDAPMessage **list, LDAPMessage *e ));
633
634 /*
635  * in getdn.c
636  */
637 LDAP_F char *ldap_get_dn LDAP_P(( LDAP *ld, LDAPMessage *entry ));
638 LDAP_F char *ldap_dn2ufn LDAP_P(( char *dn ));
639 LDAP_F char **ldap_explode_dn LDAP_P(( char *dn, int notypes ));
640 LDAP_F char **ldap_explode_rdn LDAP_P(( char *rdn, int notypes ));
641 LDAP_F char **ldap_explode_dns LDAP_P(( char *dn ));
642 LDAP_F int ldap_is_dns_dn LDAP_P(( char *dn ));
643
644 /*
645  * in getattr.c
646  */
647 LDAP_F char *ldap_first_attribute LDAP_P(( LDAP *ld, LDAPMessage *entry,
648         BerElement **ber ));
649 LDAP_F char *ldap_next_attribute LDAP_P(( LDAP *ld, LDAPMessage *entry,
650         BerElement *ber ));
651
652 /*
653  * in getvalues.c
654  */
655 LDAP_F char **ldap_get_values LDAP_P(( LDAP *ld, LDAPMessage *entry, char *target ));
656 LDAP_F struct berval **ldap_get_values_len LDAP_P(( LDAP *ld, LDAPMessage *entry,
657         char *target ));
658 LDAP_F int ldap_count_values LDAP_P(( char **vals ));
659 LDAP_F int ldap_count_values_len LDAP_P(( struct berval **vals ));
660 LDAP_F void ldap_value_free LDAP_P(( char **vals ));
661 LDAP_F void ldap_value_free_len LDAP_P(( struct berval **vals ));
662
663 /*
664  * in result.c:
665  */
666 LDAP_F int ldap_result LDAP_P(( LDAP *ld, int msgid, int all,
667         struct timeval *timeout, LDAPMessage **result ));
668 LDAP_F int ldap_msgtype LDAP_P(( LDAPMessage *lm ));
669 LDAP_F int ldap_msgid   LDAP_P(( LDAPMessage *lm ));
670 LDAP_F int ldap_msgfree LDAP_P(( LDAPMessage *lm ));
671 LDAP_F int ldap_msgdelete LDAP_P(( LDAP *ld, int msgid ));
672
673 /*
674  * in search.c:
675  */
676 LDAP_F int ldap_search LDAP_P(( LDAP *ld, char *base, int scope, char *filter,
677         char **attrs, int attrsonly ));
678 LDAP_F int ldap_search_s LDAP_P(( LDAP *ld, char *base, int scope, char *filter,
679         char **attrs, int attrsonly, LDAPMessage **res ));
680 LDAP_F int ldap_search_st LDAP_P(( LDAP *ld, char *base, int scope, char *filter,
681     char **attrs, int attrsonly, struct timeval *timeout, LDAPMessage **res ));
682
683 /*
684  * in ufn.c
685  */
686 LDAP_F int ldap_ufn_search_c LDAP_P(( LDAP *ld, char *ufn, char **attrs,
687         int attrsonly, LDAPMessage **res, int (*cancelproc)( void *cl ),
688         void *cancelparm ));
689 LDAP_F int ldap_ufn_search_ct LDAP_P(( LDAP *ld, char *ufn, char **attrs,
690         int attrsonly, LDAPMessage **res, int (*cancelproc)( void *cl ),
691         void *cancelparm, char *tag1, char *tag2, char *tag3 ));
692 LDAP_F int ldap_ufn_search_s LDAP_P(( LDAP *ld, char *ufn, char **attrs,
693         int attrsonly, LDAPMessage **res ));
694 LDAP_F LDAPFiltDesc *ldap_ufn_setfilter LDAP_P(( LDAP *ld, char *fname ));
695 LDAP_F void ldap_ufn_setprefix LDAP_P(( LDAP *ld, char *prefix ));
696 LDAP_F int ldap_ufn_timeout LDAP_P(( void *tvparam ));
697
698
699 /*
700  * in unbind.c
701  */
702 LDAP_F int ldap_unbind LDAP_P(( LDAP *ld ));
703 LDAP_F int ldap_unbind_s LDAP_P(( LDAP *ld ));
704
705
706 /*
707  * in getfilter.c
708  */
709 LDAP_F LDAPFiltDesc *ldap_init_getfilter LDAP_P(( char *fname ));
710 LDAP_F LDAPFiltDesc *ldap_init_getfilter_buf LDAP_P(( char *buf, long buflen ));
711 LDAP_F LDAPFiltInfo *ldap_getfirstfilter LDAP_P(( LDAPFiltDesc *lfdp, char *tagpat,
712         char *value ));
713 LDAP_F LDAPFiltInfo *ldap_getnextfilter LDAP_P(( LDAPFiltDesc *lfdp ));
714 LDAP_F void ldap_setfilteraffixes LDAP_P(( LDAPFiltDesc *lfdp, char *prefix, char *suffix ));
715 LDAP_F void ldap_build_filter LDAP_P(( char *buf, unsigned long buflen,
716         char *pattern, char *prefix, char *suffix, char *attr,
717         char *value, char **valwords ));
718
719 /*
720  * in free.c
721  */
722 LDAP_F void ldap_getfilter_free LDAP_P(( LDAPFiltDesc *lfdp ));
723 LDAP_F void ldap_mods_free LDAP_P(( LDAPMod **mods, int freemods ));
724
725 /*
726  * in friendly.c
727  */
728 LDAP_F char *ldap_friendly_name LDAP_P(( char *filename, char *uname,
729         LDAPFriendlyMap **map ));
730 LDAP_F void ldap_free_friendlymap LDAP_P(( LDAPFriendlyMap **map ));
731
732
733 /*
734  * in cldap.c
735  */
736 LDAP_F LDAP *cldap_open LDAP_P(( char *host, int port ));
737 LDAP_F void cldap_close LDAP_P(( LDAP *ld ));
738 LDAP_F int cldap_search_s LDAP_P(( LDAP *ld, char *base, int scope, char *filter,
739         char **attrs, int attrsonly, LDAPMessage **res, char *logdn ));
740 LDAP_F void cldap_setretryinfo LDAP_P(( LDAP *ld, int tries, int timeout ));
741
742
743 /*
744  * in sort.c
745  */
746 LDAP_F int ldap_sort_entries LDAP_P(( LDAP *ld,
747         LDAPMessage **chain, char *attr,
748         int (*cmp) (const char *, const char *) ));
749 LDAP_F int ldap_sort_values LDAP_P(( LDAP *ld,
750         char **vals, int (*cmp) (const void *, const void *) ));
751 LDAP_F int ldap_sort_strcasecmp LDAP_P(( const void *a, const void *b ));
752
753
754 /*
755  * in url.c
756  */
757 LDAP_F int ldap_is_ldap_url LDAP_P(( char *url ));
758 LDAP_F int ldap_url_parse LDAP_P(( char *url, LDAPURLDesc **ludpp ));
759 LDAP_F void ldap_free_urldesc LDAP_P(( LDAPURLDesc *ludp ));
760 LDAP_F int ldap_url_search LDAP_P(( LDAP *ld, char *url, int attrsonly ));
761 LDAP_F int ldap_url_search_s LDAP_P(( LDAP *ld, char *url, int attrsonly,
762         LDAPMessage **res ));
763 LDAP_F int ldap_url_search_st LDAP_P(( LDAP *ld, char *url, int attrsonly,
764         struct timeval *timeout, LDAPMessage **res ));
765
766
767 /*
768  * in charset.c
769  */
770 LDAP_F void ldap_set_string_translators LDAP_P(( LDAP *ld,
771         BERTranslateProc encode_proc, BERTranslateProc decode_proc ));
772 LDAP_F int ldap_translate_from_t61 LDAP_P(( LDAP *ld, char **bufp,
773         unsigned long *lenp, int free_input ));
774 LDAP_F int ldap_translate_to_t61 LDAP_P(( LDAP *ld, char **bufp,
775         unsigned long *lenp, int free_input ));
776 LDAP_F void ldap_enable_translation LDAP_P(( LDAP *ld, LDAPMessage *entry,
777         int enable ));
778
779 LDAP_F int ldap_t61_to_8859 LDAP_P(( char **bufp, unsigned long *buflenp,
780         int free_input ));
781 LDAP_F int ldap_8859_to_t61 LDAP_P(( char **bufp, unsigned long *buflenp,
782         int free_input ));
783
784
785 /*
786  * in msdos/winsock/wsa.c
787  */
788 LDAP_F void ldap_memfree LDAP_P(( void *p ));
789
790 LDAP_END_DECL
791
792 #endif /* _LDAP_H */