2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 * Copyright 1998-2022 The OpenLDAP Foundation.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted only as authorized by the OpenLDAP
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>.
15 /* Portions Copyright (c) 1990 Regents of the University of Michigan.
16 * All rights reserved.
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.
32 /* include version and API feature defines */
33 #include <ldap_features.h>
37 #define LDAP_VERSION1 1
38 #define LDAP_VERSION2 2
39 #define LDAP_VERSION3 3
41 #define LDAP_VERSION_MIN LDAP_VERSION2
42 #define LDAP_VERSION LDAP_VERSION2
43 #define LDAP_VERSION_MAX LDAP_VERSION3
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).
51 #define LDAP_API_VERSION 3001
52 #define LDAP_VENDOR_NAME "OpenLDAP"
54 /* OpenLDAP API Features */
55 #define LDAP_API_FEATURE_X_OPENLDAP LDAP_VENDOR_VERSION
57 #if defined( LDAP_API_FEATURE_X_OPENLDAP_REENTRANT )
58 # define LDAP_API_FEATURE_THREAD_SAFE 1
60 #if defined( LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE )
61 # define LDAP_API_FEATURE_SESSION_THREAD_SAFE 1
62 # define LDAP_API_FEATURE_OPERATION_THREAD_SAFE 1
66 #define LDAP_PORT 389 /* ldap:/// default LDAP port */
67 #define LDAPS_PORT 636 /* ldaps:/// default LDAP over TLS port */
69 #define LDAP_ROOT_DSE ""
70 #define LDAP_NO_ATTRS "1.1"
71 #define LDAP_ALL_USER_ATTRIBUTES "*"
72 #define LDAP_ALL_OPERATIONAL_ATTRIBUTES "+" /* RFC 3673 */
74 /* RFC 4511: maxInt INTEGER ::= 2147483647 -- (2^^31 - 1) -- */
75 #define LDAP_MAXINT (2147483647)
79 * 0x0000 - 0x0fff reserved for api options
80 * 0x1000 - 0x3fff reserved for api extended options
81 * 0x4000 - 0x7fff reserved for private and experimental options
84 #define LDAP_OPT_API_INFO 0x0000
85 #define LDAP_OPT_DESC 0x0001 /* historic */
86 #define LDAP_OPT_DEREF 0x0002
87 #define LDAP_OPT_SIZELIMIT 0x0003
88 #define LDAP_OPT_TIMELIMIT 0x0004
89 /* 0x05 - 0x07 not defined */
90 #define LDAP_OPT_REFERRALS 0x0008
91 #define LDAP_OPT_RESTART 0x0009
92 /* 0x0a - 0x10 not defined */
93 #define LDAP_OPT_PROTOCOL_VERSION 0x0011
94 #define LDAP_OPT_SERVER_CONTROLS 0x0012
95 #define LDAP_OPT_CLIENT_CONTROLS 0x0013
96 /* 0x14 not defined */
97 #define LDAP_OPT_API_FEATURE_INFO 0x0015
98 /* 0x16 - 0x2f not defined */
99 #define LDAP_OPT_HOST_NAME 0x0030
100 #define LDAP_OPT_RESULT_CODE 0x0031
101 #define LDAP_OPT_ERROR_NUMBER LDAP_OPT_RESULT_CODE
102 #define LDAP_OPT_DIAGNOSTIC_MESSAGE 0x0032
103 #define LDAP_OPT_ERROR_STRING LDAP_OPT_DIAGNOSTIC_MESSAGE
104 #define LDAP_OPT_MATCHED_DN 0x0033
105 /* 0x0034 - 0x3fff not defined */
106 /* 0x0091 used by Microsoft for LDAP_OPT_AUTO_RECONNECT */
107 #define LDAP_OPT_SSPI_FLAGS 0x0092
108 /* 0x0093 used by Microsoft for LDAP_OPT_SSL_INFO */
109 /* 0x0094 used by Microsoft for LDAP_OPT_REF_DEREF_CONN_PER_MSG */
110 #define LDAP_OPT_SIGN 0x0095
111 #define LDAP_OPT_ENCRYPT 0x0096
112 #define LDAP_OPT_SASL_METHOD 0x0097
113 /* 0x0098 used by Microsoft for LDAP_OPT_AREC_EXCLUSIVE */
114 #define LDAP_OPT_SECURITY_CONTEXT 0x0099
115 /* 0x009A used by Microsoft for LDAP_OPT_ROOTDSE_CACHE */
116 /* 0x009B - 0x3fff not defined */
119 #define LDAP_OPT_API_EXTENSION_BASE 0x4000 /* API extensions */
121 /* private and experimental options */
122 /* OpenLDAP specific options */
123 #define LDAP_OPT_DEBUG_LEVEL 0x5001 /* debug level */
124 #define LDAP_OPT_TIMEOUT 0x5002 /* default timeout */
125 #define LDAP_OPT_REFHOPLIMIT 0x5003 /* ref hop limit */
126 #define LDAP_OPT_NETWORK_TIMEOUT 0x5005 /* socket level timeout */
127 #define LDAP_OPT_URI 0x5006
128 #define LDAP_OPT_REFERRAL_URLS 0x5007 /* Referral URLs */
129 #define LDAP_OPT_SOCKBUF 0x5008 /* sockbuf */
130 #define LDAP_OPT_DEFBASE 0x5009 /* searchbase */
131 #define LDAP_OPT_CONNECT_ASYNC 0x5010 /* create connections asynchronously */
132 #define LDAP_OPT_CONNECT_CB 0x5011 /* connection callbacks */
133 #define LDAP_OPT_SESSION_REFCNT 0x5012 /* session reference count */
134 #define LDAP_OPT_KEEPCONN 0x5013 /* keep the connection on read error or NoD */
135 #define LDAP_OPT_SOCKET_BIND_ADDRESSES 0x5014 /* user configured bind IPs */
136 #define LDAP_OPT_TCP_USER_TIMEOUT 0x5015 /* set TCP_USER_TIMEOUT if the OS supports it, ignored otherwise */
138 /* OpenLDAP TLS options */
139 #define LDAP_OPT_X_TLS 0x6000
140 #define LDAP_OPT_X_TLS_CTX 0x6001 /* OpenSSL CTX* */
141 #define LDAP_OPT_X_TLS_CACERTFILE 0x6002
142 #define LDAP_OPT_X_TLS_CACERTDIR 0x6003
143 #define LDAP_OPT_X_TLS_CERTFILE 0x6004
144 #define LDAP_OPT_X_TLS_KEYFILE 0x6005
145 #define LDAP_OPT_X_TLS_REQUIRE_CERT 0x6006
146 #define LDAP_OPT_X_TLS_PROTOCOL_MIN 0x6007
147 #define LDAP_OPT_X_TLS_CIPHER_SUITE 0x6008
148 #define LDAP_OPT_X_TLS_RANDOM_FILE 0x6009
149 #define LDAP_OPT_X_TLS_SSL_CTX 0x600a /* OpenSSL SSL* */
150 #define LDAP_OPT_X_TLS_CRLCHECK 0x600b
151 #define LDAP_OPT_X_TLS_CONNECT_CB 0x600c
152 #define LDAP_OPT_X_TLS_CONNECT_ARG 0x600d
153 #define LDAP_OPT_X_TLS_DHFILE 0x600e
154 #define LDAP_OPT_X_TLS_NEWCTX 0x600f
155 #define LDAP_OPT_X_TLS_CRLFILE 0x6010 /* GNUtls only */
156 #define LDAP_OPT_X_TLS_PACKAGE 0x6011
157 #define LDAP_OPT_X_TLS_ECNAME 0x6012
158 #define LDAP_OPT_X_TLS_VERSION 0x6013 /* read-only */
159 #define LDAP_OPT_X_TLS_CIPHER 0x6014 /* read-only */
160 #define LDAP_OPT_X_TLS_PEERCERT 0x6015 /* read-only */
161 #define LDAP_OPT_X_TLS_CACERT 0x6016
162 #define LDAP_OPT_X_TLS_CERT 0x6017
163 #define LDAP_OPT_X_TLS_KEY 0x6018
164 #define LDAP_OPT_X_TLS_PEERKEY_HASH 0x6019
165 #define LDAP_OPT_X_TLS_REQUIRE_SAN 0x601a
166 #define LDAP_OPT_X_TLS_PROTOCOL_MAX 0x601b
168 #define LDAP_OPT_X_TLS_NEVER 0
169 #define LDAP_OPT_X_TLS_HARD 1
170 #define LDAP_OPT_X_TLS_DEMAND 2
171 #define LDAP_OPT_X_TLS_ALLOW 3
172 #define LDAP_OPT_X_TLS_TRY 4
174 #define LDAP_OPT_X_TLS_CRL_NONE 0
175 #define LDAP_OPT_X_TLS_CRL_PEER 1
176 #define LDAP_OPT_X_TLS_CRL_ALL 2
178 /* for LDAP_OPT_X_TLS_PROTOCOL_MIN/MAX */
179 #define LDAP_OPT_X_TLS_PROTOCOL(maj,min) (((maj) << 8) + (min))
180 #define LDAP_OPT_X_TLS_PROTOCOL_SSL2 (2 << 8)
181 #define LDAP_OPT_X_TLS_PROTOCOL_SSL3 (3 << 8)
182 #define LDAP_OPT_X_TLS_PROTOCOL_TLS1_0 ((3 << 8) + 1)
183 #define LDAP_OPT_X_TLS_PROTOCOL_TLS1_1 ((3 << 8) + 2)
184 #define LDAP_OPT_X_TLS_PROTOCOL_TLS1_2 ((3 << 8) + 3)
185 #define LDAP_OPT_X_TLS_PROTOCOL_TLS1_3 ((3 << 8) + 4)
187 #define LDAP_OPT_X_SASL_CBINDING_NONE 0
188 #define LDAP_OPT_X_SASL_CBINDING_TLS_UNIQUE 1
189 #define LDAP_OPT_X_SASL_CBINDING_TLS_ENDPOINT 2
191 /* OpenLDAP SASL options */
192 #define LDAP_OPT_X_SASL_MECH 0x6100
193 #define LDAP_OPT_X_SASL_REALM 0x6101
194 #define LDAP_OPT_X_SASL_AUTHCID 0x6102
195 #define LDAP_OPT_X_SASL_AUTHZID 0x6103
196 #define LDAP_OPT_X_SASL_SSF 0x6104 /* read-only */
197 #define LDAP_OPT_X_SASL_SSF_EXTERNAL 0x6105 /* write-only */
198 #define LDAP_OPT_X_SASL_SECPROPS 0x6106 /* write-only */
199 #define LDAP_OPT_X_SASL_SSF_MIN 0x6107
200 #define LDAP_OPT_X_SASL_SSF_MAX 0x6108
201 #define LDAP_OPT_X_SASL_MAXBUFSIZE 0x6109
202 #define LDAP_OPT_X_SASL_MECHLIST 0x610a /* read-only */
203 #define LDAP_OPT_X_SASL_NOCANON 0x610b
204 #define LDAP_OPT_X_SASL_USERNAME 0x610c /* read-only */
205 #define LDAP_OPT_X_SASL_GSS_CREDS 0x610d
206 #define LDAP_OPT_X_SASL_CBINDING 0x610e
209 * OpenLDAP per connection tcp-keepalive settings
210 * (Linux only, ignored where unsupported)
212 #define LDAP_OPT_X_KEEPALIVE_IDLE 0x6300
213 #define LDAP_OPT_X_KEEPALIVE_PROBES 0x6301
214 #define LDAP_OPT_X_KEEPALIVE_INTERVAL 0x6302
216 /* Private API Extensions -- reserved for application use */
217 #define LDAP_OPT_PRIVATE_EXTENSION_BASE 0x7000 /* Private API inclusive */
220 * ldap_get_option() and ldap_set_option() return values.
221 * As later versions may return other values indicating
222 * failure, current applications should only compare returned
223 * value against LDAP_OPT_SUCCESS.
225 #define LDAP_OPT_SUCCESS 0
226 #define LDAP_OPT_ERROR (-1)
228 /* option on/off values */
229 #define LDAP_OPT_ON ((void *) &ber_pvt_opt_on)
230 #define LDAP_OPT_OFF ((void *) 0)
232 typedef struct ldapapiinfo
{
233 int ldapai_info_version
; /* version of LDAPAPIInfo */
234 #define LDAP_API_INFO_VERSION (1)
235 int ldapai_api_version
; /* revision of API supported */
236 int ldapai_protocol_version
; /* highest LDAP version supported */
237 char **ldapai_extensions
; /* names of API extensions */
238 char *ldapai_vendor_name
; /* name of supplier */
239 int ldapai_vendor_version
; /* supplier-specific version * 100 */
242 typedef struct ldap_apifeature_info
{
243 int ldapaif_info_version
; /* version of LDAPAPIFeatureInfo */
244 #define LDAP_FEATURE_INFO_VERSION (1) /* apifeature_info struct version */
245 char* ldapaif_name
; /* LDAP_API_FEATURE_* (less prefix) */
246 int ldapaif_version
; /* value of LDAP_API_FEATURE_... */
247 } LDAPAPIFeatureInfo
;
250 * LDAP Control structure
252 typedef struct ldapcontrol
{
253 char * ldctl_oid
; /* numericoid of control */
254 struct berval ldctl_value
; /* encoded value of control */
255 char ldctl_iscritical
; /* criticality */
259 /* standard track controls */
260 #define LDAP_CONTROL_MANAGEDSAIT "2.16.840.1.113730.3.4.2" /* RFC 3296 */
261 #define LDAP_CONTROL_PROXY_AUTHZ "2.16.840.1.113730.3.4.18" /* RFC 4370 */
262 #define LDAP_CONTROL_SUBENTRIES "1.3.6.1.4.1.4203.1.10.1" /* RFC 3672 */
264 #define LDAP_CONTROL_VALUESRETURNFILTER "1.2.826.0.1.3344810.2.3"/* RFC 3876 */
266 #define LDAP_CONTROL_ASSERT "1.3.6.1.1.12" /* RFC 4528 */
267 #define LDAP_CONTROL_PRE_READ "1.3.6.1.1.13.1" /* RFC 4527 */
268 #define LDAP_CONTROL_POST_READ "1.3.6.1.1.13.2" /* RFC 4527 */
270 #define LDAP_CONTROL_SORTREQUEST "1.2.840.113556.1.4.473" /* RFC 2891 */
271 #define LDAP_CONTROL_SORTRESPONSE "1.2.840.113556.1.4.474" /* RFC 2891 */
273 /* non-standard track controls */
274 #define LDAP_CONTROL_PAGEDRESULTS "1.2.840.113556.1.4.319" /* RFC 2696 */
276 #define LDAP_CONTROL_AUTHZID_REQUEST "2.16.840.1.113730.3.4.16" /* RFC 3829 */
277 #define LDAP_CONTROL_AUTHZID_RESPONSE "2.16.840.1.113730.3.4.15" /* RFC 3829 */
279 /* LDAP Content Synchronization Operation -- RFC 4533 */
280 #define LDAP_SYNC_OID "1.3.6.1.4.1.4203.1.9.1"
281 #define LDAP_CONTROL_SYNC LDAP_SYNC_OID ".1"
282 #define LDAP_CONTROL_SYNC_STATE LDAP_SYNC_OID ".2"
283 #define LDAP_CONTROL_SYNC_DONE LDAP_SYNC_OID ".3"
284 #define LDAP_SYNC_INFO LDAP_SYNC_OID ".4"
286 #define LDAP_SYNC_NONE 0x00
287 #define LDAP_SYNC_REFRESH_ONLY 0x01
288 #define LDAP_SYNC_RESERVED 0x02
289 #define LDAP_SYNC_REFRESH_AND_PERSIST 0x03
291 #define LDAP_SYNC_REFRESH_PRESENTS 0
292 #define LDAP_SYNC_REFRESH_DELETES 1
294 #define LDAP_TAG_SYNC_NEW_COOKIE ((ber_tag_t) 0x80U)
295 #define LDAP_TAG_SYNC_REFRESH_DELETE ((ber_tag_t) 0xa1U)
296 #define LDAP_TAG_SYNC_REFRESH_PRESENT ((ber_tag_t) 0xa2U)
297 #define LDAP_TAG_SYNC_ID_SET ((ber_tag_t) 0xa3U)
299 #define LDAP_TAG_SYNC_COOKIE ((ber_tag_t) 0x04U)
300 #define LDAP_TAG_REFRESHDELETES ((ber_tag_t) 0x01U)
301 #define LDAP_TAG_REFRESHDONE ((ber_tag_t) 0x01U)
302 #define LDAP_TAG_RELOAD_HINT ((ber_tag_t) 0x01U)
304 #define LDAP_SYNC_PRESENT 0
305 #define LDAP_SYNC_ADD 1
306 #define LDAP_SYNC_MODIFY 2
307 #define LDAP_SYNC_DELETE 3
308 #define LDAP_SYNC_NEW_COOKIE 4
310 /* LDAP Don't Use Copy Control (RFC 6171) */
311 #define LDAP_CONTROL_DONTUSECOPY "1.3.6.1.1.22"
313 /* Password policy Controls *//* work in progress */
314 /* ITS#3458: released; disabled by default */
315 #define LDAP_CONTROL_PASSWORDPOLICYREQUEST "1.3.6.1.4.1.42.2.27.8.5.1"
316 #define LDAP_CONTROL_PASSWORDPOLICYRESPONSE "1.3.6.1.4.1.42.2.27.8.5.1"
318 /* various works in progress */
319 #define LDAP_CONTROL_NOOP "1.3.6.1.4.1.4203.666.5.2"
320 #define LDAP_CONTROL_NO_SUBORDINATES "1.3.6.1.4.1.4203.666.5.11"
321 #define LDAP_CONTROL_RELAX "1.3.6.1.4.1.4203.666.5.12"
322 #define LDAP_CONTROL_MANAGEDIT LDAP_CONTROL_RELAX
323 #define LDAP_CONTROL_SLURP "1.3.6.1.4.1.4203.666.5.13"
324 #define LDAP_CONTROL_VALSORT "1.3.6.1.4.1.4203.666.5.14"
325 #define LDAP_CONTROL_X_DEREF "1.3.6.1.4.1.4203.666.5.16"
326 #define LDAP_CONTROL_X_WHATFAILED "1.3.6.1.4.1.4203.666.5.17"
328 /* LDAP Chaining Behavior Control *//* work in progress */
329 /* <draft-sermersheim-ldap-chaining>;
330 * see also LDAP_NO_REFERRALS_FOUND, LDAP_CANNOT_CHAIN */
331 #define LDAP_CONTROL_X_CHAINING_BEHAVIOR "1.3.6.1.4.1.4203.666.11.3"
333 #define LDAP_CHAINING_PREFERRED 0
334 #define LDAP_CHAINING_REQUIRED 1
335 #define LDAP_REFERRALS_PREFERRED 2
336 #define LDAP_REFERRALS_REQUIRED 3
338 /* MS Active Directory controls (for compatibility) */
339 #define LDAP_CONTROL_X_LAZY_COMMIT "1.2.840.113556.1.4.619"
340 #define LDAP_CONTROL_X_INCREMENTAL_VALUES "1.2.840.113556.1.4.802"
341 #define LDAP_CONTROL_X_DOMAIN_SCOPE "1.2.840.113556.1.4.1339"
342 #define LDAP_CONTROL_X_PERMISSIVE_MODIFY "1.2.840.113556.1.4.1413"
343 #define LDAP_CONTROL_X_SEARCH_OPTIONS "1.2.840.113556.1.4.1340"
344 #define LDAP_SEARCH_FLAG_DOMAIN_SCOPE 1 /* do not generate referrals */
345 #define LDAP_SEARCH_FLAG_PHANTOM_ROOT 2 /* search all subordinate NCs */
346 #define LDAP_CONTROL_X_TREE_DELETE "1.2.840.113556.1.4.805"
348 /* MS Active Directory controls - not implemented in slapd(8) */
349 #define LDAP_CONTROL_X_SERVER_NOTIFICATION "1.2.840.113556.1.4.528"
350 #define LDAP_CONTROL_X_EXTENDED_DN "1.2.840.113556.1.4.529"
351 #define LDAP_CONTROL_X_SHOW_DELETED "1.2.840.113556.1.4.417"
352 #define LDAP_CONTROL_X_DIRSYNC "1.2.840.113556.1.4.841"
354 #define LDAP_CONTROL_X_DIRSYNC_OBJECT_SECURITY 0x00000001
355 #define LDAP_CONTROL_X_DIRSYNC_ANCESTORS_FIRST 0x00000800
356 #define LDAP_CONTROL_X_DIRSYNC_PUBLIC_DATA_ONLY 0x00002000
357 #define LDAP_CONTROL_X_DIRSYNC_INCREMENTAL_VALUES 0x80000000
360 /* <draft-wahl-ldap-session> */
361 #define LDAP_CONTROL_X_SESSION_TRACKING "1.3.6.1.4.1.21008.108.63.1"
362 #define LDAP_CONTROL_X_SESSION_TRACKING_RADIUS_ACCT_SESSION_ID \
363 LDAP_CONTROL_X_SESSION_TRACKING ".1"
364 #define LDAP_CONTROL_X_SESSION_TRACKING_RADIUS_ACCT_MULTI_SESSION_ID \
365 LDAP_CONTROL_X_SESSION_TRACKING ".2"
366 #define LDAP_CONTROL_X_SESSION_TRACKING_USERNAME \
367 LDAP_CONTROL_X_SESSION_TRACKING ".3"
368 /* various expired works */
370 /* LDAP Duplicated Entry Control Extension *//* not implemented in slapd(8) */
371 #define LDAP_CONTROL_DUPENT_REQUEST "2.16.840.1.113719.1.27.101.1"
372 #define LDAP_CONTROL_DUPENT_RESPONSE "2.16.840.1.113719.1.27.101.2"
373 #define LDAP_CONTROL_DUPENT_ENTRY "2.16.840.1.113719.1.27.101.3"
374 #define LDAP_CONTROL_DUPENT LDAP_CONTROL_DUPENT_REQUEST
376 /* LDAP Persistent Search Control *//* not implemented in slapd(8) */
377 #define LDAP_CONTROL_PERSIST_REQUEST "2.16.840.1.113730.3.4.3"
378 #define LDAP_CONTROL_PERSIST_ENTRY_CHANGE_NOTICE "2.16.840.1.113730.3.4.7"
379 #define LDAP_CONTROL_PERSIST_ENTRY_CHANGE_ADD 0x1
380 #define LDAP_CONTROL_PERSIST_ENTRY_CHANGE_DELETE 0x2
381 #define LDAP_CONTROL_PERSIST_ENTRY_CHANGE_MODIFY 0x4
382 #define LDAP_CONTROL_PERSIST_ENTRY_CHANGE_RENAME 0x8
385 #define LDAP_CONTROL_VLVREQUEST "2.16.840.1.113730.3.4.9"
386 #define LDAP_CONTROL_VLVRESPONSE "2.16.840.1.113730.3.4.10"
388 /* Sun's analogue to ppolicy */
389 #define LDAP_CONTROL_X_ACCOUNT_USABILITY "1.3.6.1.4.1.42.2.27.9.5.8"
391 #define LDAP_TAG_X_ACCOUNT_USABILITY_AVAILABLE ((ber_tag_t) 0x80U) /* primitive + 0 */
392 #define LDAP_TAG_X_ACCOUNT_USABILITY_NOT_AVAILABLE ((ber_tag_t) 0xA1U) /* constructed + 1 */
394 #define LDAP_TAG_X_ACCOUNT_USABILITY_INACTIVE ((ber_tag_t) 0x80U) /* primitive + 0 */
395 #define LDAP_TAG_X_ACCOUNT_USABILITY_RESET ((ber_tag_t) 0x81U) /* primitive + 1 */
396 #define LDAP_TAG_X_ACCOUNT_USABILITY_EXPIRED ((ber_tag_t) 0x82U) /* primitive + 2 */
397 #define LDAP_TAG_X_ACCOUNT_USABILITY_REMAINING_GRACE ((ber_tag_t) 0x83U) /* primitive + 3 */
398 #define LDAP_TAG_X_ACCOUNT_USABILITY_UNTIL_UNLOCK ((ber_tag_t) 0x84U) /* primitive + 4 */
400 /* Netscape Password policy response controls */
401 /* <draft-vchu-ldap-pwd-policy> */
402 #define LDAP_CONTROL_X_PASSWORD_EXPIRED "2.16.840.1.113730.3.4.4"
403 #define LDAP_CONTROL_X_PASSWORD_EXPIRING "2.16.840.1.113730.3.4.5"
405 /* LDAP Unsolicited Notifications */
406 #define LDAP_NOTICE_OF_DISCONNECTION "1.3.6.1.4.1.1466.20036" /* RFC 4511 */
407 #define LDAP_NOTICE_DISCONNECT LDAP_NOTICE_OF_DISCONNECTION
409 /* LDAP Extended Operations */
410 #define LDAP_EXOP_START_TLS "1.3.6.1.4.1.1466.20037" /* RFC 4511 */
412 #define LDAP_EXOP_MODIFY_PASSWD "1.3.6.1.4.1.4203.1.11.1" /* RFC 3062 */
413 #define LDAP_TAG_EXOP_MODIFY_PASSWD_ID ((ber_tag_t) 0x80U)
414 #define LDAP_TAG_EXOP_MODIFY_PASSWD_OLD ((ber_tag_t) 0x81U)
415 #define LDAP_TAG_EXOP_MODIFY_PASSWD_NEW ((ber_tag_t) 0x82U)
416 #define LDAP_TAG_EXOP_MODIFY_PASSWD_GEN ((ber_tag_t) 0x80U)
418 #define LDAP_EXOP_CANCEL "1.3.6.1.1.8" /* RFC 3909 */
419 #define LDAP_EXOP_X_CANCEL LDAP_EXOP_CANCEL
421 #define LDAP_EXOP_REFRESH "1.3.6.1.4.1.1466.101.119.1" /* RFC 2589 */
422 #define LDAP_TAG_EXOP_REFRESH_REQ_DN ((ber_tag_t) 0x80U)
423 #define LDAP_TAG_EXOP_REFRESH_REQ_TTL ((ber_tag_t) 0x81U)
424 #define LDAP_TAG_EXOP_REFRESH_RES_TTL ((ber_tag_t) 0x81U)
426 #define LDAP_EXOP_VERIFY_CREDENTIALS "1.3.6.1.4.1.4203.666.6.5"
427 #define LDAP_EXOP_X_VERIFY_CREDENTIALS LDAP_EXOP_VERIFY_CREDENTIALS
429 #define LDAP_TAG_EXOP_VERIFY_CREDENTIALS_COOKIE ((ber_tag_t) 0x80U)
430 #define LDAP_TAG_EXOP_VERIFY_CREDENTIALS_SCREDS ((ber_tag_t) 0x81U)
431 #define LDAP_TAG_EXOP_VERIFY_CREDENTIALS_CONTROLS ((ber_tag_t) 0xa2U) /* context specific + constructed + 2 */
433 #define LDAP_EXOP_WHO_AM_I "1.3.6.1.4.1.4203.1.11.3" /* RFC 4532 */
434 #define LDAP_EXOP_X_WHO_AM_I LDAP_EXOP_WHO_AM_I
436 /* various works in progress */
437 #define LDAP_EXOP_TURN "1.3.6.1.1.19" /* RFC 4531 */
438 #define LDAP_EXOP_X_TURN LDAP_EXOP_TURN
440 /* LDAP Distributed Procedures <draft-sermersheim-ldap-distproc> */
441 /* a work in progress */
442 #define LDAP_X_DISTPROC_BASE "1.3.6.1.4.1.4203.666.11.6"
443 #define LDAP_EXOP_X_CHAINEDREQUEST LDAP_X_DISTPROC_BASE ".1"
444 #define LDAP_FEATURE_X_CANCHAINOPS LDAP_X_DISTPROC_BASE ".2"
445 #define LDAP_CONTROL_X_RETURNCONTREF LDAP_X_DISTPROC_BASE ".3"
446 #define LDAP_URLEXT_X_LOCALREFOID LDAP_X_DISTPROC_BASE ".4"
447 #define LDAP_URLEXT_X_REFTYPEOID LDAP_X_DISTPROC_BASE ".5"
448 #define LDAP_URLEXT_X_SEARCHEDSUBTREEOID \
449 LDAP_X_DISTPROC_BASE ".6"
450 #define LDAP_URLEXT_X_FAILEDNAMEOID LDAP_X_DISTPROC_BASE ".7"
451 #define LDAP_URLEXT_X_LOCALREF "x-localReference"
452 #define LDAP_URLEXT_X_REFTYPE "x-referenceType"
453 #define LDAP_URLEXT_X_SEARCHEDSUBTREE "x-searchedSubtree"
454 #define LDAP_URLEXT_X_FAILEDNAME "x-failedName"
456 #define LDAP_TXN "1.3.6.1.1.21" /* RFC 5805 */
457 #define LDAP_EXOP_TXN_START LDAP_TXN ".1"
458 #define LDAP_CONTROL_TXN_SPEC LDAP_TXN ".2"
459 #define LDAP_EXOP_TXN_END LDAP_TXN ".3"
460 #define LDAP_EXOP_TXN_ABORTED_NOTICE LDAP_TXN ".4"
463 #define LDAP_FEATURE_ALL_OP_ATTRS "1.3.6.1.4.1.4203.1.5.1" /* RFC 3673 */
464 #define LDAP_FEATURE_OBJECTCLASS_ATTRS \
465 "1.3.6.1.4.1.4203.1.5.2" /* @objectClass - new number to be assigned */
466 #define LDAP_FEATURE_ABSOLUTE_FILTERS "1.3.6.1.4.1.4203.1.5.3" /* (&) (|) */
467 #define LDAP_FEATURE_LANGUAGE_TAG_OPTIONS "1.3.6.1.4.1.4203.1.5.4"
468 #define LDAP_FEATURE_LANGUAGE_RANGE_OPTIONS "1.3.6.1.4.1.4203.1.5.5"
469 #define LDAP_FEATURE_MODIFY_INCREMENT "1.3.6.1.1.14"
471 /* LDAP Experimental (works in progress) Features */
472 #define LDAP_FEATURE_SUBORDINATE_SCOPE \
473 "1.3.6.1.4.1.4203.666.8.1" /* "children" */
474 #define LDAP_FEATURE_CHILDREN_SCOPE LDAP_FEATURE_SUBORDINATE_SCOPE
477 * specific LDAP instantiations of BER types we know about
480 /* Overview of LBER tag construction
487 * 1 0 = CONTEXT-SPECIFIC
494 * | 5 ... 1 | TAG-NUMBER
498 #define LDAP_TAG_MESSAGE ((ber_tag_t) 0x30U) /* constructed + 16 */
499 #define LDAP_TAG_MSGID ((ber_tag_t) 0x02U) /* integer */
501 #define LDAP_TAG_LDAPDN ((ber_tag_t) 0x04U) /* octet string */
502 #define LDAP_TAG_LDAPCRED ((ber_tag_t) 0x04U) /* octet string */
504 #define LDAP_TAG_CONTROLS ((ber_tag_t) 0xa0U) /* context specific + constructed + 0 */
505 #define LDAP_TAG_REFERRAL ((ber_tag_t) 0xa3U) /* context specific + constructed + 3 */
507 #define LDAP_TAG_NEWSUPERIOR ((ber_tag_t) 0x80U) /* context-specific + primitive + 0 */
509 #define LDAP_TAG_EXOP_REQ_OID ((ber_tag_t) 0x80U) /* context specific + primitive */
510 #define LDAP_TAG_EXOP_REQ_VALUE ((ber_tag_t) 0x81U) /* context specific + primitive */
511 #define LDAP_TAG_EXOP_RES_OID ((ber_tag_t) 0x8aU) /* context specific + primitive */
512 #define LDAP_TAG_EXOP_RES_VALUE ((ber_tag_t) 0x8bU) /* context specific + primitive */
514 #define LDAP_TAG_IM_RES_OID ((ber_tag_t) 0x80U) /* context specific + primitive */
515 #define LDAP_TAG_IM_RES_VALUE ((ber_tag_t) 0x81U) /* context specific + primitive */
517 #define LDAP_TAG_SASL_RES_CREDS ((ber_tag_t) 0x87U) /* context specific + primitive */
519 /* LDAP Request Messages */
520 #define LDAP_REQ_BIND ((ber_tag_t) 0x60U) /* application + constructed */
521 #define LDAP_REQ_UNBIND ((ber_tag_t) 0x42U) /* application + primitive */
522 #define LDAP_REQ_SEARCH ((ber_tag_t) 0x63U) /* application + constructed */
523 #define LDAP_REQ_MODIFY ((ber_tag_t) 0x66U) /* application + constructed */
524 #define LDAP_REQ_ADD ((ber_tag_t) 0x68U) /* application + constructed */
525 #define LDAP_REQ_DELETE ((ber_tag_t) 0x4aU) /* application + primitive */
526 #define LDAP_REQ_MODDN ((ber_tag_t) 0x6cU) /* application + constructed */
527 #define LDAP_REQ_MODRDN LDAP_REQ_MODDN
528 #define LDAP_REQ_RENAME LDAP_REQ_MODDN
529 #define LDAP_REQ_COMPARE ((ber_tag_t) 0x6eU) /* application + constructed */
530 #define LDAP_REQ_ABANDON ((ber_tag_t) 0x50U) /* application + primitive */
531 #define LDAP_REQ_EXTENDED ((ber_tag_t) 0x77U) /* application + constructed */
533 /* LDAP Response Messages */
534 #define LDAP_RES_BIND ((ber_tag_t) 0x61U) /* application + constructed */
535 #define LDAP_RES_SEARCH_ENTRY ((ber_tag_t) 0x64U) /* application + constructed */
536 #define LDAP_RES_SEARCH_REFERENCE ((ber_tag_t) 0x73U) /* V3: application + constructed */
537 #define LDAP_RES_SEARCH_RESULT ((ber_tag_t) 0x65U) /* application + constructed */
538 #define LDAP_RES_MODIFY ((ber_tag_t) 0x67U) /* application + constructed */
539 #define LDAP_RES_ADD ((ber_tag_t) 0x69U) /* application + constructed */
540 #define LDAP_RES_DELETE ((ber_tag_t) 0x6bU) /* application + constructed */
541 #define LDAP_RES_MODDN ((ber_tag_t) 0x6dU) /* application + constructed */
542 #define LDAP_RES_MODRDN LDAP_RES_MODDN /* application + constructed */
543 #define LDAP_RES_RENAME LDAP_RES_MODDN /* application + constructed */
544 #define LDAP_RES_COMPARE ((ber_tag_t) 0x6fU) /* application + constructed */
545 #define LDAP_RES_EXTENDED ((ber_tag_t) 0x78U) /* V3: application + constructed */
546 #define LDAP_RES_INTERMEDIATE ((ber_tag_t) 0x79U) /* V3+: application + constructed */
548 #define LDAP_RES_ANY (-1)
549 #define LDAP_RES_UNSOLICITED (0)
553 #define LDAP_SASL_SIMPLE ((char*)0)
554 #define LDAP_SASL_NULL ("")
557 /* authentication methods available */
558 #define LDAP_AUTH_NONE ((ber_tag_t) 0x00U) /* no authentication */
559 #define LDAP_AUTH_SIMPLE ((ber_tag_t) 0x80U) /* context specific + primitive */
560 #define LDAP_AUTH_SASL ((ber_tag_t) 0xa3U) /* context specific + constructed */
561 #define LDAP_AUTH_KRBV4 ((ber_tag_t) 0xffU) /* means do both of the following */
562 #define LDAP_AUTH_KRBV41 ((ber_tag_t) 0x81U) /* context specific + primitive */
563 #define LDAP_AUTH_KRBV42 ((ber_tag_t) 0x82U) /* context specific + primitive */
565 /* used by the Windows API but not used on the wire */
566 #define LDAP_AUTH_NEGOTIATE ((ber_tag_t) 0x04FFU)
569 #define LDAP_FILTER_AND ((ber_tag_t) 0xa0U) /* context specific + constructed */
570 #define LDAP_FILTER_OR ((ber_tag_t) 0xa1U) /* context specific + constructed */
571 #define LDAP_FILTER_NOT ((ber_tag_t) 0xa2U) /* context specific + constructed */
572 #define LDAP_FILTER_EQUALITY ((ber_tag_t) 0xa3U) /* context specific + constructed */
573 #define LDAP_FILTER_SUBSTRINGS ((ber_tag_t) 0xa4U) /* context specific + constructed */
574 #define LDAP_FILTER_GE ((ber_tag_t) 0xa5U) /* context specific + constructed */
575 #define LDAP_FILTER_LE ((ber_tag_t) 0xa6U) /* context specific + constructed */
576 #define LDAP_FILTER_PRESENT ((ber_tag_t) 0x87U) /* context specific + primitive */
577 #define LDAP_FILTER_APPROX ((ber_tag_t) 0xa8U) /* context specific + constructed */
578 #define LDAP_FILTER_EXT ((ber_tag_t) 0xa9U) /* context specific + constructed */
580 /* extended filter component types */
581 #define LDAP_FILTER_EXT_OID ((ber_tag_t) 0x81U) /* context specific */
582 #define LDAP_FILTER_EXT_TYPE ((ber_tag_t) 0x82U) /* context specific */
583 #define LDAP_FILTER_EXT_VALUE ((ber_tag_t) 0x83U) /* context specific */
584 #define LDAP_FILTER_EXT_DNATTRS ((ber_tag_t) 0x84U) /* context specific */
586 /* substring filter component types */
587 #define LDAP_SUBSTRING_INITIAL ((ber_tag_t) 0x80U) /* context specific */
588 #define LDAP_SUBSTRING_ANY ((ber_tag_t) 0x81U) /* context specific */
589 #define LDAP_SUBSTRING_FINAL ((ber_tag_t) 0x82U) /* context specific */
592 #define LDAP_SCOPE_BASE ((ber_int_t) 0x0000)
593 #define LDAP_SCOPE_BASEOBJECT LDAP_SCOPE_BASE
594 #define LDAP_SCOPE_ONELEVEL ((ber_int_t) 0x0001)
595 #define LDAP_SCOPE_ONE LDAP_SCOPE_ONELEVEL
596 #define LDAP_SCOPE_SUBTREE ((ber_int_t) 0x0002)
597 #define LDAP_SCOPE_SUB LDAP_SCOPE_SUBTREE
598 #define LDAP_SCOPE_SUBORDINATE ((ber_int_t) 0x0003) /* OpenLDAP extension */
599 #define LDAP_SCOPE_CHILDREN LDAP_SCOPE_SUBORDINATE
600 #define LDAP_SCOPE_DEFAULT ((ber_int_t) -1) /* OpenLDAP extension */
602 /* substring filter component types */
603 #define LDAP_SUBSTRING_INITIAL ((ber_tag_t) 0x80U) /* context specific */
604 #define LDAP_SUBSTRING_ANY ((ber_tag_t) 0x81U) /* context specific */
605 #define LDAP_SUBSTRING_FINAL ((ber_tag_t) 0x82U) /* context specific */
610 #define LDAP_SUCCESS 0x00
612 #define LDAP_RANGE(n,x,y) (((x) <= (n)) && ((n) <= (y)))
614 #define LDAP_OPERATIONS_ERROR 0x01
615 #define LDAP_PROTOCOL_ERROR 0x02
616 #define LDAP_TIMELIMIT_EXCEEDED 0x03
617 #define LDAP_SIZELIMIT_EXCEEDED 0x04
618 #define LDAP_COMPARE_FALSE 0x05
619 #define LDAP_COMPARE_TRUE 0x06
620 #define LDAP_AUTH_METHOD_NOT_SUPPORTED 0x07
621 #define LDAP_STRONG_AUTH_NOT_SUPPORTED LDAP_AUTH_METHOD_NOT_SUPPORTED
622 #define LDAP_STRONG_AUTH_REQUIRED 0x08
623 #define LDAP_STRONGER_AUTH_REQUIRED LDAP_STRONG_AUTH_REQUIRED
624 #define LDAP_PARTIAL_RESULTS 0x09 /* LDAPv2+ (not LDAPv3) */
626 #define LDAP_REFERRAL 0x0a /* LDAPv3 */
627 #define LDAP_ADMINLIMIT_EXCEEDED 0x0b /* LDAPv3 */
628 #define LDAP_UNAVAILABLE_CRITICAL_EXTENSION 0x0c /* LDAPv3 */
629 #define LDAP_CONFIDENTIALITY_REQUIRED 0x0d /* LDAPv3 */
630 #define LDAP_SASL_BIND_IN_PROGRESS 0x0e /* LDAPv3 */
632 #define LDAP_ATTR_ERROR(n) LDAP_RANGE((n),0x10,0x15) /* 16-21 */
634 #define LDAP_NO_SUCH_ATTRIBUTE 0x10
635 #define LDAP_UNDEFINED_TYPE 0x11
636 #define LDAP_INAPPROPRIATE_MATCHING 0x12
637 #define LDAP_CONSTRAINT_VIOLATION 0x13
638 #define LDAP_TYPE_OR_VALUE_EXISTS 0x14
639 #define LDAP_INVALID_SYNTAX 0x15
641 #define LDAP_NAME_ERROR(n) LDAP_RANGE((n),0x20,0x24) /* 32-34,36 */
643 #define LDAP_NO_SUCH_OBJECT 0x20
644 #define LDAP_ALIAS_PROBLEM 0x21
645 #define LDAP_INVALID_DN_SYNTAX 0x22
646 #define LDAP_IS_LEAF 0x23 /* not LDAPv3 */
647 #define LDAP_ALIAS_DEREF_PROBLEM 0x24
649 #define LDAP_SECURITY_ERROR(n) LDAP_RANGE((n),0x2F,0x32) /* 47-50 */
651 #define LDAP_X_PROXY_AUTHZ_FAILURE 0x2F /* LDAPv3 proxy authorization */
652 #define LDAP_INAPPROPRIATE_AUTH 0x30
653 #define LDAP_INVALID_CREDENTIALS 0x31
654 #define LDAP_INSUFFICIENT_ACCESS 0x32
656 #define LDAP_SERVICE_ERROR(n) LDAP_RANGE((n),0x33,0x36) /* 51-54 */
658 #define LDAP_BUSY 0x33
659 #define LDAP_UNAVAILABLE 0x34
660 #define LDAP_UNWILLING_TO_PERFORM 0x35
661 #define LDAP_LOOP_DETECT 0x36
663 #define LDAP_UPDATE_ERROR(n) LDAP_RANGE((n),0x40,0x47) /* 64-69,71 */
665 #define LDAP_NAMING_VIOLATION 0x40
666 #define LDAP_OBJECT_CLASS_VIOLATION 0x41
667 #define LDAP_NOT_ALLOWED_ON_NONLEAF 0x42
668 #define LDAP_NOT_ALLOWED_ON_RDN 0x43
669 #define LDAP_ALREADY_EXISTS 0x44
670 #define LDAP_NO_OBJECT_CLASS_MODS 0x45
671 #define LDAP_RESULTS_TOO_LARGE 0x46 /* CLDAP */
672 #define LDAP_AFFECTS_MULTIPLE_DSAS 0x47
674 #define LDAP_VLV_ERROR 0x4C
676 #define LDAP_OTHER 0x50
678 /* LCUP operation codes (113-117) - not implemented */
679 #define LDAP_CUP_RESOURCES_EXHAUSTED 0x71
680 #define LDAP_CUP_SECURITY_VIOLATION 0x72
681 #define LDAP_CUP_INVALID_DATA 0x73
682 #define LDAP_CUP_UNSUPPORTED_SCHEME 0x74
683 #define LDAP_CUP_RELOAD_REQUIRED 0x75
685 /* Cancel operation codes (118-121) */
686 #define LDAP_CANCELLED 0x76
687 #define LDAP_NO_SUCH_OPERATION 0x77
688 #define LDAP_TOO_LATE 0x78
689 #define LDAP_CANNOT_CANCEL 0x79
691 /* Assertion control (122) */
692 #define LDAP_ASSERTION_FAILED 0x7A
694 /* Proxied Authorization Denied (123) */
695 #define LDAP_PROXIED_AUTHORIZATION_DENIED 0x7B
697 /* Experimental result codes */
698 #define LDAP_E_ERROR(n) LDAP_RANGE((n),0x1000,0x3FFF)
700 /* LDAP Sync (4096) */
701 #define LDAP_SYNC_REFRESH_REQUIRED 0x1000
704 /* Private Use result codes */
705 #define LDAP_X_ERROR(n) LDAP_RANGE((n),0x4000,0xFFFF)
707 #define LDAP_X_SYNC_REFRESH_REQUIRED 0x4100 /* defunct */
708 #define LDAP_X_ASSERTION_FAILED 0x410f /* defunct */
710 /* for the LDAP No-Op control */
711 #define LDAP_X_NO_OPERATION 0x410e
713 /* for the Chaining Behavior control (consecutive result codes requested;
714 * see <draft-sermersheim-ldap-chaining> ) */
715 #ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
716 #define LDAP_X_NO_REFERRALS_FOUND 0x4110
717 #define LDAP_X_CANNOT_CHAIN 0x4111
720 /* for Distributed Procedures (see <draft-sermersheim-ldap-distproc>) */
721 #ifdef LDAP_X_DISTPROC_BASE
722 #define LDAP_X_INVALIDREFERENCE 0x4112
725 #define LDAP_TXN_SPECIFY_OKAY 0x4120
726 #define LDAP_TXN_ID_INVALID 0x4121
730 * Based on draft-ietf-ldap-c-api-xx
731 * but with new negative code values
733 #define LDAP_API_ERROR(n) ((n)<0)
734 #define LDAP_API_RESULT(n) ((n)<=0)
736 #define LDAP_SERVER_DOWN (-1)
737 #define LDAP_LOCAL_ERROR (-2)
738 #define LDAP_ENCODING_ERROR (-3)
739 #define LDAP_DECODING_ERROR (-4)
740 #define LDAP_TIMEOUT (-5)
741 #define LDAP_AUTH_UNKNOWN (-6)
742 #define LDAP_FILTER_ERROR (-7)
743 #define LDAP_USER_CANCELLED (-8)
744 #define LDAP_PARAM_ERROR (-9)
745 #define LDAP_NO_MEMORY (-10)
746 #define LDAP_CONNECT_ERROR (-11)
747 #define LDAP_NOT_SUPPORTED (-12)
748 #define LDAP_CONTROL_NOT_FOUND (-13)
749 #define LDAP_NO_RESULTS_RETURNED (-14)
750 #define LDAP_MORE_RESULTS_TO_RETURN (-15) /* Obsolete */
751 #define LDAP_CLIENT_LOOP (-16)
752 #define LDAP_REFERRAL_LIMIT_EXCEEDED (-17)
753 #define LDAP_X_CONNECTING (-18)
757 * This structure represents both ldap messages and ldap responses.
758 * These are really the same, except in the case of search responses,
759 * where a response has multiple messages.
762 typedef struct ldapmsg LDAPMessage
;
764 /* for modifications */
765 typedef struct ldapmod
{
768 #define LDAP_MOD_OP (0x0007)
769 #define LDAP_MOD_ADD (0x0000)
770 #define LDAP_MOD_DELETE (0x0001)
771 #define LDAP_MOD_REPLACE (0x0002)
772 #define LDAP_MOD_INCREMENT (0x0003) /* OpenLDAP extension */
773 #define LDAP_MOD_BVALUES (0x0080)
774 /* IMPORTANT: do not use code 0x1000 (or above),
775 * it is used internally by the backends!
776 * (see ldap/servers/slapd/slap.h)
782 struct berval
**modv_bvals
;
784 #define mod_values mod_vals.modv_strvals
785 #define mod_bvalues mod_vals.modv_bvals
789 * structure representing an ldap session which can
790 * encompass connections to multiple servers (in the
791 * face of referrals).
793 typedef struct ldap LDAP
;
795 #define LDAP_DEREF_NEVER 0x00
796 #define LDAP_DEREF_SEARCHING 0x01
797 #define LDAP_DEREF_FINDING 0x02
798 #define LDAP_DEREF_ALWAYS 0x03
800 #define LDAP_NO_LIMIT 0
802 /* how many messages to retrieve results for */
803 #define LDAP_MSG_ONE 0x00
804 #define LDAP_MSG_ALL 0x01
805 #define LDAP_MSG_RECEIVED 0x02
808 * types for ldap URL handling
810 typedef struct ldap_url_desc
{
811 struct ldap_url_desc
*lud_next
;
823 #define LDAP_URL_SUCCESS 0x00 /* Success */
824 #define LDAP_URL_ERR_MEM 0x01 /* can't allocate memory space */
825 #define LDAP_URL_ERR_PARAM 0x02 /* parameter is bad */
827 #define LDAP_URL_ERR_BADSCHEME 0x03 /* URL doesn't begin with "ldap[si]://" */
828 #define LDAP_URL_ERR_BADENCLOSURE 0x04 /* URL is missing trailing ">" */
829 #define LDAP_URL_ERR_BADURL 0x05 /* URL is bad */
830 #define LDAP_URL_ERR_BADHOST 0x06 /* host port is bad */
831 #define LDAP_URL_ERR_BADATTRS 0x07 /* bad (or missing) attributes */
832 #define LDAP_URL_ERR_BADSCOPE 0x08 /* scope string is invalid (or missing) */
833 #define LDAP_URL_ERR_BADFILTER 0x09 /* bad or missing filter */
834 #define LDAP_URL_ERR_BADEXTS 0x0a /* bad or missing extensions */
837 * LDAP sync (RFC4533) API
840 typedef struct ldap_sync_t ldap_sync_t
;
843 /* these are private - the client should never see them */
844 LDAP_SYNC_CAPI_NONE
= -1,
846 LDAP_SYNC_CAPI_PHASE_FLAG
= 0x10U
,
847 LDAP_SYNC_CAPI_IDSET_FLAG
= 0x20U
,
848 LDAP_SYNC_CAPI_DONE_FLAG
= 0x40U
,
850 /* these are passed to ls_search_entry() */
851 LDAP_SYNC_CAPI_PRESENT
= LDAP_SYNC_PRESENT
,
852 LDAP_SYNC_CAPI_ADD
= LDAP_SYNC_ADD
,
853 LDAP_SYNC_CAPI_MODIFY
= LDAP_SYNC_MODIFY
,
854 LDAP_SYNC_CAPI_DELETE
= LDAP_SYNC_DELETE
,
856 /* these are passed to ls_intermediate() */
857 LDAP_SYNC_CAPI_PRESENTS
= ( LDAP_SYNC_CAPI_PHASE_FLAG
| LDAP_SYNC_CAPI_PRESENT
),
858 LDAP_SYNC_CAPI_DELETES
= ( LDAP_SYNC_CAPI_PHASE_FLAG
| LDAP_SYNC_CAPI_DELETE
),
860 LDAP_SYNC_CAPI_PRESENTS_IDSET
= ( LDAP_SYNC_CAPI_PRESENTS
| LDAP_SYNC_CAPI_IDSET_FLAG
),
861 LDAP_SYNC_CAPI_DELETES_IDSET
= ( LDAP_SYNC_CAPI_DELETES
| LDAP_SYNC_CAPI_IDSET_FLAG
),
863 LDAP_SYNC_CAPI_DONE
= ( LDAP_SYNC_CAPI_DONE_FLAG
| LDAP_SYNC_CAPI_PRESENTS
)
864 } ldap_sync_refresh_t
;
867 * Called when an entry is returned by ldap_result().
868 * If phase is LDAP_SYNC_CAPI_ADD or LDAP_SYNC_CAPI_MODIFY,
869 * the entry has been either added or modified, and thus
870 * the complete view of the entry should be in the LDAPMessage.
871 * If phase is LDAP_SYNC_CAPI_PRESENT or LDAP_SYNC_CAPI_DELETE,
872 * only the DN should be in the LDAPMessage.
874 typedef int (*ldap_sync_search_entry_f
) LDAP_P((
877 struct berval
*entryUUID
,
878 ldap_sync_refresh_t phase
));
881 * Called when a reference is returned; the client should know
882 * what to do with it.
884 typedef int (*ldap_sync_search_reference_f
) LDAP_P((
889 * Called when specific intermediate/final messages are returned.
890 * If phase is LDAP_SYNC_CAPI_PRESENTS or LDAP_SYNC_CAPI_DELETES,
891 * a "presents" or "deletes" phase begins.
892 * If phase is LDAP_SYNC_CAPI_DONE, a special "presents" phase
893 * with refreshDone set to "TRUE" has been returned, to indicate
894 * that the refresh phase of a refreshAndPersist is complete.
895 * In the above cases, syncUUIDs is NULL.
897 * If phase is LDAP_SYNC_CAPI_PRESENTS_IDSET or
898 * LDAP_SYNC_CAPI_DELETES_IDSET, syncUUIDs is an array of UUIDs
899 * that are either present or have been deleted.
901 typedef int (*ldap_sync_intermediate_f
) LDAP_P((
905 ldap_sync_refresh_t phase
));
908 * Called when a searchResultDone is returned. In refreshAndPersist,
909 * this can only occur if the search for any reason is being terminated
912 typedef int (*ldap_sync_search_result_f
) LDAP_P((
915 int refreshDeletes
));
918 * This structure contains all information about the persistent search;
919 * the caller is responsible for connecting, setting version, binding, tls...
922 /* conf search params */
933 /* helpers - add as appropriate */
934 ldap_sync_search_entry_f ls_search_entry
;
935 ldap_sync_search_reference_f ls_search_reference
;
936 ldap_sync_intermediate_f ls_intermediate
;
937 ldap_sync_search_result_f ls_search_result
;
939 /* set by the caller as appropriate */
945 /* --- the parameters below are private - do not modify --- */
947 /* FIXME: make the structure opaque, and provide an interface
948 * to modify the public values? */
954 /* needed by refreshOnly */
957 /* opaque - need to pass between sessions, updated by the API */
958 struct berval ls_cookie
;
960 /* state variable - do not modify */
961 ldap_sync_refresh_t ls_refreshPhase
;
965 * End of LDAP sync (RFC4533) API
969 * Connection callbacks...
974 /* Called after a connection is established */
975 typedef int (ldap_conn_add_f
) LDAP_P(( LDAP
*ld
, Sockbuf
*sb
, LDAPURLDesc
*srv
, struct sockaddr
*addr
,
976 struct ldap_conncb
*ctx
));
977 /* Called before a connection is closed */
978 typedef void (ldap_conn_del_f
) LDAP_P(( LDAP
*ld
, Sockbuf
*sb
, struct ldap_conncb
*ctx
));
980 /* Callbacks are pushed on a stack. Last one pushed is first one executed. The
981 * delete callback is called with a NULL Sockbuf just before freeing the LDAP handle.
983 typedef struct ldap_conncb
{
984 ldap_conn_add_f
*lc_add
;
985 ldap_conn_del_f
*lc_del
;
990 * The API draft spec says we should declare (or cause to be declared)
991 * 'struct timeval'. We don't. See IETF LDAPext discussions.
999 ldap_get_option
LDAP_P((
1005 ldap_set_option
LDAP_P((
1008 LDAP_CONST
void *invalue
));
1010 /* V3 REBIND Function Callback Prototype */
1011 typedef int (LDAP_REBIND_PROC
) LDAP_P((
1012 LDAP
*ld
, LDAP_CONST
char *url
,
1013 ber_tag_t request
, ber_int_t msgid
,
1017 ldap_set_rebind_proc
LDAP_P((
1019 LDAP_REBIND_PROC
*rebind_proc
,
1022 /* V3 referral selection Function Callback Prototype */
1023 typedef int (LDAP_NEXTREF_PROC
) LDAP_P((
1024 LDAP
*ld
, char ***refsp
, int *cntp
,
1028 ldap_set_nextref_proc
LDAP_P((
1030 LDAP_NEXTREF_PROC
*nextref_proc
,
1033 /* V3 URLLIST Function Callback Prototype */
1034 typedef int (LDAP_URLLIST_PROC
) LDAP_P((
1036 LDAPURLDesc
**urllist
,
1041 ldap_set_urllist_proc
LDAP_P((
1043 LDAP_URLLIST_PROC
*urllist_proc
,
1051 ldap_create_control
LDAP_P(( /* deprecated, use ldap_control_create */
1052 LDAP_CONST
char *requestOID
,
1055 LDAPControl
**ctrlp
));
1057 LDAP_F( LDAPControl
* )
1058 ldap_find_control
LDAP_P(( /* deprecated, use ldap_control_find */
1059 LDAP_CONST
char *oid
,
1060 LDAPControl
**ctrls
));
1064 ldap_control_create
LDAP_P((
1065 LDAP_CONST
char *requestOID
,
1067 struct berval
*value
,
1069 LDAPControl
**ctrlp
));
1071 LDAP_F( LDAPControl
* )
1072 ldap_control_find
LDAP_P((
1073 LDAP_CONST
char *oid
,
1074 LDAPControl
**ctrls
,
1075 LDAPControl
***nextctrlp
));
1078 ldap_control_free
LDAP_P((
1079 LDAPControl
*ctrl
));
1082 ldap_controls_free
LDAP_P((
1083 LDAPControl
**ctrls
));
1085 LDAP_F( LDAPControl
** )
1086 ldap_controls_dup
LDAP_P((
1087 LDAPControl
*LDAP_CONST
*controls
));
1089 LDAP_F( LDAPControl
* )
1090 ldap_control_dup
LDAP_P((
1091 LDAP_CONST LDAPControl
*c
));
1097 ldap_domain2dn
LDAP_P((
1098 LDAP_CONST
char* domain
,
1102 ldap_dn2domain
LDAP_P((
1103 LDAP_CONST
char* dn
,
1107 ldap_domain2hostlist
LDAP_P((
1108 LDAP_CONST
char *domain
,
1115 ldap_extended_operation
LDAP_P((
1117 LDAP_CONST
char *reqoid
,
1118 struct berval
*reqdata
,
1119 LDAPControl
**serverctrls
,
1120 LDAPControl
**clientctrls
,
1124 ldap_extended_operation_s
LDAP_P((
1126 LDAP_CONST
char *reqoid
,
1127 struct berval
*reqdata
,
1128 LDAPControl
**serverctrls
,
1129 LDAPControl
**clientctrls
,
1131 struct berval
**retdatap
));
1134 ldap_parse_extended_result
LDAP_P((
1138 struct berval
**retdatap
,
1142 ldap_parse_intermediate
LDAP_P((
1146 struct berval
**retdatap
,
1147 LDAPControl
***serverctrls
,
1155 ldap_abandon_ext
LDAP_P((
1158 LDAPControl
**serverctrls
,
1159 LDAPControl
**clientctrls
));
1163 ldap_abandon
LDAP_P(( /* deprecated, use ldap_abandon_ext */
1172 ldap_add_ext
LDAP_P((
1174 LDAP_CONST
char *dn
,
1176 LDAPControl
**serverctrls
,
1177 LDAPControl
**clientctrls
,
1181 ldap_add_ext_s
LDAP_P((
1183 LDAP_CONST
char *dn
,
1185 LDAPControl
**serverctrls
,
1186 LDAPControl
**clientctrls
));
1190 ldap_add
LDAP_P(( /* deprecated, use ldap_add_ext */
1192 LDAP_CONST
char *dn
,
1196 ldap_add_s
LDAP_P(( /* deprecated, use ldap_add_ext_s */
1198 LDAP_CONST
char *dn
,
1207 ldap_sasl_bind
LDAP_P((
1209 LDAP_CONST
char *dn
,
1210 LDAP_CONST
char *mechanism
,
1211 struct berval
*cred
,
1212 LDAPControl
**serverctrls
,
1213 LDAPControl
**clientctrls
,
1216 /* Interaction flags (should be passed about in a control)
1217 * Automatic (default): use defaults, prompt otherwise
1218 * Interactive: prompt always
1219 * Quiet: never prompt
1221 #define LDAP_SASL_AUTOMATIC 0U
1222 #define LDAP_SASL_INTERACTIVE 1U
1223 #define LDAP_SASL_QUIET 2U
1226 * V3 SASL Interaction Function Callback Prototype
1227 * when using Cyrus SASL, interact is pointer to sasl_interact_t
1228 * should likely passed in a control (and provided controls)
1230 typedef int (LDAP_SASL_INTERACT_PROC
) LDAP_P((
1231 LDAP
*ld
, unsigned flags
, void* defaults
, void *interact
));
1234 ldap_sasl_interactive_bind
LDAP_P((
1236 LDAP_CONST
char *dn
, /* usually NULL */
1237 LDAP_CONST
char *saslMechanism
,
1238 LDAPControl
**serverControls
,
1239 LDAPControl
**clientControls
,
1241 /* should be client controls */
1243 LDAP_SASL_INTERACT_PROC
*proc
,
1246 /* as obtained from ldap_result() */
1247 LDAPMessage
*result
,
1249 /* returned during bind processing */
1254 ldap_sasl_interactive_bind_s
LDAP_P((
1256 LDAP_CONST
char *dn
, /* usually NULL */
1257 LDAP_CONST
char *saslMechanism
,
1258 LDAPControl
**serverControls
,
1259 LDAPControl
**clientControls
,
1261 /* should be client controls */
1263 LDAP_SASL_INTERACT_PROC
*proc
,
1267 ldap_sasl_bind_s
LDAP_P((
1269 LDAP_CONST
char *dn
,
1270 LDAP_CONST
char *mechanism
,
1271 struct berval
*cred
,
1272 LDAPControl
**serverctrls
,
1273 LDAPControl
**clientctrls
,
1274 struct berval
**servercredp
));
1277 ldap_parse_sasl_bind_result
LDAP_P((
1280 struct berval
**servercredp
,
1289 ldap_bind
LDAP_P(( /* deprecated, use ldap_sasl_bind */
1291 LDAP_CONST
char *who
,
1292 LDAP_CONST
char *passwd
,
1296 ldap_bind_s
LDAP_P(( /* deprecated, use ldap_sasl_bind_s */
1298 LDAP_CONST
char *who
,
1299 LDAP_CONST
char *cred
,
1306 ldap_simple_bind
LDAP_P(( /* deprecated, use ldap_sasl_bind */
1308 LDAP_CONST
char *who
,
1309 LDAP_CONST
char *passwd
));
1312 ldap_simple_bind_s
LDAP_P(( /* deprecated, use ldap_sasl_bind_s */
1314 LDAP_CONST
char *who
,
1315 LDAP_CONST
char *passwd
));
1324 ldap_compare_ext
LDAP_P((
1326 LDAP_CONST
char *dn
,
1327 LDAP_CONST
char *attr
,
1328 struct berval
*bvalue
,
1329 LDAPControl
**serverctrls
,
1330 LDAPControl
**clientctrls
,
1334 ldap_compare_ext_s
LDAP_P((
1336 LDAP_CONST
char *dn
,
1337 LDAP_CONST
char *attr
,
1338 struct berval
*bvalue
,
1339 LDAPControl
**serverctrls
,
1340 LDAPControl
**clientctrls
));
1344 ldap_compare
LDAP_P(( /* deprecated, use ldap_compare_ext */
1346 LDAP_CONST
char *dn
,
1347 LDAP_CONST
char *attr
,
1348 LDAP_CONST
char *value
));
1351 ldap_compare_s
LDAP_P(( /* deprecated, use ldap_compare_ext_s */
1353 LDAP_CONST
char *dn
,
1354 LDAP_CONST
char *attr
,
1355 LDAP_CONST
char *value
));
1363 ldap_delete_ext
LDAP_P((
1365 LDAP_CONST
char *dn
,
1366 LDAPControl
**serverctrls
,
1367 LDAPControl
**clientctrls
,
1371 ldap_delete_ext_s
LDAP_P((
1373 LDAP_CONST
char *dn
,
1374 LDAPControl
**serverctrls
,
1375 LDAPControl
**clientctrls
));
1379 ldap_delete
LDAP_P(( /* deprecated, use ldap_delete_ext */
1381 LDAP_CONST
char *dn
));
1384 ldap_delete_s
LDAP_P(( /* deprecated, use ldap_delete_ext_s */
1386 LDAP_CONST
char *dn
));
1394 ldap_parse_result
LDAP_P((
1401 LDAPControl
***serverctrls
,
1405 ldap_err2string
LDAP_P((
1410 ldap_result2error
LDAP_P(( /* deprecated, use ldap_parse_result */
1416 ldap_perror
LDAP_P(( /* deprecated, use ldap_err2string */
1418 LDAP_CONST
char *s
));
1426 ldap_modify_ext
LDAP_P((
1428 LDAP_CONST
char *dn
,
1430 LDAPControl
**serverctrls
,
1431 LDAPControl
**clientctrls
,
1435 ldap_modify_ext_s
LDAP_P((
1437 LDAP_CONST
char *dn
,
1439 LDAPControl
**serverctrls
,
1440 LDAPControl
**clientctrls
));
1444 ldap_modify
LDAP_P(( /* deprecated, use ldap_modify_ext */
1446 LDAP_CONST
char *dn
,
1450 ldap_modify_s
LDAP_P(( /* deprecated, use ldap_modify_ext_s */
1452 LDAP_CONST
char *dn
,
1461 ldap_rename
LDAP_P((
1463 LDAP_CONST
char *dn
,
1464 LDAP_CONST
char *newrdn
,
1465 LDAP_CONST
char *newSuperior
,
1467 LDAPControl
**sctrls
,
1468 LDAPControl
**cctrls
,
1472 ldap_rename_s
LDAP_P((
1474 LDAP_CONST
char *dn
,
1475 LDAP_CONST
char *newrdn
,
1476 LDAP_CONST
char *newSuperior
,
1478 LDAPControl
**sctrls
,
1479 LDAPControl
**cctrls
));
1483 ldap_rename2
LDAP_P(( /* deprecated, use ldap_rename */
1485 LDAP_CONST
char *dn
,
1486 LDAP_CONST
char *newrdn
,
1487 LDAP_CONST
char *newSuperior
,
1488 int deleteoldrdn
));
1491 ldap_rename2_s
LDAP_P(( /* deprecated, use ldap_rename_s */
1493 LDAP_CONST
char *dn
,
1494 LDAP_CONST
char *newrdn
,
1495 LDAP_CONST
char *newSuperior
,
1496 int deleteoldrdn
));
1499 ldap_modrdn
LDAP_P(( /* deprecated, use ldap_rename */
1501 LDAP_CONST
char *dn
,
1502 LDAP_CONST
char *newrdn
));
1505 ldap_modrdn_s
LDAP_P(( /* deprecated, use ldap_rename_s */
1507 LDAP_CONST
char *dn
,
1508 LDAP_CONST
char *newrdn
));
1511 ldap_modrdn2
LDAP_P(( /* deprecated, use ldap_rename */
1513 LDAP_CONST
char *dn
,
1514 LDAP_CONST
char *newrdn
,
1515 int deleteoldrdn
));
1518 ldap_modrdn2_s
LDAP_P(( /* deprecated, use ldap_rename_s */
1520 LDAP_CONST
char *dn
,
1521 LDAP_CONST
char *newrdn
,
1531 ldap_init
LDAP_P(( /* deprecated, use ldap_create or ldap_initialize */
1532 LDAP_CONST
char *host
,
1536 ldap_open
LDAP_P(( /* deprecated, use ldap_create or ldap_initialize */
1537 LDAP_CONST
char *host
,
1542 ldap_create
LDAP_P((
1546 ldap_initialize
LDAP_P((
1548 LDAP_CONST
char *url
));
1555 ldap_connect( LDAP
*ld
);
1562 ldap_tls_inplace
LDAP_P((
1566 ldap_start_tls
LDAP_P((
1568 LDAPControl
**serverctrls
,
1569 LDAPControl
**clientctrls
,
1573 ldap_install_tls
LDAP_P((
1577 ldap_start_tls_s
LDAP_P((
1579 LDAPControl
**serverctrls
,
1580 LDAPControl
**clientctrls
));
1585 LDAP_F( LDAPMessage
* )
1586 ldap_first_message
LDAP_P((
1588 LDAPMessage
*chain
));
1590 LDAP_F( LDAPMessage
* )
1591 ldap_next_message
LDAP_P((
1593 LDAPMessage
*msg
));
1596 ldap_count_messages
LDAP_P((
1598 LDAPMessage
*chain
));
1603 LDAP_F( LDAPMessage
* )
1604 ldap_first_reference
LDAP_P((
1606 LDAPMessage
*chain
));
1608 LDAP_F( LDAPMessage
* )
1609 ldap_next_reference
LDAP_P((
1611 LDAPMessage
*ref
));
1614 ldap_count_references
LDAP_P((
1616 LDAPMessage
*chain
));
1619 ldap_parse_reference
LDAP_P((
1623 LDAPControl
***serverctrls
,
1630 LDAP_F( LDAPMessage
* )
1631 ldap_first_entry
LDAP_P((
1633 LDAPMessage
*chain
));
1635 LDAP_F( LDAPMessage
* )
1636 ldap_next_entry
LDAP_P((
1638 LDAPMessage
*entry
));
1641 ldap_count_entries
LDAP_P((
1643 LDAPMessage
*chain
));
1646 ldap_get_entry_controls
LDAP_P((
1649 LDAPControl
***serverctrls
));
1655 LDAP_F( LDAPMessage
* )
1656 ldap_delete_result_entry
LDAP_P((
1661 ldap_add_result_entry
LDAP_P((
1670 ldap_get_dn
LDAP_P((
1672 LDAPMessage
*entry
));
1674 typedef struct ldap_ava
{
1675 struct berval la_attr
;
1676 struct berval la_value
;
1678 #define LDAP_AVA_NULL 0x0000U
1679 #define LDAP_AVA_STRING 0x0001U
1680 #define LDAP_AVA_BINARY 0x0002U
1681 #define LDAP_AVA_NONPRINTABLE 0x0004U
1682 #define LDAP_AVA_FREE_ATTR 0x0010U
1683 #define LDAP_AVA_FREE_VALUE 0x0020U
1688 typedef LDAPAVA
** LDAPRDN
;
1689 typedef LDAPRDN
* LDAPDN
;
1692 #define LDAP_DN_FORMAT_LDAP 0x0000U
1693 #define LDAP_DN_FORMAT_LDAPV3 0x0010U
1694 #define LDAP_DN_FORMAT_LDAPV2 0x0020U
1695 #define LDAP_DN_FORMAT_DCE 0x0030U
1696 #define LDAP_DN_FORMAT_UFN 0x0040U /* dn2str only */
1697 #define LDAP_DN_FORMAT_AD_CANONICAL 0x0050U /* dn2str only */
1698 #define LDAP_DN_FORMAT_LBER 0x00F0U /* for testing only */
1699 #define LDAP_DN_FORMAT_MASK 0x00F0U
1702 #define LDAP_DN_PRETTY 0x0100U
1703 #define LDAP_DN_SKIP 0x0200U
1704 #define LDAP_DN_P_NOLEADTRAILSPACES 0x1000U
1705 #define LDAP_DN_P_NOSPACEAFTERRDN 0x2000U
1706 #define LDAP_DN_PEDANTIC 0xF000U
1708 LDAP_F( void ) ldap_rdnfree
LDAP_P(( LDAPRDN rdn
));
1709 LDAP_F( void ) ldap_dnfree
LDAP_P(( LDAPDN dn
));
1718 ldap_str2dn
LDAP_P((
1719 LDAP_CONST
char *str
,
1730 ldap_dn2str
LDAP_P((
1736 ldap_bv2rdn
LDAP_P((
1743 ldap_str2rdn
LDAP_P((
1744 LDAP_CONST
char *str
,
1750 ldap_rdn2bv
LDAP_P((
1756 ldap_rdn2str
LDAP_P((
1762 ldap_dn_normalize
LDAP_P((
1763 LDAP_CONST
char *in
, unsigned iflags
,
1764 char **out
, unsigned oflags
));
1767 ldap_dn2ufn
LDAP_P(( /* deprecated, use ldap_str2dn/dn2str */
1768 LDAP_CONST
char *dn
));
1771 ldap_explode_dn
LDAP_P(( /* deprecated, ldap_str2dn */
1772 LDAP_CONST
char *dn
,
1776 ldap_explode_rdn
LDAP_P(( /* deprecated, ldap_str2rdn */
1777 LDAP_CONST
char *rdn
,
1780 typedef int LDAPDN_rewrite_func
1781 LDAP_P(( LDAPDN dn
, unsigned flags
, void *ctx
));
1784 ldap_X509dn2bv
LDAP_P(( void *x509_name
, struct berval
*dn
,
1785 LDAPDN_rewrite_func
*func
, unsigned flags
));
1788 ldap_dn2dcedn
LDAP_P(( /* deprecated, ldap_str2dn/dn2str */
1789 LDAP_CONST
char *dn
));
1792 ldap_dcedn2dn
LDAP_P(( /* deprecated, ldap_str2dn/dn2str */
1793 LDAP_CONST
char *dce
));
1796 ldap_dn2ad_canonical
LDAP_P(( /* deprecated, ldap_str2dn/dn2str */
1797 LDAP_CONST
char *dn
));
1800 ldap_get_dn_ber
LDAP_P((
1801 LDAP
*ld
, LDAPMessage
*e
, BerElement
**berout
, struct berval
*dn
));
1804 ldap_get_attribute_ber
LDAP_P((
1805 LDAP
*ld
, LDAPMessage
*e
, BerElement
*ber
, struct berval
*attr
,
1806 struct berval
**vals
));
1812 ldap_first_attribute
LDAP_P((
1815 BerElement
**ber
));
1818 ldap_next_attribute
LDAP_P((
1827 LDAP_F( struct berval
** )
1828 ldap_get_values_len
LDAP_P((
1831 LDAP_CONST
char *target
));
1834 ldap_count_values_len
LDAP_P((
1835 struct berval
**vals
));
1838 ldap_value_free_len
LDAP_P((
1839 struct berval
**vals
));
1843 ldap_get_values
LDAP_P(( /* deprecated, use ldap_get_values_len */
1846 LDAP_CONST
char *target
));
1849 ldap_count_values
LDAP_P(( /* deprecated, use ldap_count_values_len */
1853 ldap_value_free
LDAP_P(( /* deprecated, use ldap_value_free_len */
1861 ldap_result
LDAP_P((
1865 struct timeval
*timeout
,
1866 LDAPMessage
**result
));
1869 ldap_msgtype
LDAP_P((
1877 ldap_msgfree
LDAP_P((
1881 ldap_msgdelete
LDAP_P((
1890 ldap_bv2escaped_filter_value
LDAP_P((
1892 struct berval
*out
));
1895 ldap_search_ext
LDAP_P((
1897 LDAP_CONST
char *base
,
1899 LDAP_CONST
char *filter
,
1902 LDAPControl
**serverctrls
,
1903 LDAPControl
**clientctrls
,
1904 struct timeval
*timeout
,
1909 ldap_search_ext_s
LDAP_P((
1911 LDAP_CONST
char *base
,
1913 LDAP_CONST
char *filter
,
1916 LDAPControl
**serverctrls
,
1917 LDAPControl
**clientctrls
,
1918 struct timeval
*timeout
,
1920 LDAPMessage
**res
));
1924 ldap_search
LDAP_P(( /* deprecated, use ldap_search_ext */
1926 LDAP_CONST
char *base
,
1928 LDAP_CONST
char *filter
,
1933 ldap_search_s
LDAP_P(( /* deprecated, use ldap_search_ext_s */
1935 LDAP_CONST
char *base
,
1937 LDAP_CONST
char *filter
,
1940 LDAPMessage
**res
));
1943 ldap_search_st
LDAP_P(( /* deprecated, use ldap_search_ext_s */
1945 LDAP_CONST
char *base
,
1947 LDAP_CONST
char *filter
,
1950 struct timeval
*timeout
,
1951 LDAPMessage
**res
));
1958 ldap_unbind_ext
LDAP_P((
1960 LDAPControl
**serverctrls
,
1961 LDAPControl
**clientctrls
));
1964 ldap_unbind_ext_s
LDAP_P((
1966 LDAPControl
**serverctrls
,
1967 LDAPControl
**clientctrls
));
1970 ldap_destroy
LDAP_P((
1975 ldap_unbind
LDAP_P(( /* deprecated, use ldap_unbind_ext */
1979 ldap_unbind_s
LDAP_P(( /* deprecated, use ldap_unbind_ext_s */
1987 ldap_put_vrFilter
LDAP_P((
1996 ldap_memalloc
LDAP_P((
2000 ldap_memrealloc
LDAP_P((
2005 ldap_memcalloc
LDAP_P((
2010 ldap_memfree
LDAP_P((
2014 ldap_memvfree
LDAP_P((
2018 ldap_strdup
LDAP_P((
2019 LDAP_CONST
char * ));
2022 ldap_mods_free
LDAP_P((
2029 * in sort.c (deprecated, use custom code instead)
2031 typedef int (LDAP_SORT_AD_CMP_PROC
) LDAP_P(( /* deprecated */
2032 LDAP_CONST
char *left
,
2033 LDAP_CONST
char *right
));
2035 typedef int (LDAP_SORT_AV_CMP_PROC
) LDAP_P(( /* deprecated */
2036 LDAP_CONST
void *left
,
2037 LDAP_CONST
void *right
));
2039 LDAP_F( int ) /* deprecated */
2040 ldap_sort_entries
LDAP_P(( LDAP
*ld
,
2041 LDAPMessage
**chain
,
2042 LDAP_CONST
char *attr
,
2043 LDAP_SORT_AD_CMP_PROC
*cmp
));
2045 LDAP_F( int ) /* deprecated */
2046 ldap_sort_values
LDAP_P((
2049 LDAP_SORT_AV_CMP_PROC
*cmp
));
2051 LDAP_F( int ) /* deprecated */
2052 ldap_sort_strcasecmp
LDAP_P((
2054 LDAP_CONST
void *b
));
2061 ldap_is_ldap_url
LDAP_P((
2062 LDAP_CONST
char *url
));
2065 ldap_is_ldaps_url
LDAP_P((
2066 LDAP_CONST
char *url
));
2069 ldap_is_ldapi_url
LDAP_P((
2070 LDAP_CONST
char *url
));
2072 #ifdef LDAP_CONNECTIONLESS
2074 ldap_is_ldapc_url
LDAP_P((
2075 LDAP_CONST
char *url
));
2079 ldap_url_parse
LDAP_P((
2080 LDAP_CONST
char *url
,
2081 LDAPURLDesc
**ludpp
));
2084 ldap_url_desc2str
LDAP_P((
2085 LDAPURLDesc
*ludp
));
2088 ldap_free_urldesc
LDAP_P((
2089 LDAPURLDesc
*ludp
));
2093 * LDAP Cancel Extended Operation <draft-zeilenga-ldap-cancel-xx.txt>
2096 #define LDAP_API_FEATURE_CANCEL 1000
2099 ldap_cancel
LDAP_P(( LDAP
*ld
,
2101 LDAPControl
**sctrls
,
2102 LDAPControl
**cctrls
,
2106 ldap_cancel_s
LDAP_P(( LDAP
*ld
,
2108 LDAPControl
**sctrl
,
2109 LDAPControl
**cctrl
));
2112 * LDAP Turn Extended Operation <draft-zeilenga-ldap-turn-xx.txt>
2115 #define LDAP_API_FEATURE_TURN 1000
2118 ldap_turn
LDAP_P(( LDAP
*ld
,
2120 LDAP_CONST
char* identifier
,
2121 LDAPControl
**sctrls
,
2122 LDAPControl
**cctrls
,
2126 ldap_turn_s
LDAP_P(( LDAP
*ld
,
2128 LDAP_CONST
char* identifier
,
2129 LDAPControl
**sctrl
,
2130 LDAPControl
**cctrl
));
2133 * LDAP Paged Results
2136 #define LDAP_API_FEATURE_PAGED_RESULTS 2000
2139 ldap_create_page_control_value
LDAP_P((
2142 struct berval
*cookie
,
2143 struct berval
*value
));
2146 ldap_create_page_control
LDAP_P((
2149 struct berval
*cookie
,
2151 LDAPControl
**ctrlp
));
2155 ldap_parse_page_control
LDAP_P((
2156 /* deprecated, use ldap_parse_pageresponse_control */
2158 LDAPControl
**ctrls
,
2160 struct berval
**cookie
));
2164 ldap_parse_pageresponse_control
LDAP_P((
2168 struct berval
*cookie
));
2171 * LDAP Server Side Sort
2174 #define LDAP_API_FEATURE_SERVER_SIDE_SORT 2000
2176 /* structure for a sort-key */
2177 typedef struct ldapsortkey
{
2178 char *attributeType
;
2184 ldap_create_sort_keylist
LDAP_P((
2185 LDAPSortKey
***sortKeyList
,
2189 ldap_free_sort_keylist
LDAP_P((
2190 LDAPSortKey
**sortkeylist
));
2193 ldap_create_sort_control_value
LDAP_P((
2195 LDAPSortKey
**keyList
,
2196 struct berval
*value
));
2199 ldap_create_sort_control
LDAP_P((
2201 LDAPSortKey
**keyList
,
2203 LDAPControl
**ctrlp
));
2206 ldap_parse_sortresponse_control
LDAP_P((
2210 char **attribute
));
2213 * LDAP Virtual List View
2216 #define LDAP_API_FEATURE_VIRTUAL_LIST_VIEW 2000
2218 /* structure for virtual list */
2219 typedef struct ldapvlvinfo
{
2220 ber_int_t ldvlv_version
;
2221 ber_int_t ldvlv_before_count
;
2222 ber_int_t ldvlv_after_count
;
2223 ber_int_t ldvlv_offset
;
2224 ber_int_t ldvlv_count
;
2225 struct berval
* ldvlv_attrvalue
;
2226 struct berval
* ldvlv_context
;
2227 void * ldvlv_extradata
;
2231 ldap_create_vlv_control_value
LDAP_P((
2233 LDAPVLVInfo
*ldvlistp
,
2234 struct berval
*value
));
2237 ldap_create_vlv_control
LDAP_P((
2239 LDAPVLVInfo
*ldvlistp
,
2240 LDAPControl
**ctrlp
));
2243 ldap_parse_vlvresponse_control
LDAP_P((
2246 ber_int_t
*target_posp
,
2247 ber_int_t
*list_countp
,
2248 struct berval
**contextp
,
2252 * LDAP Verify Credentials
2254 #define LDAP_API_FEATURE_VERIFY_CREDENTIALS 1000
2257 ldap_verify_credentials
LDAP_P((
2259 struct berval
*cookie
,
2260 LDAP_CONST
char *dn
,
2261 LDAP_CONST
char *mechanism
,
2262 struct berval
*cred
,
2263 LDAPControl
**ctrls
,
2264 LDAPControl
**serverctrls
,
2265 LDAPControl
**clientctrls
,
2269 ldap_verify_credentials_s
LDAP_P((
2271 struct berval
*cookie
,
2272 LDAP_CONST
char *dn
,
2273 LDAP_CONST
char *mechanism
,
2274 struct berval
*cred
,
2275 LDAPControl
**vcictrls
,
2276 LDAPControl
**serverctrls
,
2277 LDAPControl
**clientctrls
,
2280 struct berval
**scookie
,
2281 struct berval
**servercredp
,
2282 LDAPControl
***vcoctrls
));
2286 ldap_parse_verify_credentials
LDAP_P((
2291 struct berval
**cookie
,
2292 struct berval
**servercredp
,
2293 LDAPControl
***vcctrls
));
2295 /* not yet implemented */
2296 /* #define LDAP_API_FEATURE_VERIFY_CREDENTIALS_INTERACTIVE 1000 */
2297 #ifdef LDAP_API_FEATURE_VERIFY_CREDENTIALS_INTERACTIVE
2299 ldap_verify_credentials_interactive
LDAP_P((
2301 LDAP_CONST
char *dn
, /* usually NULL */
2302 LDAP_CONST
char *saslMechanism
,
2303 LDAPControl
**vcControls
,
2304 LDAPControl
**serverControls
,
2305 LDAPControl
**clientControls
,
2307 /* should be client controls */
2309 LDAP_SASL_INTERACT_PROC
*proc
,
2313 /* as obtained from ldap_result() */
2314 LDAPMessage
*result
,
2316 /* returned during bind processing */
2325 #define LDAP_API_FEATURE_WHOAMI 1000
2328 ldap_parse_whoami
LDAP_P((
2331 struct berval
**authzid
));
2334 ldap_whoami
LDAP_P(( LDAP
*ld
,
2335 LDAPControl
**sctrls
,
2336 LDAPControl
**cctrls
,
2340 ldap_whoami_s
LDAP_P((
2342 struct berval
**authzid
,
2343 LDAPControl
**sctrls
,
2344 LDAPControl
**cctrls
));
2347 * LDAP Password Modify
2350 #define LDAP_API_FEATURE_PASSWD_MODIFY 1000
2353 ldap_parse_passwd
LDAP_P((
2356 struct berval
*newpasswd
));
2359 ldap_passwd
LDAP_P(( LDAP
*ld
,
2360 struct berval
*user
,
2361 struct berval
*oldpw
,
2362 struct berval
*newpw
,
2363 LDAPControl
**sctrls
,
2364 LDAPControl
**cctrls
,
2368 ldap_passwd_s
LDAP_P((
2370 struct berval
*user
,
2371 struct berval
*oldpw
,
2372 struct berval
*newpw
,
2373 struct berval
*newpasswd
,
2374 LDAPControl
**sctrls
,
2375 LDAPControl
**cctrls
));
2377 #ifdef LDAP_CONTROL_PASSWORDPOLICYREQUEST
2379 * LDAP Password Policy controls
2382 #define LDAP_API_FEATURE_PASSWORD_POLICY 1000
2384 typedef enum passpolicyerror_enum
{
2385 PP_passwordExpired
= 0,
2386 PP_accountLocked
= 1,
2387 PP_changeAfterReset
= 2,
2388 PP_passwordModNotAllowed
= 3,
2389 PP_mustSupplyOldPassword
= 4,
2390 PP_insufficientPasswordQuality
= 5,
2391 PP_passwordTooShort
= 6,
2392 PP_passwordTooYoung
= 7,
2393 PP_passwordInHistory
= 8,
2394 PP_passwordTooLong
= 9,
2396 } LDAPPasswordPolicyError
;
2399 ldap_create_passwordpolicy_control
LDAP_P((
2401 LDAPControl
**ctrlp
));
2404 ldap_parse_passwordpolicy_control
LDAP_P((
2409 LDAPPasswordPolicyError
*errorp
));
2411 LDAP_F( const char * )
2412 ldap_passwordpolicy_err2txt
LDAP_P(( LDAPPasswordPolicyError
));
2413 #endif /* LDAP_CONTROL_PASSWORDPOLICYREQUEST */
2416 ldap_parse_password_expiring_control
LDAP_P((
2422 * LDAP Dynamic Directory Services Refresh -- RFC 2589
2425 #define LDAP_API_FEATURE_REFRESH 1000
2428 ldap_parse_refresh
LDAP_P((
2431 ber_int_t
*newttl
));
2434 ldap_refresh
LDAP_P(( LDAP
*ld
,
2437 LDAPControl
**sctrls
,
2438 LDAPControl
**cctrls
,
2442 ldap_refresh_s
LDAP_P((
2447 LDAPControl
**sctrls
,
2448 LDAPControl
**cctrls
));
2454 ldap_txn_start
LDAP_P(( LDAP
*ld
,
2455 LDAPControl
**sctrls
,
2456 LDAPControl
**cctrls
,
2460 ldap_txn_start_s
LDAP_P(( LDAP
*ld
,
2461 LDAPControl
**sctrl
,
2462 LDAPControl
**cctrl
,
2463 struct berval
**rettxnid
));
2466 ldap_txn_end
LDAP_P(( LDAP
*ld
,
2468 struct berval
*txnid
,
2469 LDAPControl
**sctrls
,
2470 LDAPControl
**cctrls
,
2474 ldap_txn_end_s
LDAP_P(( LDAP
*ld
,
2476 struct berval
*txnid
,
2477 LDAPControl
**sctrl
,
2478 LDAPControl
**cctrl
,
2486 * initialize the persistent search structure
2488 LDAP_F( ldap_sync_t
* )
2489 ldap_sync_initialize
LDAP_P((
2493 * destroy the persistent search structure
2496 ldap_sync_destroy
LDAP_P((
2501 * initialize a refreshOnly sync
2504 ldap_sync_init
LDAP_P((
2509 * initialize a refreshOnly sync
2512 ldap_sync_init_refresh_only
LDAP_P((
2516 * initialize a refreshAndPersist sync
2519 ldap_sync_init_refresh_and_persist
LDAP_P((
2523 * poll for new responses
2526 ldap_sync_poll
LDAP_P((
2529 #ifdef LDAP_CONTROL_X_SESSION_TRACKING
2535 ldap_create_session_tracking_value
LDAP_P((
2537 char *sessionSourceIp
,
2538 char *sessionSourceName
,
2540 struct berval
*sessionTrackingIdentifier
,
2541 struct berval
*value
));
2544 ldap_create_session_tracking_control
LDAP_P((
2546 char *sessionSourceIp
,
2547 char *sessionSourceName
,
2549 struct berval
*sessionTrackingIdentifier
,
2550 LDAPControl
**ctrlp
));
2553 ldap_parse_session_tracking_control
LDAP_P((
2557 struct berval
*name
,
2559 struct berval
*id
));
2561 #endif /* LDAP_CONTROL_X_SESSION_TRACKING */
2566 #ifdef LDAP_CONTROL_X_DIRSYNC
2568 ldap_create_dirsync_value
LDAP_P((
2572 struct berval
*cookie
,
2573 struct berval
*value
));
2576 ldap_create_dirsync_control
LDAP_P((
2580 struct berval
*cookie
,
2581 LDAPControl
**ctrlp
));
2584 ldap_parse_dirsync_control
LDAP_P((
2588 struct berval
*cookie
));
2589 #endif /* LDAP_CONTROL_X_DIRSYNC */
2591 #ifdef LDAP_CONTROL_X_EXTENDED_DN
2593 ldap_create_extended_dn_value
LDAP_P((
2596 struct berval
*value
));
2599 ldap_create_extended_dn_control
LDAP_P((
2602 LDAPControl
**ctrlp
));
2603 #endif /* LDAP_CONTROL_X_EXTENDED_DN */
2605 #ifdef LDAP_CONTROL_X_SHOW_DELETED
2607 ldap_create_show_deleted_control
LDAP_P((
2609 LDAPControl
**ctrlp
));
2610 #endif /* LDAP_CONTROL_X_SHOW_DELETED */
2612 #ifdef LDAP_CONTROL_X_SERVER_NOTIFICATION
2614 ldap_create_server_notification_control
LDAP_P((
2616 LDAPControl
**ctrlp
));
2617 #endif /* LDAP_CONTROL_X_SERVER_NOTIFICATION */
2623 ldap_create_assertion_control_value
LDAP_P((
2626 struct berval
*value
));
2629 ldap_create_assertion_control
LDAP_P((
2633 LDAPControl
**ctrlp
));
2639 typedef struct LDAPDerefSpec
{
2644 typedef struct LDAPDerefVal
{
2647 struct LDAPDerefVal
*next
;
2650 typedef struct LDAPDerefRes
{
2652 struct berval derefVal
;
2653 LDAPDerefVal
*attrVals
;
2654 struct LDAPDerefRes
*next
;
2658 ldap_create_deref_control_value
LDAP_P((
2661 struct berval
*value
));
2664 ldap_create_deref_control
LDAP_P((
2668 LDAPControl
**ctrlp
));
2671 ldap_derefresponse_free
LDAP_P((
2672 LDAPDerefRes
*dr
));
2675 ldap_parse_derefresponse_control
LDAP_P((
2678 LDAPDerefRes
**drp
));
2681 ldap_parse_deref_control
LDAP_P((
2683 LDAPControl
**ctrls
,
2684 LDAPDerefRes
**drp
));
2691 ldap_create_persistentsearch_control_value
LDAP_P((
2695 int return_echg_ctls
,
2696 struct berval
*value
));
2699 ldap_create_persistentsearch_control
LDAP_P((
2703 int return_echg_ctls
,
2705 LDAPControl
**ctrlp
));
2708 ldap_parse_entrychange_control
LDAP_P((
2712 struct berval
*prevdnp
,
2713 int *chgnumpresentp
,
2716 /* in account_usability.c */
2719 ldap_create_accountusability_control
LDAP_P((
2721 LDAPControl
**ctrlp
));
2723 typedef struct LDAPAccountUsabilityMoreInfo
{
2727 ber_int_t remaining_grace
;
2728 ber_int_t seconds_before_unlock
;
2729 } LDAPAccountUsabilityMoreInfo
;
2731 typedef union LDAPAccountUsability
{
2732 ber_int_t seconds_remaining
;
2733 LDAPAccountUsabilityMoreInfo more_info
;
2734 } LDAPAccountUsability
;
2737 ldap_parse_accountusability_control
LDAP_P((
2741 LDAPAccountUsability
*usabilityp
));
2745 * high level LDIF to LDAP structure support
2747 #define LDIF_DEFAULT_ADD 0x01 /* if changetype missing, assume LDAP_ADD */
2748 #define LDIF_ENTRIES_ONLY 0x02 /* ignore changetypes other than add */
2749 #define LDIF_NO_CONTROLS 0x04 /* ignore control specifications */
2750 #define LDIF_MODS_ONLY 0x08 /* no changetypes, assume LDAP_MODIFY */
2751 #define LDIF_NO_DN 0x10 /* dn is not present */
2753 typedef struct ldifrecord
{
2754 ber_tag_t lr_op
; /* type of operation - LDAP_REQ_MODIFY, LDAP_REQ_ADD, etc. */
2755 struct berval lr_dn
; /* DN of operation */
2756 LDAPControl
**lr_ctrls
; /* controls specified for operation */
2757 /* some ops such as LDAP_REQ_DELETE require only a DN */
2758 /* other ops require different data - the ldif_ops union
2759 is used to specify the data for each type of operation */
2761 LDAPMod
**lr_mods
; /* list of mods for LDAP_REQ_MODIFY, LDAP_REQ_ADD */
2762 #define lrop_mods ldif_ops.lr_mods
2763 struct ldif_op_rename_s
{
2764 struct berval lr_newrdn
; /* LDAP_REQ_MODDN, LDAP_REQ_MODRDN, LDAP_REQ_RENAME */
2765 #define lrop_newrdn ldif_ops.ldif_op_rename.lr_newrdn
2766 struct berval lr_newsuperior
; /* LDAP_REQ_MODDN, LDAP_REQ_MODRDN, LDAP_REQ_RENAME */
2767 #define lrop_newsup ldif_ops.ldif_op_rename.lr_newsuperior
2768 int lr_deleteoldrdn
; /* LDAP_REQ_MODDN, LDAP_REQ_MODRDN, LDAP_REQ_RENAME */
2769 #define lrop_delold ldif_ops.ldif_op_rename.lr_deleteoldrdn
2770 } ldif_op_rename
; /* rename/moddn/modrdn */
2771 /* the following are for future support */
2772 struct ldif_op_ext_s
{
2773 struct berval lr_extop_oid
; /* LDAP_REQ_EXTENDED */
2774 #define lrop_extop_oid ldif_ops.ldif_op_ext.lr_extop_oid
2775 struct berval lr_extop_data
; /* LDAP_REQ_EXTENDED */
2776 #define lrop_extop_data ldif_ops.ldif_op_ext.lr_extop_data
2777 } ldif_op_ext
; /* extended operation */
2778 struct ldif_op_cmp_s
{
2779 struct berval lr_cmp_attr
; /* LDAP_REQ_COMPARE */
2780 #define lrop_cmp_attr ldif_ops.ldif_op_cmp.lr_cmp_attr
2781 struct berval lr_cmp_bvalue
; /* LDAP_REQ_COMPARE */
2782 #define lrop_cmp_bval ldif_ops.ldif_op_cmp.lr_cmp_bvalue
2783 } ldif_op_cmp
; /* compare operation */
2785 /* PRIVATE STUFF - DO NOT TOUCH */
2786 /* for efficiency, the implementation allocates memory */
2787 /* in large blobs, and makes the above fields point to */
2788 /* locations inside those blobs - one consequence is that */
2789 /* you cannot simply free the above allocated fields, nor */
2790 /* assign them to be owned by another memory context which */
2791 /* might free them (unless providing your own mem ctx) */
2792 /* we use the fields below to keep track of those blobs */
2793 /* so we that we can free them later */
2794 void *lr_ctx
; /* the memory context or NULL */
2797 unsigned char *lr_mops
;
2799 struct berval
*lr_vals
;
2800 struct berval
*lr_btype
;
2803 /* free internal fields - does not free the LDIFRecord */
2805 ldap_ldif_record_done
LDAP_P((
2809 ldap_parse_ldif_record
LDAP_P((
2810 struct berval
*rbuf
,
2811 unsigned long linenum
,
2814 unsigned int flags
));
2817 #endif /* _LDAP_H */