1(* $OpenLDAP: pkg/ldap/include/ldap.h,v 1.168.2.16 2003/03/05 23:48:31 kurt Exp $ *)
2(*
3 * Copyright 1998-2003 The OpenLDAP Foundation, Redwood City, California, USA
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted only as authorized by the OpenLDAP
8 * Public License.  A copy of this license is available at
9 * http://www.OpenLDAP.org/license.html or in file LICENSE in the
10 * top-level directory of the distribution.
11 *)
12(* Portions
13 * Copyright (c) 1990 Regents of the University of Michigan.
14 * All rights reserved.
15 *
16 * Redistribution and use in source and binary forms are permitted
17 * provided that this notice is preserved and that due credit is given
18 * to the University of Michigan at Ann Arbor. The name of the University
19 * may not be used to endorse or promote products derived from this
20 * software without specific prior written permission. This software
21 * is provided ``as is'' without express or implied warranty.
22 *)
23
24const
25  LDAP_VERSION1                     = 1;
26  LDAP_VERSION2                     = 2;
27  LDAP_VERSION3                     = 3;
28
29  LDAP_VERSION_MIN                  = LDAP_VERSION2;
30  LDAP_VERSION                      = LDAP_VERSION2;
31  LDAP_VERSION_MAX                  = LDAP_VERSION3;
32
33(*
34 * We'll use 2000+draft revision for our API version number
35 * As such, the number will be above the old RFC but below
36 * whatever number does finally get assigned
37 *)
38const
39  LDAP_API_VERSION                  = 3001;
40  LDAP_VENDOR_NAME                  = 'OpenLDAP';
41
42(* OpenLDAP API Features *)
43  LDAP_API_FEATURE_X_OPENLDAP       = LDAP_VENDOR_VERSION;
44
45{$IF defined(LDAP_API_FEATURE_X_OPENLDAP_REENTRANT) or (defined(LDAP_THREAD_SAFE) and defined(LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE))}
46    (* -lldap may or may not be thread safe *)
47    (* -lldap_r, if available, is always thread safe *)
48  {$DEFINE LDAP_API_FEATURE_THREAD_SAFE}
49{$IFEND}
50{$IF defined(LDAP_THREAD_SAFE) and defined(LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE)}
51  //{$DEFINE LDAP_API_FEATURE_SESSION_SAFE}
52  //{$DEFINE LDAP_API_OPERATION_SESSION_SAFE}
53{$IFEND}
54
55  LDAP_PORT                         = 389;     (* ldap:///     default LDAP port *)
56  LDAPS_PORT                        = 636;     (* ldaps:///    default LDAP over TLS port *)
57
58  LDAP_ROOT_DSE                     = '';
59  LDAP_NO_ATTRS                     = '1.1';
60  LDAP_ALL_USER_ATTRIBUTES          = '*';
61  LDAP_ALL_OPERATIONAL_ATTRIBUTES   = '+'; (* OpenLDAP extension *)
62
63  LDAP_MAXINT                       = 2147483647;
64
65(*
66 * LDAP_OPTions defined by draft-ldapext-ldap-c-api-02
67 * 0x0000 - 0x0fff reserved for api options
68 * 0x1000 - 0x3fff reserved for api extended options
69 * 0x4000 - 0x7fff reserved for private and experimental options
70 *)
71  LDAP_OPT_API_INFO                 = $0000;
72  LDAP_OPT_DESC                     = $0001; (* deprecated *)
73  LDAP_OPT_DEREF                    = $0002;
74  LDAP_OPT_SIZELIMIT                = $0003;
75  LDAP_OPT_TIMELIMIT                = $0004;
76(* $05 - $07 not defined by current draft *)
77  LDAP_OPT_REFERRALS                = $0008;
78  LDAP_OPT_RESTART                  = $0009;
79(* $0a - $10 not defined by current draft *)
80  LDAP_OPT_PROTOCOL_VERSION         = $0011;
81  LDAP_OPT_SERVER_CONTROLS          = $0012;
82  LDAP_OPT_CLIENT_CONTROLS          = $0013;
83(* $14 not defined by current draft *)
84  LDAP_OPT_API_FEATURE_INFO         = $0015;
85
86(* $16 - $2f not defined by current draft *)
87  LDAP_OPT_HOST_NAME                = $0030;
88  LDAP_OPT_RESULT_CODE              = $0031;
89  LDAP_OPT_ERROR_NUMBER             = LDAP_OPT_RESULT_CODE;
90  LDAP_OPT_ERROR_STRING             = $0032;
91  LDAP_OPT_MATCHED_DN               = $0033;
92
93(* $34 - $0fff not defined by current draft *)
94
95(* private and experimental options *)
96(* OpenLDAP specific options *)
97  LDAP_OPT_DEBUG_LEVEL              = $5001;  (* debug level *)
98  LDAP_OPT_TIMEOUT                  = $5002;  (* default timeout *)
99  LDAP_OPT_REFHOPLIMIT              = $5003;  (* ref hop limit *)
100  LDAP_OPT_NETWORK_TIMEOUT          = $5005;  (* socket level timeout *)
101  LDAP_OPT_URI                      = $5006;
102  LDAP_OPT_REFERRAL_URLS            = $5007;  (* Referral URLs *)
103
104(* OpenLDAP TLS options *)
105  LDAP_OPT_X_TLS                    = $6000;
106  LDAP_OPT_X_TLS_CTX                = $6001;  (* SSL CTX *)
107  LDAP_OPT_X_TLS_CACERTFILE         = $6002;
108  LDAP_OPT_X_TLS_CACERTDIR          = $6003;
109  LDAP_OPT_X_TLS_CERTFILE           = $6004;
110  LDAP_OPT_X_TLS_KEYFILE            = $6005;
111  LDAP_OPT_X_TLS_REQUIRE_CERT       = $6006;
112(*   LDAP_OPT_X_TLS_PROTOCOL        = $6007; *)
113  LDAP_OPT_X_TLS_CIPHER_SUITE       = $6008;
114  LDAP_OPT_X_TLS_RANDOM_FILE        = $6009;
115  LDAP_OPT_X_TLS_SSL_CTX            = $600a;
116  LDAP_OPT_X_TLS_CRLCHECK           = $600b;
117  LDAP_OPT_X_TLS_CONNECT_CB         = $6600c;
118  LDAP_OPT_X_TLS_CONNECT_ARG        = $6600d;
119  LDAP_OPT_X_TLS_DHFILE             = $6600e;
120
121  LDAP_OPT_X_TLS_NEVER              = 0;
122  LDAP_OPT_X_TLS_HARD               = 1;
123  LDAP_OPT_X_TLS_DEMAND             = 2;
124  LDAP_OPT_X_TLS_ALLOW              = 3;
125  LDAP_OPT_X_TLS_TRY                = 4;
126
127(* OpenLDAP SASL options *)
128  LDAP_OPT_X_SASL_MECH              = $6100;
129  LDAP_OPT_X_SASL_REALM             = $6101;
130  LDAP_OPT_X_SASL_AUTHCID           = $6102;
131  LDAP_OPT_X_SASL_AUTHZID           = $6103;
132  LDAP_OPT_X_SASL_SSF               = $6104; (* read-only *)
133  LDAP_OPT_X_SASL_SSF_EXTERNAL      = $6105; (* write-only *)
134  LDAP_OPT_X_SASL_SECPROPS          = $6106; (* write-only *)
135  LDAP_OPT_X_SASL_SSF_MIN           = $6107;
136  LDAP_OPT_X_SASL_SSF_MAX           = $6108;
137  LDAP_OPT_X_SASL_MAXBUFSIZE        = $6109;
138
139(* Private API Extensions -- reserved for application use *)
140  LDAP_OPT_PRIVATE_EXTENSION_BASE   = $7000;  (* Private API inclusive *)
141
142(*
143 * ldap_get_option() and ldap_set_option() return values.
144 * As later versions may return other values indicating
145 * failure, current applications should only compare returned
146 * value against LDAP_OPT_SUCCESS.
147 *)
148  LDAP_OPT_SUCCESS                  =  0;
149  LDAP_OPT_ERROR                    = -1;
150
151(* on/off values *)
152  LDAP_OPT_OFF                      = Pointer(0);
153
154function LDAP_OPT_ON: Pointer;
155
156const
157  LDAP_API_INFO_VERSION             = 1;
158
159type
160  PLDAPAPIInfo                      = ^LDAPAPIInfo;
161  LDAPAPIInfo                       = record
162    ldapai_info_version     : cint;      (* version of LDAPAPIInfo (1) *)
163    ldapai_api_version      : cint;      (* revision of API supported *)
164    ldapai_protocol_version : cint;      (* highest LDAP version supported *)
165    ldapai_extensions       : ppcchar;   (* names of API extensions *)
166    ldapai_vendor_name      : pcchar;    (* name of supplier *)
167    ldapai_vendor_version   : cint;      (* supplier-specific version * 100 *)
168  end;
169
170const
171  LDAP_FEATURE_INFO_VERSION         = 1; (* version of api feature structure *)
172
173type
174  pldap_apifeature_info             = ^ldap_apifeature_info;
175  ldap_apifeature_info              = record
176    ldapaif_info_version    : cint;      (* version of this struct (1) *)
177    ldapaif_name            : pcchar;    (* matches LDAP_API_FEATURE_... less the prefix *)
178    ldapaif_version         : cint;      (* matches the value LDAP_API_FEATURE_... *)
179  end;
180
181  PLDAPAPIFeatureInfo               = ^LDAPAPIFeatureInfo;
182  LDAPAPIFeatureInfo                = ldap_apifeature_info;
183
184  PPPLDAPControl                    = ^PPLDAPControl;
185  PPLDAPControl                     = ^PLDAPControl;
186  PLDAPControl                      = ^LDAPControl;
187  LDAPControl                       = record
188    ldctl_oid               : pcchar;
189    ldctl_value             : berval;
190    ldctl_iscritical        : cchar;
191  end;
192
193const
194(* LDAP Controls *)
195(*  standard track controls *)
196  LDAP_CONTROL_MANAGEDSAIT          = '2.16.840.1.113730.3.4.2'; (* RFC 3296 *)
197  LDAP_CONTROL_SUBENTRIES           = '1.3.6.1.4.1.4203.1.10.1'; (* RFC 3672 *)
198  LDAP_CONTROL_PAGEDRESULTS         = '1.2.840.113556.1.4.319';  (* RFC 2696 *)
199
200  LDAP_CONTROL_VALUESRETURNFILTER   = '1.2.826.0.1.3344810.2.3'; (* RFC 3876 *)
201  LDAP_CONTROL_X_VALUESRETURNFILTER = '1.2.826.0.1.334810.2.3';  (* bad OID *)
202
203  LDAP_CONTROL_ASSERT               = '1.3.6.1.1.12';
204  LDAP_CONTROL_PRE_READ             = '1.3.6.1.1.13.1';
205  LDAP_CONTROL_POST_READ            = '1.3.6.1.1.13.2';
206
207(*  standard track - not implemented in slapd(8) *)
208  LDAP_CONTROL_SORTREQUEST          = '1.2.840.113556.1.4.473'; (* RFC 2891 *)
209  LDAP_CONTROL_SORTRESPONSE         = '1.2.840.113556.1.4.474'; (* RFC 2891 *)
210
211(* but not yet formalized controls *)
212  LDAP_CONTROL_PROXY_AUTHZ          = '2.16.840.1.113730.3.4.18';
213
214(* various works in progress *)
215  LDAP_CONTROL_NOOP                 = '1.3.6.1.4.1.4203.666.5.2';
216
217(* LDAP VLV *)(* not implemented in slapd(8) *)
218  LDAP_CONTROL_VLVREQUEST           = '2.16.840.1.113730.3.4.9';
219  LDAP_CONTROL_VLVRESPONSE          = '2.16.840.1.113730.3.4.10';
220
221(* LDAP Sync -- draft-zeilenga-ldup-sync *)(* submitted for publication *)
222  LDAP_SYNC_OID                     = '1.3.6.1.4.1.4203.1.9.1';
223  LDAP_CONTROL_SYNC                 = LDAP_SYNC_OID + '.1';
224  LDAP_CONTROL_SYNC_STATE           = LDAP_SYNC_OID + '.2';
225  LDAP_CONTROL_SYNC_DONE            = LDAP_SYNC_OID + '.3';
226  LDAP_SYNC_INFO                    = LDAP_SYNC_OID + '.4';
227
228  LDAP_SYNC_NONE                    = $00;
229  LDAP_SYNC_REFRESH_ONLY            = $01;
230  LDAP_SYNC_RESERVED                = $02;
231  LDAP_SYNC_REFRESH_AND_PERSIST     = $03;
232
233  LDAP_SYNC_REFRESH_PRESENTS        = 0;
234  LDAP_SYNC_REFRESH_DELETES         = 1;
235
236  LDAP_TAG_SYNC_NEW_COOKIE          = ber_tag_t($80);
237  LDAP_TAG_SYNC_REFRESH_DELETE      = ber_tag_t($a1);
238  LDAP_TAG_SYNC_REFRESH_PRESENT     = ber_tag_t($a2);
239  LDAP_TAG_SYNC_ID_SET              = ber_tag_t($a3);
240
241  LDAP_TAG_SYNC_COOKIE              = ber_tag_t($04);
242  LDAP_TAG_REFRESHDELETES           = ber_tag_t($01);
243  LDAP_TAG_REFRESHDONE              = ber_tag_t($01);
244  LDAP_TAG_RELOAD_HINT              = ber_tag_t($01);
245
246  LDAP_SYNC_PRESENT                 = 0;
247  LDAP_SYNC_ADD                     = 1;
248  LDAP_SYNC_MODIFY                  = 2;
249  LDAP_SYNC_DELETE                  = 3;
250
251(* MS ActiveDirectory controls (for compatibility) *)
252  LDAP_CONTROL_X_DOMAIN_SCOPE       = '1.2.840.113556.1.4.1339';
253  LDAP_CONTROL_X_PERMISSIVE_MODIFY  = '1.2.840.113556.1.4.1413';
254
255(* LDAP Unsolicited Notifications *)
256  LDAP_NOTICE_OF_DISCONNECTION      = '1.3.6.1.4.1.1466.20036'; (* RFC 2251 *)
257  LDAP_NOTICE_DISCONNECT            = LDAP_NOTICE_OF_DISCONNECTION;
258
259(* LDAP Extended Operations *)
260  LDAP_EXOP_START_TLS               = '1.3.6.1.4.1.1466.20037';    (* RFC 2830 *)
261
262  LDAP_EXOP_MODIFY_PASSWD           = '1.3.6.1.4.1.4203.1.11.1';   (* RFC 3062 *)
263  LDAP_TAG_EXOP_MODIFY_PASSWD_ID    = ber_tag_t($80);
264  LDAP_TAG_EXOP_MODIFY_PASSWD_OLD   = ber_tag_t($81);
265  LDAP_TAG_EXOP_MODIFY_PASSWD_NEW   = ber_tag_t($82);
266  LDAP_TAG_EXOP_MODIFY_PASSWD_GEN   = ber_tag_t($80);
267
268  LDAP_EXOP_X_WHO_AM_I              = '1.3.6.1.4.1.4203.1.11.3';
269  LDAP_EXOP_X_CANCEL                = '1.3.6.1.4.1.4203.666.6.3';
270
271(* LDAP Features *)
272  LDAP_FEATURE_ALL_OP_ATTRS         = '1.3.6.1.4.1.4203.1.5.1';    (* RFC 3673 *)
273  LDAP_FEATURE_OBJECTCLASS_ATTRS    = '1.3.6.1.4.1.4203.1.5.2'; (*  @objectClass - new number to be assigned *)
274  LDAP_FEATURE_ABSOLUTE_FILTERS     = '1.3.6.1.4.1.4203.1.5.3';  (* (&) (|) *)
275  LDAP_FEATURE_LANGUAGE_TAG_OPTIONS = '1.3.6.1.4.1.4203.1.5.4';
276  LDAP_FEATURE_LANGUAGE_RANGE_OPTIONS = '1.3.6.1.4.1.4203.1.5.5';
277  LDAP_FEATURE_MODIFY_INCREMENT     = '1.3.6.1.1.14';
278
279(*
280 * specific LDAP instantiations of BER types we know about
281 *)
282
283(* Overview of LBER tag construction
284 *
285 *  Bits
286 *  ______
287 *  8 7 | CLASS
288 *  0 0 = UNIVERSAL
289 *  0 1 = APPLICATION
290 *  1 0 = CONTEXT-SPECIFIC
291 *  1 1 = PRIVATE
292 *      _____
293 *      | 6 | DATA-TYPE
294 *        0 = PRIMITIVE
295 *        1 = CONSTRUCTED
296 *          ___________
297 *          | 5 ... 1 | TAG-NUMBER
298 *)
299
300(* general stuff *)
301  LDAP_TAG_MESSAGE                  = ber_tag_t($30); (* constructed + 16 *)
302  LDAP_TAG_MSGID                    = ber_tag_t($02); (* integer *)
303
304  LDAP_TAG_LDAPDN                   = ber_tag_t($04); (* octet string *)
305  LDAP_TAG_LDAPCRED                 = ber_tag_t($04); (* octet string *)
306
307  LDAP_TAG_CONTROLS                 = ber_tag_t($a0); (* context specific + constructed + 0 *)
308  LDAP_TAG_REFERRAL                 = ber_tag_t($a3); (* context specific + constructed + 3 *)
309
310  LDAP_TAG_NEWSUPERIOR              = ber_tag_t($80); (* context-specific + primitive + 0 *)
311
312  LDAP_TAG_EXOP_REQ_OID             = ber_tag_t($80); (* context specific + primitive *)
313  LDAP_TAG_EXOP_REQ_VALUE           = ber_tag_t($81); (* context specific + primitive *)
314  LDAP_TAG_EXOP_RES_OID             = ber_tag_t($8a); (* context specific + primitive *)
315  LDAP_TAG_EXOP_RES_VALUE           = ber_tag_t($8b); (* context specific + primitive *)
316
317  LDAP_TAG_IM_RES_OID               = ber_tag_t($80); (* context specific + primitive *)
318  LDAP_TAG_IM_RES_VALUE             = ber_tag_t($81); (* context specific + primitive *)
319
320  LDAP_TAG_SASL_RES_CREDS           = ber_tag_t($87); (* context specific + primitive *)
321
322
323(* possible operations a client can invoke *)
324  LDAP_REQ_BIND                     = ber_tag_t($60); (* application + constructed *)
325  LDAP_REQ_UNBIND                   = ber_tag_t($42); (* application + primitive   *)
326  LDAP_REQ_SEARCH                   = ber_tag_t($63); (* application + constructed *)
327  LDAP_REQ_MODIFY                   = ber_tag_t($66); (* application + constructed *)
328  LDAP_REQ_ADD                      = ber_tag_t($68); (* application + constructed *)
329  LDAP_REQ_DELETE                   = ber_tag_t($4a); (* application + primitive   *)
330  LDAP_REQ_MODDN                    = ber_tag_t($6c); (* application + constructed *)
331  LDAP_REQ_MODRDN                   = LDAP_REQ_MODDN;
332  LDAP_REQ_RENAME                   = LDAP_REQ_MODDN;
333  LDAP_REQ_COMPARE                  = ber_tag_t($6e); (* application + constructed *)
334  LDAP_REQ_ABANDON                  = ber_tag_t($50); (* application + primitive   *)
335  LDAP_REQ_EXTENDED                 = ber_tag_t($77); (* application + constructed *)
336
337(* possible result types a server can return *)
338  LDAP_RES_BIND                     = ber_tag_t($61); (* application + constructed *)
339  LDAP_RES_SEARCH_ENTRY             = ber_tag_t($64); (* application + constructed *)
340  LDAP_RES_SEARCH_REFERENCE         = ber_tag_t($73); (* V3: application + constructed *)
341  LDAP_RES_SEARCH_RESULT            = ber_tag_t($65); (* application + constructed *)
342  LDAP_RES_MODIFY                   = ber_tag_t($67); (* application + constructed *)
343  LDAP_RES_ADD                      = ber_tag_t($69); (* application + constructed *)
344  LDAP_RES_DELETE                   = ber_tag_t($6b); (* application + constructed *)
345  LDAP_RES_MODDN                    = ber_tag_t($6d); (* application + constructed *)
346  LDAP_RES_MODRDN                   = LDAP_RES_MODDN; (* application + constructed *)
347  LDAP_RES_RENAME                   = LDAP_RES_MODDN; (* application + constructed *)
348  LDAP_RES_COMPARE                  = ber_tag_t($6f); (* application + constructed *)
349  LDAP_RES_EXTENDED                 = ber_tag_t($78); (* V3: application + constructed *)
350  LDAP_RES_INTERMEDIATE             = ber_tag_t($79); (* V3+: application + constructed *)
351
352  LDAP_RES_ANY                      = -1;
353  LDAP_RES_UNSOLICITED              =  0;
354
355
356(* sasl methods *)
357  LDAP_SASL_SIMPLE                  = pcchar(0);
358  LDAP_SASL_NULL                    = '';
359
360
361(* authentication methods available *)
362  LDAP_AUTH_NONE                    = ber_tag_t($00); (* no authentication          *)
363  LDAP_AUTH_SIMPLE                  = ber_tag_t($80); (* context specific + primitive *)
364  LDAP_AUTH_SASL                    = ber_tag_t($a3); (* context specific + constructed *)
365  LDAP_AUTH_KRBV4                   = ber_tag_t($ff); (* means do both of the following *)
366  LDAP_AUTH_KRBV41                  = ber_tag_t($81); (* context specific + primitive *)
367  LDAP_AUTH_KRBV42                  = ber_tag_t($82); (* context specific + primitive *)
368
369
370(* filter types *)
371  LDAP_FILTER_AND                   = ber_tag_t($a0); (* context specific + constructed *)
372  LDAP_FILTER_OR                    = ber_tag_t($a1); (* context specific + constructed *)
373  LDAP_FILTER_NOT                   = ber_tag_t($a2); (* context specific + constructed *)
374  LDAP_FILTER_EQUALITY              = ber_tag_t($a3); (* context specific + constructed *)
375  LDAP_FILTER_SUBSTRINGS            = ber_tag_t($a4); (* context specific + constructed *)
376  LDAP_FILTER_GE                    = ber_tag_t($a5); (* context specific + constructed *)
377  LDAP_FILTER_LE                    = ber_tag_t($a6); (* context specific + constructed *)
378  LDAP_FILTER_PRESENT               = ber_tag_t($87); (* context specific + primitive   *)
379  LDAP_FILTER_APPROX                = ber_tag_t($a8); (* context specific + constructed *)
380  LDAP_FILTER_EXT                   = ber_tag_t($a9); (* context specific + constructed *)
381
382(* extended filter component types *)
383  LDAP_FILTER_EXT_OID               = ber_tag_t($81); (* context specific *)
384  LDAP_FILTER_EXT_TYPE              = ber_tag_t($82); (* context specific *)
385  LDAP_FILTER_EXT_VALUE             = ber_tag_t($83); (* context specific *)
386  LDAP_FILTER_EXT_DNATTRS           = ber_tag_t($84); (* context specific *)
387
388(* substring filter component types *)
389  LDAP_SUBSTRING_INITIAL            = ber_tag_t($80); (* context specific *)
390  LDAP_SUBSTRING_ANY                = ber_tag_t($81); (* context specific *)
391  LDAP_SUBSTRING_FINAL              = ber_tag_t($82); (* context specific *)
392
393(* search scopes *)
394  LDAP_SCOPE_DEFAULT                = ber_int_t(-1);     (* OpenLDAP extension *)
395  LDAP_SCOPE_BASE                   = ber_int_t($0000);
396  LDAP_SCOPE_BASEOBJECT             = LDAP_SCOPE_BASE;
397  LDAP_SCOPE_ONELEVEL               = ber_int_t($0001);
398  LDAP_SCOPE_ONE                    = LDAP_SCOPE_ONELEVEL;
399  LDAP_SCOPE_SUBTREE                = ber_int_t($0002);
400  LDAP_SCOPE_SUB                    = LDAP_SCOPE_SUBTREE;
401
402
403(*
404 * possible error codes we can return
405 *)
406
407function LDAP_RANGE(n, x, y: ber_int_t): Boolean;
408
409const
410  LDAP_SUCCESS                      = $00;
411  LDAP_OPERATIONS_ERROR             = $01;
412  LDAP_PROTOCOL_ERROR               = $02;
413  LDAP_TIMELIMIT_EXCEEDED           = $03;
414  LDAP_SIZELIMIT_EXCEEDED           = $04;
415  LDAP_COMPARE_FALSE                = $05;
416  LDAP_COMPARE_TRUE                 = $06;
417  LDAP_AUTH_METHOD_NOT_SUPPORTED    = $07;
418  LDAP_STRONG_AUTH_NOT_SUPPORTED    = LDAP_AUTH_METHOD_NOT_SUPPORTED;
419  LDAP_STRONG_AUTH_REQUIRED         = $08;
420  LDAP_PARTIAL_RESULTS              = $09;   (* LDAPv2+ (not LDAPv3) *)
421
422  LDAP_REFERRAL                     = $0a; (* LDAPv3 *)
423  LDAP_ADMINLIMIT_EXCEEDED          = $0b; (* LDAPv3 *)
424  LDAP_UNAVAILABLE_CRITICAL_EXTENSION = $0c; (* LDAPv3 *)
425  LDAP_CONFIDENTIALITY_REQUIRED     = $0d; (* LDAPv3 *)
426  LDAP_SASL_BIND_IN_PROGRESS        = $0e; (* LDAPv3 *)
427
428function LDAP_ATTR_ERROR(n: ber_int_t): Boolean;
429
430const
431  LDAP_NO_SUCH_ATTRIBUTE            = $10;
432  LDAP_UNDEFINED_TYPE               = $11;
433  LDAP_INAPPROPRIATE_MATCHING       = $12;
434  LDAP_CONSTRAINT_VIOLATION         = $13;
435  LDAP_TYPE_OR_VALUE_EXISTS         = $14;
436  LDAP_INVALID_SYNTAX               = $15;
437
438function LDAP_NAME_ERROR(n: ber_int_t): Boolean;
439
440const
441  LDAP_NO_SUCH_OBJECT               = $20;
442  LDAP_ALIAS_PROBLEM                = $21;
443  LDAP_INVALID_DN_SYNTAX            = $22;
444  LDAP_IS_LEAF                      = $23; (* not LDAPv3 *)
445  LDAP_ALIAS_DEREF_PROBLEM          = $24;
446
447function LDAP_SECURITY_ERROR(n: ber_int_t): Boolean;
448
449const
450  LDAP_PROXY_AUTHZ_FAILURE          = $2F; (* LDAPv3 proxy authorization *)
451  LDAP_INAPPROPRIATE_AUTH           = $30;
452  LDAP_INVALID_CREDENTIALS          = $31;
453  LDAP_INSUFFICIENT_ACCESS          = $32;
454
455function LDAP_SERVICE_ERROR(n: ber_int_t): Boolean;
456
457const
458  LDAP_BUSY                         = $33;
459  LDAP_UNAVAILABLE                  = $34;
460  LDAP_UNWILLING_TO_PERFORM         = $35;
461  LDAP_LOOP_DETECT                  = $36;
462
463function LDAP_UPDATE_ERROR(n: ber_int_t): Boolean;
464
465const
466  LDAP_NAMING_VIOLATION             = $40;
467  LDAP_OBJECT_CLASS_VIOLATION       = $41;
468  LDAP_NOT_ALLOWED_ON_NONLEAF       = $42;
469  LDAP_NOT_ALLOWED_ON_RDN           = $43;
470  LDAP_ALREADY_EXISTS               = $44;
471  LDAP_NO_OBJECT_CLASS_MODS         = $45;
472  LDAP_RESULTS_TOO_LARGE            = $46; (* CLDAP *)
473  LDAP_AFFECTS_MULTIPLE_DSAS        = $47; (* LDAPv3 *)
474
475  LDAP_OTHER                        = $50;
476
477(* for the LDAP Sync operation *)
478  LDAP_SYNC_REFRESH_REQUIRED        = $4100;
479
480(* for the LDAP No-Op control *)
481  LDAP_NO_OPERATION                 = $410e;
482
483(* for the Assertion control *)
484  LDAP_ASSERTION_FAILED             = $410f;
485
486(* for the Cancel operation *)
487  LDAP_CANCELLED                    = $4110;
488  LDAP_NO_SUCH_OPERATION            = $4111;
489  LDAP_TOO_LATE                     = $4112;
490  LDAP_CANNOT_CANCEL                = $4113;
491
492(* API Error Codes
493 *
494 * Based on draft-ietf-ldap-c-api-xx
495 * but with new negative code values
496 *)
497
498function LDAP_API_ERROR(n: ber_int_t): Boolean;
499function LDAP_API_RESULT(n: ber_int_t): Boolean;
500
501const
502  LDAP_SERVER_DOWN                  = -1;
503  LDAP_LOCAL_ERROR                  = -2;
504  LDAP_ENCODING_ERROR               = -3;
505  LDAP_DECODING_ERROR               = -4;
506  LDAP_TIMEOUT                      = -5;
507  LDAP_AUTH_UNKNOWN                 = -6;
508  LDAP_FILTER_ERROR                 = -7;
509  LDAP_USER_CANCELLED               = -8;
510  LDAP_PARAM_ERROR                  = -9;
511  LDAP_NO_MEMORY                    = -10;
512  LDAP_CONNECT_ERROR                = -11;
513  LDAP_NOT_SUPPORTED                = -12;
514  LDAP_CONTROL_NOT_FOUND            = -13;
515  LDAP_NO_RESULTS_RETURNED          = -14;
516  LDAP_MORE_RESULTS_TO_RETURN       = -15;
517  LDAP_CLIENT_LOOP                  = -16;
518  LDAP_REFERRAL_LIMIT_EXCEEDED      = -17;
519
520
521(*
522 * This structure represents both ldap messages and ldap responses.
523 * These are really the same, except in the case of search responses,
524 * where a response has multiple messages.
525 *)
526
527type
528//typedef struct ldapmsg LDAPMessage;
529  pldapmsg                          = Pointer;
530
531  PPLDAPMessage                     = ^PLDAPMessage;
532  PLDAPMessage                      = pldapmsg;
533
534
535(* for modifications *)
536const
537  LDAP_MOD_OP                       = $0007;
538  LDAP_MOD_ADD                      = $0000;
539  LDAP_MOD_DELETE                   = $0001;
540  LDAP_MOD_REPLACE                  = $0002;
541  LDAP_MOD_INCREMENT                = $0003; (* OpenLDAP extension *)
542  LDAP_MOD_BVALUES                  = $0080;
543
544type
545  PPPLDAPMod                        = ^PPLDAPMod;
546  PPLDAPMod                         = ^PLDAPMod;
547  PLDAPMod                          = ^LDAPMod;
548  LDAPMod                           = record
549    mod_op      : cint;
550
551(* IMPORTANT: do not use code 0x1000 (or above),
552 * it is used internally by the backends!
553 * (see ldap/servers/slapd/slap.h)
554 *)
555
556    mod_type    : pcchar;
557
558    case cint of
559      0: (mod_vals    : record
560           case cint of
561             0: (modv_strvals  : ppcchar);
562             1: (modv_bvals    : PPBerval);
563         end);
564      1: (case cint of
565           0: (mod_values      : ppcchar);
566           1: (mod_bvalues     : PPBerval));
567  end;
568
569
570(*
571 * structure representing an ldap session which can
572 * encompass connections to multiple servers (in the
573 * face of referrals).
574 *)
575  PLDAP                             = Pointer;
576
577const
578  LDAP_DEREF_NEVER                  = $00;
579  LDAP_DEREF_SEARCHING              = $01;
580  LDAP_DEREF_FINDING                = $02;
581  LDAP_DEREF_ALWAYS                 = $03;
582
583  LDAP_NO_LIMIT                     = 0;
584
585(* how many messages to retrieve results for *)
586  LDAP_MSG_ONE                      = $00;
587  LDAP_MSG_ALL                      = $01;
588  LDAP_MSG_RECEIVED                 = $02;
589
590(*
591 * types for ldap URL handling
592 *)
593
594type
595  pldap_url_desc                    = ^ldap_url_desc;
596  ldap_url_desc                     = record
597    lud_next        : pldap_url_desc;
598    lud_scheme      : pcchar;
599    lud_host        : pcchar;
600    lud_port        : cint;
601    lud_dn          : pcchar;
602    lud_attrs       : ppcchar;
603    lud_scope       : cint;
604    lud_filter      : pcchar;
605    lud_exts        : pcchar;
606    lud_crit_exts   : cint;
607  end;
608
609  PLDAPURLDesc                      = ^LDAPURLDesc;
610  LDAPURLDesc                       = ldap_url_desc;
611
612const
613  LDAP_URL_SUCCESS                  = $00;    (* Success *)
614  LDAP_URL_ERR_MEM                  = $01;    (* can't allocate memory space *)
615  LDAP_URL_ERR_PARAM                = $02;    (* parameter is bad *)
616
617  LDAP_URL_ERR_BADSCHEME            = $03;    (* URL doesn't begin with "ldap[si]://" *)
618  LDAP_URL_ERR_BADENCLOSURE         = $04;    (* URL is missing trailing ">" *)
619  LDAP_URL_ERR_BADURL               = $05;    (* URL is bad *)
620  LDAP_URL_ERR_BADHOST              = $06;    (* host port is bad *)
621  LDAP_URL_ERR_BADATTRS             = $07;    (* bad (or missing) attributes *)
622  LDAP_URL_ERR_BADSCOPE             = $08;    (* scope string is invalid (or missing) *)
623  LDAP_URL_ERR_BADFILTER            = $09;    (* bad or missing filter *)
624  LDAP_URL_ERR_BADEXTS              = $0a;    (* bad or missing extensions *)
625
626(*
627 * The API draft spec says we should declare (or cause to be declared)
628 * 'struct timeval'.   We don't.  See IETF LDAPext discussions.
629 *)
630type
631  ptimeval                          = Pointer;
632
633(*
634 * in options.c:
635 *)
636function ldap_get_option(
637    ld              : PLDAP;
638    option          : cint;
639    outvalue        : Pointer
640  ): cint; cdecl; external;
641
642function ldap_set_option(
643    ld              : PLDAP;
644    option          : cint;
645    const invalue   : Pointer
646  ): cint; cdecl; external;
647
648(* V3 REBIND Function Callback Prototype *)
649type
650  LDAP_REBIND_PROC = function(ld: PLDAP; const url: pcchar; request: ber_tag_t; msgid: ber_int_t; params: Pointer): cint; cdecl;
651
652function ldap_set_rebind_proc(
653    ld              : PLDAP;
654    rebind_proc     : LDAP_REBIND_PROC;
655    params          : Pointer
656  ): cint; cdecl; external;
657
658(* V3 referral selection Function Callback Prototype *)
659type
660  LDAP_NEXTREF_PROC = function(ld: PLDAP; refsp: pppcchar; cntp: pcint; params: Pointer): cint; cdecl;
661
662
663function ldap_set_nextref_proc(
664    ld              : PLDAP;
665    nextref_proc    : LDAP_NEXTREF_PROC;
666    params          : Pointer
667  ): cint; cdecl; external;
668
669
670(*
671 * in controls.c:
672 *)
673
674function ldap_create_control(
675    const requestOID: pcchar;
676    ber             : PBerElement;
677    iscritical      : cint;
678    var ctrlp       : PLDAPControl
679  ): cint; cdecl; external;
680
681function ldap_find_control(
682    const oid       : pcchar;
683    ctrls           : PPLDAPControl
684  ): PLDAPControl; cdecl; external;
685
686procedure ldap_control_free(
687    ctrl            : PLDAPControl
688  ); cdecl; external;
689
690procedure ldap_controls_free(
691    ctrls           : PPLDAPControl
692  ); cdecl; external;
693
694
695(*
696 * in dnssrv.c:
697 *)
698
699function ldap_domain2dn(
700    const domain    : pcchar;
701    var dn          : pcchar
702  ): cint; cdecl; external;
703
704function ldap_dn2domain(
705    const dn        : pcchar;
706    var domain      : pcchar
707  ): cint; cdecl; external;
708
709function ldap_domain2hostlist(
710    const domain    : pcchar;
711    var hostlist    : pcchar
712  ): cint; cdecl; external;
713
714
715(*
716 * in extended.c:
717 *)
718
719function ldap_extended_operation(
720    ld              : PLDAP;
721    const reqoid    : pcchar;
722    reqdata         : PBerval;
723    serverctrls     : PPLDAPControl;
724    clientctrls     : PPLDAPControl;
725    var msgidp      : cint
726  ): cint; cdecl; external;
727
728function ldap_extended_operation_s(
729    ld              : PLDAP;
730    const reqoid    : pcchar;
731    reqdata         : PBerval;
732    serverctrls     : PPLDAPControl;
733    clientctrls     : PPLDAPControl;
734    var retoidp     : pcchar;
735    var retdatap    : PBerval
736  ): cint; cdecl; external;
737
738function ldap_parse_extended_result(
739    ld              : PLDAP;
740    res             : PLDAPMessage;
741    var retoidp     : pcchar;
742    var retdatap    : PBerval;
743    freeit          : cbool
744  ): cint; cdecl; external;
745
746function ldap_parse_intermediate(
747    ld              : PLDAP;
748    res             : PLDAPMessage;
749    var retoidp     : pcchar;
750    var retdatap    : PBerval;
751    serverctrls     : PPPLDAPControl;
752    freeit          : cbool
753  ): cint; cdecl; external;
754
755
756(*
757 * in groupings.c:
758 *)
759(*#ifdef LDAP_EXOP_GROUPING_CREATE
760
761LDAP_F( int )
762ldap_grouping_create LDAP_P((
763    LDAP            *ld,
764    LDAP_CONST cchar *grpoid,
765    struct berval   *grpdata,
766    LDAPControl     **serverctrls,
767    LDAPControl     **clientctrls,
768    int             *msgidp ));
769
770LDAP_F( int )
771ldap_grouping_create_s LDAP_P((
772    LDAP            *ld,
773    LDAP_CONST cchar *grpoid,
774    struct berval   *grpdata,
775    LDAPControl     **serverctrls,
776    LDAPControl     **clientctrls,
777    struct berval   **retgrpcookiep,
778    struct berval   **retgrpdatap ));
779
780LDAP_F( int )
781ldap_parse_grouping_create_result LDAP_P((
782    LDAP            *ld,
783    LDAPMessage     *res,
784    struct berval   **retgrpcookiep,
785    struct berval   **retgrpdatap,
786    LDAPControl     ***serverctrls,
787    int             freeit ));
788
789LDAP_F( int )
790ldap_grouping_end LDAP_P((
791    LDAP            *ld,
792    LDAP_CONST cchar *grpoid,
793    struct berval   *grpdata,
794    LDAPControl     **serverctrls,
795    LDAPControl     **clientctrls,
796    int             *msgidp ));
797
798LDAP_F( int )
799ldap_grouping_end_s LDAP_P((
800    LDAP            *ld,
801    LDAP_CONST cchar *grpoid,
802    struct berval   *grpdata,
803    LDAPControl     **serverctrls,
804    LDAPControl     **clientctrls,
805    struct berval   **retgrpdatap ));
806
807LDAP_F( int )
808ldap_parse_grouping_end_result LDAP_P((
809    LDAP            *ld,
810    LDAPMessage     *res,
811    struct berval   **retgrpdatap,
812    LDAPControl     ***serverctrls,
813    int             freeit ));
814
815LDAP_F( int )
816ldap_grouping_action_operation LDAP_P((
817    LDAP            *ld,
818    LDAP_CONST cchar *grpoid,
819    struct berval   *grpdata,
820    LDAPControl     **serverctrls,
821    LDAPControl     **clientctrls,
822    int             *msgidp ));
823
824LDAP_F( int )
825ldap_grouping_action_operation_s LDAP_P((
826    LDAP            *ld,
827    LDAP_CONST cchar *grpoid,
828    struct berval   *grpdata,
829    LDAPControl     **serverctrls,
830    LDAPControl     **clientctrls,
831    struct berval   **retgrpcookiep,
832    struct berval   **retgrpdatap ));
833
834LDAP_F( int )
835ldap_parse_grouping_action_result LDAP_P((
836    LDAP            *ld,
837    LDAPMessage     *res,
838    struct berval   **retgrpcookiep,
839    struct berval   **retgrpdatap,
840    LDAPControl     ***serverctrls,
841    int             freeit ));
842
843LDAP_F( int )
844ldap_parse_grouping_end_notice LDAP_P((
845    LDAP            *ld,
846    LDAPMessage     *res,
847    struct berval   **retdatap,
848    struct berval   **retgrpcookiep,
849    struct berval   **retgrpdatap,
850    int             freeit ));
851
852LDAP_F( int )
853ldap_parse_grouping_info_notice LDAP_P((
854    LDAP            *ld,
855    LDAPMessage     *res,
856    struct berval   **retdatap,
857    struct berval   **retgrpcookiep,
858    struct berval   **retgrpdatap,
859    int             freeit ));
860#endif
861*)
862
863
864(*
865 * in abandon.c:
866 *)
867
868function ldap_abandon_ext(
869    ld              : PLDAP;
870    msgid           : cint;
871    serverctrls     : PPLDAPControl;
872    clientctrls     : PPLDAPControl
873  ): cint; cdecl; external;
874
875
876(*
877 * in add.c:
878 *)
879
880function ldap_add_ext(
881    ld              : PLDAP;
882    const dn        : pcchar;
883    attrs           : PPLDAPMod;
884    serverctrls     : PPLDAPControl;
885    clientctrls     : PPLDAPControl;
886    var msgidp      : cint
887  ): cint; cdecl; external;
888
889function ldap_add_ext_s(
890    ld              : PLDAP;
891    const dn        : pcchar;
892    attrs           : PPLDAPMod;
893    serverctrls     : PPLDAPControl;
894    clientctrls     : PPLDAPControl
895  ): cint; cdecl; external;
896
897
898(*
899 * in sasl.c:
900 *)
901
902function ldap_sasl_bind(
903    ld              : PLDAP;
904    const dn        : pcchar;
905    const mechanism : pcchar;
906    cred            : PBerval;
907    serverctrls     : PPLDAPControl;
908    clientctrls     : PPLDAPControl;
909    var msgidp      : cint
910  ): cint; cdecl; external;
911
912function ldap_sasl_bind_s(
913    ld              : PLDAP;
914    const dn        : pcchar;
915    const mechanism : pcchar;
916    cred            : PBerval;
917    serverctrls     : PPLDAPControl;
918    clientctrls     : PPLDAPControl;
919    servercredp     : PPBerval
920  ): cint; cdecl; external;
921
922(* Interaction flags (should be passed about in a control)
923 *  Automatic (default): use defaults, prompt otherwise
924 *  Interactive: prompt always
925 *  Quiet: never prompt
926 *)
927const
928  LDAP_SASL_AUTOMATIC               = 0;
929  LDAP_SASL_INTERACTIVE             = 1;
930  LDAP_SASL_QUIET                   = 2;
931
932(*
933 * V3 SASL Interaction Function Callback Prototype
934 *  when using Cyrus SASL, interact is pointer to sasl_interact_t
935 *  should likely passed in a control (and provided controls)
936 *)
937type
938  LDAP_SASL_INTERACT_PROC = function(ld: PLDAP; flags: cuint; defaults, interact: Pointer): cint; cdecl;
939
940function ldap_sasl_interactive_bind_s(
941    ld              : PLDAP;
942    const dn        : pcchar;
943    const mechanism : pcchar;
944    serverctrls     : PPLDAPControl;
945    clientctrls     : PPLDAPControl;
946    flags           : cuint;
947    proc            : LDAP_SASL_INTERACT_PROC;
948    defaults        : Pointer
949  ): cint; cdecl; external;
950
951function ldap_parse_sasl_bind_result(
952    ld              : PLDAP;
953    res             : PLDAPMessage;
954    var servercredp : PBerval;
955    freeit          : cbool
956  ): cint; cdecl; external;
957
958
959(*
960 * in compare.c:
961 *)
962
963function ldap_compare_ext(
964    ld              : PLDAP;
965    const dn        : pcchar;
966    const attr      : pcchar;
967    bvalue          : PBerval;
968    serverctrls     : PPLDAPControl;
969    clientctrls     : PPLDAPControl;
970    var msgidp      : cint
971  ): cint; cdecl; external;
972
973function ldap_compare_ext_s(
974    ld              : PLDAP;
975    const dn        : pcchar;
976    const attr      : pcchar;
977    bvalue          : PBerval;
978    serverctrls     : PPLDAPControl;
979    clientctrls     : PPLDAPControl
980  ): cint; cdecl; external;
981
982
983(*
984 * in delete.c:
985 *)
986
987function ldap_delete_ext(
988    ld              : PLDAP;
989    const dn        : pcchar;
990    serverctrls     : PPLDAPControl;
991    clientctrls     : PPLDAPControl;
992    var msgidp      : cint
993  ): cint; cdecl; external;
994
995function ldap_delete_ext_s(
996    ld              : PLDAP;
997    const dn        : pcchar;
998    serverctrls     : PPLDAPControl;
999    clientctrls     : PPLDAPControl
1000  ): cint; cdecl; external;
1001
1002
1003(*
1004 * in error.c:
1005 *)
1006
1007function ldap_parse_result(
1008    ld              : PLDAP;
1009    res             : PLDAPMessage;
1010    errcodep        : pcint;
1011    matcheddnp      : ppcchar;
1012    errmsgp         : ppcchar;
1013    referralsp      : pppcchar;
1014    serverctrls     : PPPLDAPControl;
1015    freeit          : cbool
1016  ): cint; cdecl; external;
1017
1018function ldap_err2string(
1019    err             : cint
1020  ): pcchar; cdecl; external;
1021
1022
1023(*
1024 * in modify.c:
1025 *)
1026
1027function ldap_modify_ext(
1028    ld              : PLDAP;
1029    const dn        : pcchar;
1030    mods            : PPLDAPMod;
1031    serverctrls     : PPLDAPControl;
1032    clientctrls     : PPLDAPControl;
1033    var msgidp      : cint
1034  ): cint; cdecl; external;
1035
1036function ldap_modify_ext_s(
1037    ld              : PLDAP;
1038    const dn        : pcchar;
1039    mods            : PPLDAPMod;
1040    serverctrls     : PPLDAPControl;
1041    clientctrls     : PPLDAPControl
1042  ): cint; cdecl; external;
1043
1044
1045(*
1046 * in modrdn.c:
1047 *)
1048
1049function ldap_rename(
1050    ld              : PLDAP;
1051    const dn        : pcchar;
1052    const newrdn    : pcchar;
1053    const newSuperior: pcchar;
1054    deleteoldrdn    : cbool;
1055    sctrls          : PPLDAPControl;
1056    cctrls          : PPPLDAPControl;
1057    var msgidp      : cint
1058  ): cint; cdecl; external;
1059
1060function ldap_rename_s(
1061    ld              : PLDAP;
1062    const dn        : pcchar;
1063    const newrdn    : pcchar;
1064    const newSuperior: pcchar;
1065    deleteoldrdn    : cbool;
1066    sctrls          : PPLDAPControl;
1067    cctrls          : PPLDAPControl
1068  ): cint; cdecl; external;
1069
1070
1071(*
1072 * in open.c:
1073 *)
1074
1075function ldap_create(
1076    var ld          : PLDAP
1077  ): cint; cdecl; external;
1078
1079function ldap_initialize(
1080    var ld          : PLDAP;
1081    const url       : pcchar
1082  ): cint; cdecl; external;
1083
1084
1085(*
1086 * in tls.c
1087 *)
1088
1089function ldap_tls_inplace(
1090    ld              : PLDAP
1091  ): cint; cdecl; external;
1092
1093function ldap_install_tls(
1094    ld              : PLDAP
1095  ): cint; cdecl; external;
1096
1097function ldap_start_tls(
1098    ld              : PLDAP;
1099    serverctrls     : PPLDAPControl;
1100    clientctrls     : PPLDAPControl;
1101    var msgidp      : cint
1102  ): cint; cdecl; external;
1103
1104function ldap_start_tls_s(
1105    ld              : PLDAP;
1106    serverctrls     : PPLDAPControl;
1107    clientctrls     : PPLDAPControl
1108  ): cint; cdecl; external;
1109
1110
1111(*
1112 * in messages.c:
1113 *)
1114
1115function ldap_first_message(
1116    ld              : PLDAP;
1117    chain           : PLDAPMessage
1118  ): PLDAPMessage; cdecl; external;
1119
1120function ldap_next_message(
1121    ld              : PLDAP;
1122    msg             : PLDAPMessage
1123  ): PLDAPMessage; cdecl; external;
1124
1125function ldap_count_messages(
1126    ld              : PLDAP;
1127    chain           : PLDAPMessage
1128  ): cint; cdecl; external;
1129
1130
1131(*
1132 * in references.c:
1133 *)
1134
1135function ldap_first_reference(
1136    ld              : PLDAP;
1137    chain           : PLDAPMessage
1138  ): PLDAPMessage; cdecl; external;
1139
1140function ldap_next_reference(
1141    ld              : PLDAP;
1142    ref             : PLDAPMessage
1143  ): PLDAPMessage; cdecl; external;
1144
1145function ldap_count_references(
1146    ld              : PLDAP;
1147    chain           : PLDAPMessage
1148  ): cint; cdecl; external;
1149
1150function ldap_parse_reference(
1151    ld              : PLDAP;
1152    ref             : PLDAPMessage;
1153    var referralsp  : ppcchar;
1154    serverctrls     : PPPLDAPControl;
1155    freeit          : cbool
1156  ): cint; cdecl; external;
1157
1158
1159(*
1160 * in getentry.c:
1161 *)
1162
1163function ldap_first_entry(
1164    ld              : PLDAP;
1165    chain           : PLDAPMessage
1166  ): PLDAPMessage; cdecl; external;
1167
1168function ldap_next_entry(
1169    ld              : PLDAP;
1170    entry           : PLDAPMessage
1171  ): PLDAPMessage; cdecl; external;
1172
1173function ldap_count_entries(
1174    ld              : PLDAP;
1175    chain           : PLDAPMessage
1176  ): cint; cdecl; external;
1177
1178function ldap_get_entry_controls(
1179    ld              : PLDAP;
1180    entry           : PLDAPMessage;
1181    var serverctrls : PPLDAPControl
1182  ): cint; cdecl; external;
1183
1184
1185(*
1186 * in addentry.c
1187 *)
1188
1189function ldap_delete_result_entry(
1190    list            : PPLDAPMessage;
1191    e               : PLDAPMessage
1192  ): PLDAPMessage; cdecl; external;
1193
1194procedure ldap_add_result_entry(
1195    list            : PPLDAPMessage;
1196    e               : PLDAPMessage
1197  ); cdecl; external;
1198
1199
1200(*
1201 * in getdn.c
1202 *)
1203
1204function ldap_get_dn(
1205    ld              : PLDAP;
1206    entry           : PLDAPMessage
1207  ): pcchar; cdecl; external;
1208
1209const
1210  LDAP_AVA_NULL                     = $0000;
1211  LDAP_AVA_STRING                   = $0001;
1212  LDAP_AVA_BINARY                   = $0002;
1213  LDAP_AVA_NONPRINTABLE             = $0004;
1214  LDAP_AVA_FREE_ATTR                = $0010;
1215  LDAP_AVA_FREE_VALUE               = $0020;
1216
1217type
1218  pldap_ava                         = ^ldap_ava;
1219  ldap_ava                          = record
1220    la_attr     : berval;
1221    la_value    : berval;
1222    la_flags    : cuint;
1223    la_private  : Pointer;
1224  end;
1225
1226  PLDAPAVA                          = ^LDAPAVA;
1227  LDAPAVA                           = ldap_ava;
1228
1229  PLDAPRDN                          = ^LDAPRDN;
1230  LDAPRDN                           = ^PLDAPAVA;
1231
1232  PLDAPDN                           = ^LDAPDN;
1233  LDAPDN                            = ^LDAPRDN;
1234
1235const
1236(* DN formats *)
1237  LDAP_DN_FORMAT_LDAP               = $0000;
1238  LDAP_DN_FORMAT_LDAPV3             = $0010;
1239  LDAP_DN_FORMAT_LDAPV2             = $0020;
1240  LDAP_DN_FORMAT_DCE                = $0030;
1241  LDAP_DN_FORMAT_UFN                = $0040; (* dn2str only *)
1242  LDAP_DN_FORMAT_AD_CANONICAL       = $0050; (* dn2str only *)
1243  LDAP_DN_FORMAT_LBER               = $00F0; (* for testing only *)
1244  LDAP_DN_FORMAT_MASK               = $00F0;
1245
1246(* DN flags *)
1247  LDAP_DN_PRETTY                    = $0100;
1248  LDAP_DN_SKIP                      = $0200;
1249  LDAP_DN_P_NOLEADTRAILSPACES       = $1000;
1250  LDAP_DN_P_NOSPACEAFTERRDN         = $2000;
1251  LDAP_DN_PEDANTIC                  = $F000;
1252
1253procedure ldap_rdnfree(rdn: LDAPRDN); cdecl; external;
1254procedure ldap_dnfree(rdn: LDAPDN); cdecl; external;
1255
1256function ldap_bv2dn(
1257    bv              : PBerval;
1258    var dn          : LDAPDN;
1259    flags           : cuint
1260  ): cint; cdecl; external;
1261
1262function ldap_str2dn(
1263    const str       : pcchar;
1264    var dn          : LDAPDN;
1265    flags           : cuint
1266  ): cint; cdecl; external;
1267
1268function ldap_dn2bv(
1269    dn              : LDAPDN;
1270    bv              : PBerval;
1271    flags           : cuint
1272  ): cint; cdecl; external;
1273
1274function ldap_dn2str(
1275    dn              : LDAPDN;
1276    var str         : pcchar;
1277    flags           : cuint
1278  ): cint; cdecl; external;
1279
1280function ldap_bv2rdn(
1281    bv              : PBerval;
1282    var rdn         : LDAPRDN;
1283    var next        : pcchar;
1284    flags           : cuint
1285  ): cint; cdecl; external;
1286
1287function ldap_str2rdn(
1288    const str       : pcchar;
1289    var rdn         : LDAPRDN;
1290    var next        : pcchar;
1291    flags           : cuint
1292  ): cint; cdecl; external;
1293
1294function ldap_rdn2bv(
1295    rdn             : LDAPRDN;
1296    bv              : PBerval;
1297    flags           : cuint
1298  ): cint; cdecl; external;
1299
1300function ldap_rdn2str(
1301    rdn             : LDAPRDN;
1302    var str         : pcchar;
1303    flags           : cuint
1304  ): cint; cdecl; external;
1305
1306function ldap_dn_normalize(
1307    const _in       : pcchar;
1308    iflags          : cuint;
1309    var _out        : pcchar;
1310    oflags          : cuint
1311  ): cint; cdecl; external;
1312
1313
1314type
1315  LDAPDN_rewrite_func = function(dn: LDAPDN; flags: cuint; ctx: Pointer): cint; cdecl;
1316
1317function ldap_X509dn2bv(
1318    x509_name       : Pointer;
1319    dn              : PBerval;
1320    func            : LDAPDN_rewrite_func;
1321    flags           : cuint
1322  ): cint; cdecl; external;
1323
1324function ldap_get_dn_ber(
1325    ld              : PLDAP;
1326    e               : PLDAPMessage;
1327    var berout      : PBerElement;
1328    dn              : PBerval
1329  ): cint; cdecl; external;
1330
1331function ldap_get_attribute_ber(
1332    ld              : PLDAP;
1333    e               : PLDAPMessage;
1334    ber             : PBerElement;
1335    attr            : PBerval;
1336    var vals        : PBerval
1337  ): cint; cdecl; external;
1338
1339
1340(*
1341 * in getattr.c
1342 *)
1343
1344function ldap_first_attribute(
1345    ld              : PLDAP;
1346    entry           : PLDAPMessage;
1347    var ber         : PBerElement
1348  ): pcchar; cdecl; external;
1349
1350function ldap_next_attribute(
1351    ld              : PLDAP;
1352    entry           : PLDAPMessage;
1353    ber             : PBerElement
1354  ): pcchar; cdecl; external;
1355
1356
1357(*
1358 * in getvalues.c
1359 *)
1360
1361function ldap_get_values_len(
1362    ld              : PLDAP;
1363    entry           : PLDAPMessage;
1364    const target    : pcchar
1365  ): PPBerval; cdecl; external;
1366
1367function ldap_count_values_len(
1368    vals            : PPBerval
1369  ): cint; cdecl; external;
1370
1371procedure ldap_value_free_len(
1372    vals            : PPBerval
1373  ); cdecl; external;
1374
1375
1376(*
1377 * in result.c:
1378 *)
1379
1380function ldap_result(
1381    ld              : PLDAP;
1382    msgid           : cint;
1383    all             : cint;
1384    timeout         : ptimeval;
1385    var result      : PLDAPMessage
1386  ): cint; cdecl; external;
1387
1388function ldap_msgtype(
1389    lm              : PLDAPMessage
1390  ): cint; cdecl; external;
1391
1392function ldap_msgid(
1393    lm              : PLDAPMessage
1394  ): cint; cdecl; external;
1395
1396function ldap_msgfree(
1397    lm              : PLDAPMessage
1398  ): cint; cdecl; external;
1399
1400function ldap_msgdelete(
1401    ld              : PLDAP;
1402    msgid           : cint
1403  ): cint; cdecl; external;
1404
1405
1406(*
1407 * in search.c:
1408 *)
1409
1410function ldap_search_ext(
1411    ld              : PLDAP;
1412    const base      : pcchar;
1413    scope           : cint;
1414    const filter    : pcchar;
1415    attrs           : ppcchar;
1416    attrsonly       : cbool;
1417    serverctrls     : PPLDAPControl;
1418    clientctrls     : PPLDAPControl;
1419    timout          : ptimeval;
1420    sizelimit       : cint;
1421    var msgidp      : cint
1422  ): cint; cdecl; external;
1423
1424function ldap_search_ext_s(
1425    ld              : PLDAP;
1426    const base      : pcchar;
1427    scope           : cint;
1428    const filter    : pcchar;
1429    attrs           : ppcchar;
1430    attrsonly       : cbool;
1431    serverctrls     : PPLDAPControl;
1432    clientctrls     : PPLDAPControl;
1433    timout          : ptimeval;
1434    sizelimit       : cint;
1435    var res         : PLDAPMessage
1436  ): cint; cdecl; external;
1437
1438
1439(*
1440 * in unbind.c
1441 *)
1442
1443function ldap_unbind_ext(
1444    ld              : PLDAP;
1445    serverctrls     : PPLDAPControl;
1446    clientctrls     : PPLDAPControl
1447  ): cint; cdecl; external;
1448
1449function ldap_unbind_ext_s(
1450    ld              : PLDAP;
1451    serverctrls     : PPLDAPControl;
1452    clientctrls     : PPLDAPControl
1453  ): cint; cdecl; external;
1454
1455
1456(*
1457 * in filter.c
1458 *)
1459
1460function ldap_put_vrFilter(
1461    ber             : PBerElement;
1462    const vrf       : pcchar
1463  ): cint; cdecl; external;
1464
1465
1466(*
1467 * in free.c
1468 *)
1469
1470function ldap_memalloc(
1471    s               : ber_len_t
1472  ): Pointer; cdecl; external;
1473
1474function ldap_memrealloc(
1475    p               : Pointer;
1476    s               : ber_len_t
1477  ): Pointer; cdecl; external;
1478
1479function ldap_memcalloc(
1480    n               : ber_len_t;
1481    s               : ber_len_t
1482  ): Pointer; cdecl; external;
1483
1484procedure ldap_memfree(
1485    p               : Pointer
1486  ); cdecl; external;
1487
1488procedure ldap_memvfree(
1489    v               : PPointer
1490  ); cdecl; external;
1491
1492function ldap_strdup(
1493    const str       : pcchar
1494  ): pcchar; cdecl; external;
1495
1496procedure ldap_mods_free(
1497    mods            : PPLDAPMod;
1498    freemods        : cbool
1499  ); cdecl; external;
1500
1501
1502(*
1503 * in url.c
1504 *)
1505
1506function ldap_is_ldap_url(
1507    const url       : pcchar
1508  ): cint; cdecl; external;
1509
1510function ldap_is_ldaps_url(
1511    const url       : pcchar
1512  ): cint; cdecl; external;
1513
1514function ldap_is_ldapi_url(
1515    const url       : pcchar
1516  ): cint; cdecl; external;
1517
1518function ldap_url_parse(
1519    const url       : pcchar;
1520    var ludpp       : PLDAPURLDesc
1521  ): cint; cdecl; external;
1522
1523function ldap_url_desc2str(
1524    ludpp           : PLDAPURLDesc
1525  ): pcchar; cdecl; external;
1526
1527procedure ldap_free_urldesc(
1528    ludpp           : PLDAPURLDesc
1529  ); cdecl; external;
1530
1531
1532(*
1533 * LDAP Cancel Extended Operation <draft-zeilenga-ldap-cancel-xx.txt>
1534 *  in cancel.c
1535 *)
1536const
1537  LDAP_API_FEATURE_CANCEL           = 1000;
1538
1539function ldap_cancel(
1540    ld              : PLDAP;
1541    cancelid        : cint;
1542    sctrl           : PPLDAPControl;
1543    cctrl           : PPLDAPControl;
1544    var msgidp      : cint
1545  ): cint; cdecl; external;
1546
1547
1548function ldap_cancel_s(
1549    ld              : PLDAP;
1550    cancelid        : cint;
1551    sctrl           : PPLDAPControl;
1552    cctrl           : PPLDAPControl
1553  ): cint; cdecl; external;
1554
1555
1556(*
1557 * LDAP Server Side Sort
1558 *  in sortctrl.c
1559 *)
1560
1561const
1562  LDAP_API_FEATURE_SERVER_SIDE_SORT = 1000;
1563
1564(* structure for a sort-key *)
1565type
1566  PPLDAPSortKey                     = ^PLDAPSortKey;
1567  PLDAPSortKey                      = ^LDAPSortKey;
1568  LDAPSortKey                       = record
1569    attributeType   : pcchar;
1570    orderingRule    : pcchar;
1571    reverseOrder    : cbool;
1572  end;
1573
1574
1575function ldap_create_sort_keylist(
1576    var sortKeyList : PPLDAPSortKey;
1577    keyString       : pcchar
1578  ): cint; cdecl; external;
1579
1580procedure ldap_free_sort_keylist(
1581    sortKeyList     : PPLDAPSortKey
1582  ); cdecl; external;
1583
1584function ldap_create_sort_control(
1585    ld              : PLDAP;
1586    keyList         : PPLDAPSortKey;
1587    ctl_iscritical  : cbool;
1588    var ctrlp       : PLDAPControl
1589  ): cint; cdecl; external;
1590
1591function ldap_parse_sort_control(
1592    ld              : PLDAP;
1593    ctrlp           : PPLDAPControl;
1594    var result      : culong;
1595    var attribute   : pcchar
1596  ): cint; cdecl; external;
1597
1598
1599(*
1600 * LDAP Virtual List View
1601 *  in vlvctrl.c
1602 *)
1603const
1604  LDAP_API_FEATURE_VIRTUAL_LIST_VIEW = 1000;
1605
1606(* structure for virtual list *)
1607type
1608  PLDAPVLVInfo                      = ^LDAPVLVInfo;
1609  LDAPVLVInfo                       = record
1610    ldvlv_version       : cint;
1611    ldvlv_before_count  : culong;
1612    ldvlv_after_count   : culong;
1613    ldvlv_offset        : culong;
1614    ldvlv_count         : culong;
1615    ldvlv_attrvalue     : PBerval;
1616    ldvlv_context       : PBerval;
1617    ldvlv_extradata     : Pointer;
1618  end;
1619
1620function ldap_create_vlv_control(
1621    ld              : PLDAP;
1622    ldvlistp        : PLDAPVLVInfo;
1623    var ctrlp       : PLDAPControl
1624  ): cint; cdecl; external;
1625
1626function ldap_parse_vlv_control(
1627    ld              : PLDAP;
1628    ctrls           : PPLDAPControl;
1629    var target_posp : culong;
1630    var list_countp : culong;
1631    var contextp    : PBerval;
1632    var errcodep    : cint
1633  ): cint; cdecl; external;
1634
1635
1636(*
1637 * LDAP Transactions
1638 *  in txn.c
1639 *)
1640
1641(*
1642#ifdef LDAP_GROUP_TRANSACTION
1643LDAP_F( int )
1644ldap_parse_txn_create LDAP_P((
1645    LDAP *ld,
1646    LDAPMessage *res,
1647    struct berval **cookie ));
1648
1649LDAP_F( int )
1650ldap_txn_create LDAP_P((
1651    LDAP *ld,
1652    LDAPControl     **sctrls,
1653    LDAPControl     **cctrls,
1654    int             *msgidp ));
1655
1656LDAP_F( int )
1657ldap_txn_create_s LDAP_P((
1658    LDAP *ld,
1659    struct berval **cookie,
1660    LDAPControl **sctrls,
1661    LDAPControl **cctrls ));
1662
1663LDAP_F( int )
1664ldap_txn_end LDAP_P((
1665    LDAP *ld,
1666    struct berval *cookie,
1667    int commit,
1668    LDAPControl     **sctrls,
1669    LDAPControl     **cctrls,
1670    int             *msgidp ));
1671
1672LDAP_F( int )
1673ldap_txn_end_s LDAP_P((
1674    LDAP *ld,
1675    struct berval *cookie,
1676    int commit,
1677    LDAPControl **sctrls,
1678    LDAPControl **cctrls ));
1679#endif*)
1680
1681
1682(*
1683 * LDAP Who Am I?
1684 *  in whoami.c
1685 *)
1686const
1687  LDAP_API_FEATURE_WHOAMI           = 1000;
1688
1689function ldap_parse_whoami(
1690    ld              : PLDAP;
1691    res             : PLDAPMessage;
1692    var authzid     : PBerval
1693  ): cint; cdecl; external;
1694
1695function ldap_whoami(
1696    ld              : PLDAP;
1697    sctrl           : PPLDAPControl;
1698    cctrl           : PPLDAPControl;
1699    var msgidp      : cint
1700  ): cint; cdecl; external;
1701
1702function ldap_whoami_s(
1703    ld              : PLDAP;
1704    var authzid     : PBerval;
1705    sctrl           : PPLDAPControl;
1706    cctrl           : PPLDAPControl
1707  ): cint; cdecl; external;
1708
1709
1710(*
1711 * LDAP Password Modify
1712 *  in passwd.c
1713 *)
1714const
1715  LDAP_API_FEATURE_PASSWD_MODIFY    = 1000;
1716
1717function ldap_parse_passwd(
1718    ld              : PLDAP;
1719    res             : PLDAPMessage;
1720    newpasswd       : PBerval
1721  ): cint; cdecl; external;
1722
1723function ldap_passwd(
1724    ld              : PLDAP;
1725    user            : PBerval;
1726    oldpw           : PBerval;
1727    newpw           : PBerval;
1728    sctrl           : PPLDAPControl;
1729    cctrl           : PPLDAPControl;
1730    var msgidp      : cint
1731  ): cint; cdecl; external;
1732
1733function ldap_passwd_s(
1734    ld              : PLDAP;
1735    user            : PBerval;
1736    oldpw           : PBerval;
1737    newpw           : PBerval;
1738    newpasswd       : PBerval;
1739    sctrl           : PPLDAPControl;
1740    cctrl           : PPLDAPControl
1741  ): cint; cdecl; external;
1742
1743
1744(*
1745 * LDAP Password Policy controls
1746 *  in ppolicy.c
1747 *)
1748
1749(*
1750#ifdef LDAP_CONTROL_PASSWORDPOLICYREQUEST
1751#define LDAP_API_FEATURE_PASSWORD_POLICY 1000
1752
1753typedef enum passpolicyerror_enum {
1754       PP_passwordExpired = 0,
1755       PP_accountLocked = 1,
1756       PP_changeAfterReset = 2,
1757       PP_passwordModNotAllowed = 3,
1758       PP_mustSupplyOldPassword = 4,
1759       PP_insufficientPasswordQuality = 5,
1760       PP_passwordTooShort = 6,
1761       PP_passwordTooYoung = 7,
1762       PP_passwordInHistory = 8,
1763       PP_noError = 65535
1764} LDAPPasswordPolicyError;
1765
1766LDAP_F( int )
1767ldap_create_passwordpolicy_control LDAP_P((
1768        LDAP *ld,
1769        LDAPControl **ctrlp ));
1770
1771LDAP_F( int )
1772ldap_parse_passwordpolicy_control LDAP_P((
1773        LDAP *ld,
1774        LDAPControl *ctrl,
1775        int *expirep,
1776        int *gracep,
1777        LDAPPasswordPolicyError *errorp ));
1778
1779LDAP_F( const cchar * )
1780ldap_passwordpolicy_err2txt LDAP_P(( LDAPPasswordPolicyError ));
1781#endif*)
1782
1783
1784(*
1785 * hacks for NTLM
1786 *)
1787const
1788  LDAP_AUTH_NTLM_REQUEST            = ber_tag_t($8a);
1789  LDAP_AUTH_NTLM_RESPONSE           = ber_tag_t($8b);
1790
1791function ldap_ntlm_bind(
1792    ld              : PLDAP;
1793    const dn        : pcchar;
1794    tag             : ber_tag_t;
1795    cred            : PBerval;
1796    sctrl           : PPLDAPControl;
1797    cctrl           : PPLDAPControl;
1798    var msgidp      : cint
1799  ): cint; cdecl; external;
1800
1801function ldap_parse_ntlm_bind_result(
1802    ld              : PLDAP;
1803    res             : PLDAPMessage;
1804    challenge       : PBerval
1805  ): cint; cdecl; external;
1806