xref: /netbsd-src/external/bsd/openldap/dist/include/ldap.h (revision b1c86f5f087524e68db12794ee9c3e3da1ab17a0)
1 /*	$NetBSD: ldap.h,v 1.1.1.3 2010/03/08 02:14:20 lukem Exp $	*/
2 
3 /* OpenLDAP: pkg/ldap/include/ldap.h,v 1.312.2.23 2009/08/25 22:52:17 quanah Exp */
4 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5  *
6  * Copyright 1998-2009 The OpenLDAP Foundation.
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted only as authorized by the OpenLDAP
11  * Public License.
12  *
13  * A copy of this license is available in file LICENSE in the
14  * top-level directory of the distribution or, alternatively, at
15  * <http://www.OpenLDAP.org/license.html>.
16  */
17 /* Portions Copyright (c) 1990 Regents of the University of Michigan.
18  * All rights reserved.
19  *
20  * Redistribution and use in source and binary forms are permitted
21  * provided that this notice is preserved and that due credit is given
22  * to the University of Michigan at Ann Arbor. The name of the University
23  * may not be used to endorse or promote products derived from this
24  * software without specific prior written permission. This software
25  * is provided ``as is'' without express or implied warranty.
26  */
27 
28 #ifndef _LDAP_H
29 #define _LDAP_H
30 
31 /* pull in lber */
32 #include <lber.h>
33 
34 /* include version and API feature defines */
35 #include <ldap_features.h>
36 
37 LDAP_BEGIN_DECL
38 
39 #define LDAP_VERSION1	1
40 #define LDAP_VERSION2	2
41 #define LDAP_VERSION3	3
42 
43 #define LDAP_VERSION_MIN	LDAP_VERSION2
44 #define	LDAP_VERSION		LDAP_VERSION2
45 #define LDAP_VERSION_MAX	LDAP_VERSION3
46 
47 /*
48  * We use 3000+n here because it is above 1823 (for RFC 1823),
49  * above 2000+rev of IETF LDAPEXT draft (now quite dated),
50  * yet below allocations for new RFCs (just in case there is
51  * someday an RFC produced).
52  */
53 #define LDAP_API_VERSION	3001
54 #define LDAP_VENDOR_NAME	"OpenLDAP"
55 
56 /* OpenLDAP API Features */
57 #define LDAP_API_FEATURE_X_OPENLDAP LDAP_VENDOR_VERSION
58 
59 #if defined( LDAP_API_FEATURE_X_OPENLDAP_REENTRANT ) || \
60 	( defined( LDAP_THREAD_SAFE ) && \
61 		defined( LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE ) )
62 	/* -lldap may or may not be thread safe */
63 	/* -lldap_r, if available, is always thread safe */
64 #	define	LDAP_API_FEATURE_THREAD_SAFE 1
65 #endif
66 #if defined( LDAP_THREAD_SAFE ) && \
67 	defined( LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE )
68 /* #define LDAP_API_FEATURE_SESSION_SAFE	1	*/
69 /* #define LDAP_API_OPERATION_SESSION_SAFE	1	*/
70 #endif
71 
72 
73 #define LDAP_PORT		389		/* ldap:///		default LDAP port */
74 #define LDAPS_PORT		636		/* ldaps:///	default LDAP over TLS port */
75 
76 #define LDAP_ROOT_DSE				""
77 #define LDAP_NO_ATTRS				"1.1"
78 #define LDAP_ALL_USER_ATTRIBUTES	"*"
79 #define LDAP_ALL_OPERATIONAL_ATTRIBUTES	"+" /* RFC 3673 */
80 
81 /* RFC 4511:  maxInt INTEGER ::= 2147483647 -- (2^^31 - 1) -- */
82 #define LDAP_MAXINT (2147483647)
83 
84 /*
85  * LDAP_OPTions
86  *	0x0000 - 0x0fff reserved for api options
87  *	0x1000 - 0x3fff reserved for api extended options
88  *	0x4000 - 0x7fff reserved for private and experimental options
89  */
90 
91 #define LDAP_OPT_API_INFO			0x0000
92 #define LDAP_OPT_DESC				0x0001 /* historic */
93 #define LDAP_OPT_DEREF				0x0002
94 #define LDAP_OPT_SIZELIMIT			0x0003
95 #define LDAP_OPT_TIMELIMIT			0x0004
96 /* 0x05 - 0x07 not defined */
97 #define LDAP_OPT_REFERRALS			0x0008
98 #define LDAP_OPT_RESTART			0x0009
99 /* 0x0a - 0x10 not defined */
100 #define LDAP_OPT_PROTOCOL_VERSION		0x0011
101 #define LDAP_OPT_SERVER_CONTROLS		0x0012
102 #define LDAP_OPT_CLIENT_CONTROLS		0x0013
103 /* 0x14 not defined */
104 #define LDAP_OPT_API_FEATURE_INFO		0x0015
105 /* 0x16 - 0x2f not defined */
106 #define LDAP_OPT_HOST_NAME			0x0030
107 #define LDAP_OPT_RESULT_CODE			0x0031
108 #define LDAP_OPT_ERROR_NUMBER			LDAP_OPT_RESULT_CODE
109 #define LDAP_OPT_DIAGNOSTIC_MESSAGE		0x0032
110 #define LDAP_OPT_ERROR_STRING			LDAP_OPT_DIAGNOSTIC_MESSAGE
111 #define LDAP_OPT_MATCHED_DN			0x0033
112 /* 0x0034 - 0x3fff not defined */
113 /* 0x0091 used by Microsoft for LDAP_OPT_AUTO_RECONNECT */
114 #define LDAP_OPT_SSPI_FLAGS			0x0092
115 /* 0x0093 used by Microsoft for LDAP_OPT_SSL_INFO */
116 /* 0x0094 used by Microsoft for LDAP_OPT_REF_DEREF_CONN_PER_MSG */
117 #define LDAP_OPT_SIGN				0x0095
118 #define LDAP_OPT_ENCRYPT			0x0096
119 #define LDAP_OPT_SASL_METHOD			0x0097
120 /* 0x0098 used by Microsoft for LDAP_OPT_AREC_EXCLUSIVE */
121 #define LDAP_OPT_SECURITY_CONTEXT		0x0099
122 /* 0x009A used by Microsoft for LDAP_OPT_ROOTDSE_CACHE */
123 /* 0x009B - 0x3fff not defined */
124 
125 /* API Extensions */
126 #define LDAP_OPT_API_EXTENSION_BASE 0x4000  /* API extensions */
127 
128 /* private and experimental options */
129 /* OpenLDAP specific options */
130 #define LDAP_OPT_DEBUG_LEVEL		0x5001	/* debug level */
131 #define LDAP_OPT_TIMEOUT			0x5002	/* default timeout */
132 #define LDAP_OPT_REFHOPLIMIT		0x5003	/* ref hop limit */
133 #define LDAP_OPT_NETWORK_TIMEOUT	0x5005	/* socket level timeout */
134 #define LDAP_OPT_URI				0x5006
135 #define LDAP_OPT_REFERRAL_URLS      0x5007  /* Referral URLs */
136 #define LDAP_OPT_SOCKBUF            0x5008  /* sockbuf */
137 #define LDAP_OPT_DEFBASE		0x5009	/* searchbase */
138 #define	LDAP_OPT_CONNECT_ASYNC		0x5010	/* create connections asynchronously */
139 #define	LDAP_OPT_CONNECT_CB			0x5011	/* connection callbacks */
140 
141 /* OpenLDAP TLS options */
142 #define LDAP_OPT_X_TLS				0x6000
143 #define LDAP_OPT_X_TLS_CTX			0x6001	/* OpenSSL CTX* */
144 #define LDAP_OPT_X_TLS_CACERTFILE	0x6002
145 #define LDAP_OPT_X_TLS_CACERTDIR	0x6003
146 #define LDAP_OPT_X_TLS_CERTFILE		0x6004
147 #define LDAP_OPT_X_TLS_KEYFILE		0x6005
148 #define LDAP_OPT_X_TLS_REQUIRE_CERT	0x6006
149 #define LDAP_OPT_X_TLS_PROTOCOL_MIN	0x6007
150 #define LDAP_OPT_X_TLS_CIPHER_SUITE	0x6008
151 #define LDAP_OPT_X_TLS_RANDOM_FILE	0x6009
152 #define LDAP_OPT_X_TLS_SSL_CTX		0x600a	/* OpenSSL SSL* */
153 #define LDAP_OPT_X_TLS_CRLCHECK		0x600b
154 #define LDAP_OPT_X_TLS_CONNECT_CB	0x600c
155 #define LDAP_OPT_X_TLS_CONNECT_ARG	0x600d
156 #define LDAP_OPT_X_TLS_DHFILE		0x600e
157 #define LDAP_OPT_X_TLS_NEWCTX		0x600f
158 #define LDAP_OPT_X_TLS_CRLFILE		0x6010	/* GNUtls only */
159 
160 #define LDAP_OPT_X_TLS_NEVER	0
161 #define LDAP_OPT_X_TLS_HARD		1
162 #define LDAP_OPT_X_TLS_DEMAND	2
163 #define LDAP_OPT_X_TLS_ALLOW	3
164 #define LDAP_OPT_X_TLS_TRY		4
165 
166 #define LDAP_OPT_X_TLS_CRL_NONE	0
167 #define LDAP_OPT_X_TLS_CRL_PEER	1
168 #define LDAP_OPT_X_TLS_CRL_ALL	2
169 
170 /* for LDAP_OPT_X_TLS_PROTOCOL_MIN */
171 #define LDAP_OPT_X_TLS_PROTOCOL(maj,min)	(((maj) << 8) + (min))
172 #define LDAP_OPT_X_TLS_PROTOCOL_SSL2		(2 << 8)
173 #define LDAP_OPT_X_TLS_PROTOCOL_SSL3		(3 << 8)
174 #define LDAP_OPT_X_TLS_PROTOCOL_TLS1_0		((3 << 8) + 1)
175 #define LDAP_OPT_X_TLS_PROTOCOL_TLS1_1		((3 << 8) + 2)
176 #define LDAP_OPT_X_TLS_PROTOCOL_TLS1_2		((3 << 8) + 3)
177 
178 /* OpenLDAP SASL options */
179 #define LDAP_OPT_X_SASL_MECH			0x6100
180 #define LDAP_OPT_X_SASL_REALM			0x6101
181 #define LDAP_OPT_X_SASL_AUTHCID			0x6102
182 #define LDAP_OPT_X_SASL_AUTHZID			0x6103
183 #define LDAP_OPT_X_SASL_SSF				0x6104 /* read-only */
184 #define LDAP_OPT_X_SASL_SSF_EXTERNAL	0x6105 /* write-only */
185 #define LDAP_OPT_X_SASL_SECPROPS		0x6106 /* write-only */
186 #define LDAP_OPT_X_SASL_SSF_MIN			0x6107
187 #define LDAP_OPT_X_SASL_SSF_MAX			0x6108
188 #define LDAP_OPT_X_SASL_MAXBUFSIZE		0x6109
189 #define LDAP_OPT_X_SASL_MECHLIST		0x610a /* read-only */
190 #define LDAP_OPT_X_SASL_NOCANON			0x610b
191 #define LDAP_OPT_X_SASL_USERNAME		0x610c /* read-only */
192 
193 /* OpenLDAP GSSAPI options */
194 #define LDAP_OPT_X_GSSAPI_DO_NOT_FREE_CONTEXT      0x6200
195 #define LDAP_OPT_X_GSSAPI_ALLOW_REMOTE_PRINCIPAL   0x6201
196 
197 /*
198  * OpenLDAP per connection tcp-keepalive settings
199  * (Linux only, ignored where unsupported)
200  */
201 #define LDAP_OPT_X_KEEPALIVE_IDLE		0x6300
202 #define LDAP_OPT_X_KEEPALIVE_PROBES		0x6301
203 #define LDAP_OPT_X_KEEPALIVE_INTERVAL	0x6302
204 
205 /* Private API Extensions -- reserved for application use */
206 #define LDAP_OPT_PRIVATE_EXTENSION_BASE 0x7000  /* Private API inclusive */
207 
208 /*
209  * ldap_get_option() and ldap_set_option() return values.
210  * As later versions may return other values indicating
211  * failure, current applications should only compare returned
212  * value against LDAP_OPT_SUCCESS.
213  */
214 #define LDAP_OPT_SUCCESS	0
215 #define	LDAP_OPT_ERROR		(-1)
216 
217 /* option on/off values */
218 #define LDAP_OPT_ON		((void *) &ber_pvt_opt_on)
219 #define LDAP_OPT_OFF	((void *) 0)
220 
221 typedef struct ldapapiinfo {
222 	int		ldapai_info_version;		/* version of LDAPAPIInfo */
223 #define LDAP_API_INFO_VERSION	(1)
224 	int		ldapai_api_version;			/* revision of API supported */
225 	int		ldapai_protocol_version;	/* highest LDAP version supported */
226 	char	**ldapai_extensions;		/* names of API extensions */
227 	char	*ldapai_vendor_name;		/* name of supplier */
228 	int		ldapai_vendor_version;		/* supplier-specific version * 100 */
229 } LDAPAPIInfo;
230 
231 typedef struct ldap_apifeature_info {
232 	int		ldapaif_info_version;		/* version of LDAPAPIFeatureInfo */
233 #define LDAP_FEATURE_INFO_VERSION (1)	/* apifeature_info struct version */
234 	char*	ldapaif_name;				/* LDAP_API_FEATURE_* (less prefix) */
235 	int		ldapaif_version;			/* value of LDAP_API_FEATURE_... */
236 } LDAPAPIFeatureInfo;
237 
238 /*
239  * LDAP Control structure
240  */
241 typedef struct ldapcontrol {
242 	char *			ldctl_oid;			/* numericoid of control */
243 	struct berval	ldctl_value;		/* encoded value of control */
244 	char			ldctl_iscritical;	/* criticality */
245 } LDAPControl;
246 
247 /* LDAP Controls */
248 /*	standard track controls */
249 #define LDAP_CONTROL_MANAGEDSAIT	"2.16.840.1.113730.3.4.2"  /* RFC 3296 */
250 #define LDAP_CONTROL_PROXY_AUTHZ	"2.16.840.1.113730.3.4.18" /* RFC 4370 */
251 #define LDAP_CONTROL_SUBENTRIES		"1.3.6.1.4.1.4203.1.10.1"  /* RFC 3672 */
252 
253 #define LDAP_CONTROL_VALUESRETURNFILTER "1.2.826.0.1.3344810.2.3"/* RFC 3876 */
254 
255 #define LDAP_CONTROL_ASSERT				"1.3.6.1.1.12"			/* RFC 4528 */
256 #define LDAP_CONTROL_PRE_READ			"1.3.6.1.1.13.1"		/* RFC 4527 */
257 #define LDAP_CONTROL_POST_READ			"1.3.6.1.1.13.2"		/* RFC 4527 */
258 
259 #define LDAP_CONTROL_SORTREQUEST    "1.2.840.113556.1.4.473" /* RFC 2891 */
260 #define LDAP_CONTROL_SORTRESPONSE	"1.2.840.113556.1.4.474" /* RFC 2891 */
261 
262 /*	non-standard track controls */
263 #define LDAP_CONTROL_PAGEDRESULTS	"1.2.840.113556.1.4.319"   /* RFC 2696 */
264 
265 /* LDAP Content Synchronization Operation -- RFC 4533 */
266 #define LDAP_SYNC_OID			"1.3.6.1.4.1.4203.1.9.1"
267 #define LDAP_CONTROL_SYNC		LDAP_SYNC_OID ".1"
268 #define LDAP_CONTROL_SYNC_STATE	LDAP_SYNC_OID ".2"
269 #define LDAP_CONTROL_SYNC_DONE	LDAP_SYNC_OID ".3"
270 #define LDAP_SYNC_INFO			LDAP_SYNC_OID ".4"
271 
272 #define LDAP_SYNC_NONE					0x00
273 #define LDAP_SYNC_REFRESH_ONLY			0x01
274 #define LDAP_SYNC_RESERVED				0x02
275 #define LDAP_SYNC_REFRESH_AND_PERSIST	0x03
276 
277 #define LDAP_SYNC_REFRESH_PRESENTS		0
278 #define LDAP_SYNC_REFRESH_DELETES		1
279 
280 #define LDAP_TAG_SYNC_NEW_COOKIE		((ber_tag_t) 0x80U)
281 #define LDAP_TAG_SYNC_REFRESH_DELETE	((ber_tag_t) 0xa1U)
282 #define LDAP_TAG_SYNC_REFRESH_PRESENT	((ber_tag_t) 0xa2U)
283 #define	LDAP_TAG_SYNC_ID_SET			((ber_tag_t) 0xa3U)
284 
285 #define LDAP_TAG_SYNC_COOKIE			((ber_tag_t) 0x04U)
286 #define LDAP_TAG_REFRESHDELETES			((ber_tag_t) 0x01U)
287 #define LDAP_TAG_REFRESHDONE			((ber_tag_t) 0x01U)
288 #define LDAP_TAG_RELOAD_HINT			((ber_tag_t) 0x01U)
289 
290 #define LDAP_SYNC_PRESENT				0
291 #define LDAP_SYNC_ADD					1
292 #define LDAP_SYNC_MODIFY				2
293 #define LDAP_SYNC_DELETE				3
294 #define LDAP_SYNC_NEW_COOKIE			4
295 
296 
297 /* Password policy Controls *//* work in progress */
298 /* ITS#3458: released; disabled by default */
299 #define LDAP_CONTROL_PASSWORDPOLICYREQUEST	"1.3.6.1.4.1.42.2.27.8.5.1"
300 #define LDAP_CONTROL_PASSWORDPOLICYRESPONSE	"1.3.6.1.4.1.42.2.27.8.5.1"
301 
302 /* various works in progress */
303 #define LDAP_CONTROL_NOOP				"1.3.6.1.4.1.4203.666.5.2"
304 #define LDAP_CONTROL_NO_SUBORDINATES	"1.3.6.1.4.1.4203.666.5.11"
305 #define LDAP_CONTROL_RELAX				"1.3.6.1.4.1.4203.666.5.12"
306 #define LDAP_CONTROL_MANAGEDIT			LDAP_CONTROL_RELAX
307 #define LDAP_CONTROL_SLURP				"1.3.6.1.4.1.4203.666.5.13"
308 #define LDAP_CONTROL_VALSORT			"1.3.6.1.4.1.4203.666.5.14"
309 #define LDAP_CONTROL_DONTUSECOPY		"1.3.6.1.4.1.4203.666.5.15"
310 #define	LDAP_CONTROL_X_DEREF			"1.3.6.1.4.1.4203.666.5.16"
311 #define	LDAP_CONTROL_X_WHATFAILED		"1.3.6.1.4.1.4203.666.5.17"
312 
313 /* LDAP Chaining Behavior Control *//* work in progress */
314 /* <draft-sermersheim-ldap-chaining>;
315  * see also LDAP_NO_REFERRALS_FOUND, LDAP_CANNOT_CHAIN */
316 #define LDAP_CONTROL_X_CHAINING_BEHAVIOR	"1.3.6.1.4.1.4203.666.11.3"
317 
318 #define	LDAP_CHAINING_PREFERRED				0
319 #define	LDAP_CHAINING_REQUIRED				1
320 #define LDAP_REFERRALS_PREFERRED			2
321 #define LDAP_REFERRALS_REQUIRED				3
322 
323 /* MS Active Directory controls (for compatibility) */
324 #define LDAP_CONTROL_X_INCREMENTAL_VALUES	"1.2.840.113556.1.4.802"
325 #define LDAP_CONTROL_X_DOMAIN_SCOPE			"1.2.840.113556.1.4.1339"
326 #define LDAP_CONTROL_X_PERMISSIVE_MODIFY	"1.2.840.113556.1.4.1413"
327 #define LDAP_CONTROL_X_SEARCH_OPTIONS		"1.2.840.113556.1.4.1340"
328 #define LDAP_SEARCH_FLAG_DOMAIN_SCOPE 1 /* do not generate referrals */
329 #define LDAP_SEARCH_FLAG_PHANTOM_ROOT 2 /* search all subordinate NCs */
330 #define LDAP_CONTROL_X_TREE_DELETE		"1.2.840.113556.1.4.805"
331 
332 /* MS Active Directory controls - not implemented in slapd(8) */
333 #define LDAP_CONTROL_X_EXTENDED_DN		"1.2.840.113556.1.4.529"
334 
335 #ifdef LDAP_DEVEL
336 /* <draft-wahl-ldap-session> */
337 #define LDAP_CONTROL_X_SESSION_TRACKING		"1.3.6.1.4.1.21008.108.63.1"
338 #define LDAP_CONTROL_X_SESSION_TRACKING_RADIUS_ACCT_SESSION_ID \
339 						LDAP_CONTROL_X_SESSION_TRACKING ".1"
340 #define LDAP_CONTROL_X_SESSION_TRACKING_RADIUS_ACCT_MULTI_SESSION_ID \
341 						LDAP_CONTROL_X_SESSION_TRACKING ".2"
342 #define LDAP_CONTROL_X_SESSION_TRACKING_USERNAME \
343 						LDAP_CONTROL_X_SESSION_TRACKING ".3"
344 #endif /* LDAP_DEVEL */
345 
346 /* various expired works */
347 /* LDAP Duplicated Entry Control Extension *//* not implemented in slapd(8) */
348 #define LDAP_CONTROL_DUPENT_REQUEST		"2.16.840.1.113719.1.27.101.1"
349 #define LDAP_CONTROL_DUPENT_RESPONSE	"2.16.840.1.113719.1.27.101.2"
350 #define LDAP_CONTROL_DUPENT_ENTRY		"2.16.840.1.113719.1.27.101.3"
351 #define LDAP_CONTROL_DUPENT	LDAP_CONTROL_DUPENT_REQUEST
352 
353 /* LDAP Persistent Search Control *//* not implemented in slapd(8) */
354 #define LDAP_CONTROL_PERSIST_REQUEST				"2.16.840.1.113730.3.4.3"
355 #define LDAP_CONTROL_PERSIST_ENTRY_CHANGE_NOTICE	"2.16.840.1.113730.3.4.7"
356 #define LDAP_CONTROL_PERSIST_ENTRY_CHANGE_ADD		0x1
357 #define LDAP_CONTROL_PERSIST_ENTRY_CHANGE_DELETE	0x2
358 #define LDAP_CONTROL_PERSIST_ENTRY_CHANGE_MODIFY	0x4
359 #define LDAP_CONTROL_PERSIST_ENTRY_CHANGE_RENAME	0x8
360 
361 /* LDAP VLV */
362 #define LDAP_CONTROL_VLVREQUEST    	"2.16.840.1.113730.3.4.9"
363 #define LDAP_CONTROL_VLVRESPONSE    "2.16.840.1.113730.3.4.10"
364 
365 /* LDAP Unsolicited Notifications */
366 #define	LDAP_NOTICE_OF_DISCONNECTION	"1.3.6.1.4.1.1466.20036" /* RFC 4511 */
367 #define LDAP_NOTICE_DISCONNECT LDAP_NOTICE_OF_DISCONNECTION
368 
369 /* LDAP Extended Operations */
370 #define LDAP_EXOP_START_TLS		"1.3.6.1.4.1.1466.20037"	/* RFC 4511 */
371 
372 #define LDAP_EXOP_MODIFY_PASSWD	"1.3.6.1.4.1.4203.1.11.1"	/* RFC 3062 */
373 #define LDAP_TAG_EXOP_MODIFY_PASSWD_ID	((ber_tag_t) 0x80U)
374 #define LDAP_TAG_EXOP_MODIFY_PASSWD_OLD	((ber_tag_t) 0x81U)
375 #define LDAP_TAG_EXOP_MODIFY_PASSWD_NEW	((ber_tag_t) 0x82U)
376 #define LDAP_TAG_EXOP_MODIFY_PASSWD_GEN	((ber_tag_t) 0x80U)
377 
378 #define LDAP_EXOP_CANCEL		"1.3.6.1.1.8"					/* RFC 3909 */
379 #define LDAP_EXOP_X_CANCEL		LDAP_EXOP_CANCEL
380 
381 #define	LDAP_EXOP_REFRESH		"1.3.6.1.4.1.1466.101.119.1"	/* RFC 2589 */
382 #define	LDAP_TAG_EXOP_REFRESH_REQ_DN	((ber_tag_t) 0x80U)
383 #define	LDAP_TAG_EXOP_REFRESH_REQ_TTL	((ber_tag_t) 0x81U)
384 #define	LDAP_TAG_EXOP_REFRESH_RES_TTL	((ber_tag_t) 0x80U)
385 
386 #define LDAP_EXOP_WHO_AM_I		"1.3.6.1.4.1.4203.1.11.3"		/* RFC 4532 */
387 #define LDAP_EXOP_X_WHO_AM_I	LDAP_EXOP_WHO_AM_I
388 
389 /* various works in progress */
390 #define LDAP_EXOP_TURN		"1.3.6.1.1.19"				/* RFC 4531 */
391 #define LDAP_EXOP_X_TURN	LDAP_EXOP_TURN
392 
393 /* LDAP Distributed Procedures <draft-sermersheim-ldap-distproc> */
394 /* a work in progress */
395 #define LDAP_X_DISTPROC_BASE		"1.3.6.1.4.1.4203.666.11.6"
396 #define LDAP_EXOP_X_CHAINEDREQUEST	LDAP_X_DISTPROC_BASE ".1"
397 #define LDAP_FEATURE_X_CANCHAINOPS	LDAP_X_DISTPROC_BASE ".2"
398 #define LDAP_CONTROL_X_RETURNCONTREF	LDAP_X_DISTPROC_BASE ".3"
399 #define LDAP_URLEXT_X_LOCALREFOID	LDAP_X_DISTPROC_BASE ".4"
400 #define LDAP_URLEXT_X_REFTYPEOID	LDAP_X_DISTPROC_BASE ".5"
401 #define LDAP_URLEXT_X_SEARCHEDSUBTREEOID \
402 					LDAP_X_DISTPROC_BASE ".6"
403 #define LDAP_URLEXT_X_FAILEDNAMEOID	LDAP_X_DISTPROC_BASE ".7"
404 #define LDAP_URLEXT_X_LOCALREF		"x-localReference"
405 #define LDAP_URLEXT_X_REFTYPE		"x-referenceType"
406 #define LDAP_URLEXT_X_SEARCHEDSUBTREE	"x-searchedSubtree"
407 #define LDAP_URLEXT_X_FAILEDNAME	"x-failedName"
408 
409 #ifdef LDAP_DEVEL
410 #define LDAP_X_TXN						"1.3.6.1.4.1.4203.666.11.7" /* tmp */
411 #define LDAP_EXOP_X_TXN_START			LDAP_X_TXN ".1"
412 #define LDAP_CONTROL_X_TXN_SPEC			LDAP_X_TXN ".2"
413 #define LDAP_EXOP_X_TXN_END				LDAP_X_TXN ".3"
414 #define LDAP_EXOP_X_TXN_ABORTED_NOTICE	LDAP_X_TXN ".4"
415 #endif
416 
417 /* LDAP Features */
418 #define LDAP_FEATURE_ALL_OP_ATTRS	"1.3.6.1.4.1.4203.1.5.1"	/* RFC 3673 */
419 #define LDAP_FEATURE_OBJECTCLASS_ATTRS \
420 	"1.3.6.1.4.1.4203.1.5.2" /*  @objectClass - new number to be assigned */
421 #define LDAP_FEATURE_ABSOLUTE_FILTERS "1.3.6.1.4.1.4203.1.5.3"  /* (&) (|) */
422 #define LDAP_FEATURE_LANGUAGE_TAG_OPTIONS "1.3.6.1.4.1.4203.1.5.4"
423 #define LDAP_FEATURE_LANGUAGE_RANGE_OPTIONS "1.3.6.1.4.1.4203.1.5.5"
424 #define LDAP_FEATURE_MODIFY_INCREMENT "1.3.6.1.1.14"
425 
426 /* LDAP Experimental (works in progress) Features */
427 #define LDAP_FEATURE_SUBORDINATE_SCOPE \
428 	"1.3.6.1.4.1.4203.666.8.1" /* "children" */
429 #define LDAP_FEATURE_CHILDREN_SCOPE LDAP_FEATURE_SUBORDINATE_SCOPE
430 
431 /*
432  * specific LDAP instantiations of BER types we know about
433  */
434 
435 /* Overview of LBER tag construction
436  *
437  *	Bits
438  *	______
439  *	8 7 | CLASS
440  *	0 0 = UNIVERSAL
441  *	0 1 = APPLICATION
442  *	1 0 = CONTEXT-SPECIFIC
443  *	1 1 = PRIVATE
444  *		_____
445  *		| 6 | DATA-TYPE
446  *		  0 = PRIMITIVE
447  *		  1 = CONSTRUCTED
448  *			___________
449  *			| 5 ... 1 | TAG-NUMBER
450  */
451 
452 /* general stuff */
453 #define LDAP_TAG_MESSAGE	((ber_tag_t) 0x30U)	/* constructed + 16 */
454 #define LDAP_TAG_MSGID		((ber_tag_t) 0x02U)	/* integer */
455 
456 #define LDAP_TAG_LDAPDN		((ber_tag_t) 0x04U)	/* octet string */
457 #define LDAP_TAG_LDAPCRED	((ber_tag_t) 0x04U)	/* octet string */
458 
459 #define LDAP_TAG_CONTROLS	((ber_tag_t) 0xa0U)	/* context specific + constructed + 0 */
460 #define LDAP_TAG_REFERRAL	((ber_tag_t) 0xa3U)	/* context specific + constructed + 3 */
461 
462 #define LDAP_TAG_NEWSUPERIOR	((ber_tag_t) 0x80U)	/* context-specific + primitive + 0 */
463 
464 #define LDAP_TAG_EXOP_REQ_OID   ((ber_tag_t) 0x80U)	/* context specific + primitive */
465 #define LDAP_TAG_EXOP_REQ_VALUE ((ber_tag_t) 0x81U)	/* context specific + primitive */
466 #define LDAP_TAG_EXOP_RES_OID   ((ber_tag_t) 0x8aU)	/* context specific + primitive */
467 #define LDAP_TAG_EXOP_RES_VALUE ((ber_tag_t) 0x8bU)	/* context specific + primitive */
468 
469 #define LDAP_TAG_IM_RES_OID   ((ber_tag_t) 0x80U)	/* context specific + primitive */
470 #define LDAP_TAG_IM_RES_VALUE ((ber_tag_t) 0x81U)	/* context specific + primitive */
471 
472 #define LDAP_TAG_SASL_RES_CREDS	((ber_tag_t) 0x87U)	/* context specific + primitive */
473 
474 /* LDAP Request Messages */
475 #define LDAP_REQ_BIND		((ber_tag_t) 0x60U)	/* application + constructed */
476 #define LDAP_REQ_UNBIND		((ber_tag_t) 0x42U)	/* application + primitive   */
477 #define LDAP_REQ_SEARCH		((ber_tag_t) 0x63U)	/* application + constructed */
478 #define LDAP_REQ_MODIFY		((ber_tag_t) 0x66U)	/* application + constructed */
479 #define LDAP_REQ_ADD		((ber_tag_t) 0x68U)	/* application + constructed */
480 #define LDAP_REQ_DELETE		((ber_tag_t) 0x4aU)	/* application + primitive   */
481 #define LDAP_REQ_MODDN		((ber_tag_t) 0x6cU)	/* application + constructed */
482 #define LDAP_REQ_MODRDN		LDAP_REQ_MODDN
483 #define LDAP_REQ_RENAME		LDAP_REQ_MODDN
484 #define LDAP_REQ_COMPARE	((ber_tag_t) 0x6eU)	/* application + constructed */
485 #define LDAP_REQ_ABANDON	((ber_tag_t) 0x50U)	/* application + primitive   */
486 #define LDAP_REQ_EXTENDED	((ber_tag_t) 0x77U)	/* application + constructed */
487 
488 /* LDAP Response Messages */
489 #define LDAP_RES_BIND		((ber_tag_t) 0x61U)	/* application + constructed */
490 #define LDAP_RES_SEARCH_ENTRY	((ber_tag_t) 0x64U)	/* application + constructed */
491 #define LDAP_RES_SEARCH_REFERENCE	((ber_tag_t) 0x73U)	/* V3: application + constructed */
492 #define LDAP_RES_SEARCH_RESULT	((ber_tag_t) 0x65U)	/* application + constructed */
493 #define LDAP_RES_MODIFY		((ber_tag_t) 0x67U)	/* application + constructed */
494 #define LDAP_RES_ADD		((ber_tag_t) 0x69U)	/* application + constructed */
495 #define LDAP_RES_DELETE		((ber_tag_t) 0x6bU)	/* application + constructed */
496 #define LDAP_RES_MODDN		((ber_tag_t) 0x6dU)	/* application + constructed */
497 #define LDAP_RES_MODRDN		LDAP_RES_MODDN	/* application + constructed */
498 #define LDAP_RES_RENAME		LDAP_RES_MODDN	/* application + constructed */
499 #define LDAP_RES_COMPARE	((ber_tag_t) 0x6fU)	/* application + constructed */
500 #define LDAP_RES_EXTENDED	((ber_tag_t) 0x78U)	/* V3: application + constructed */
501 #define LDAP_RES_INTERMEDIATE	((ber_tag_t) 0x79U) /* V3+: application + constructed */
502 
503 #define LDAP_RES_ANY			(-1)
504 #define LDAP_RES_UNSOLICITED	(0)
505 
506 
507 /* sasl methods */
508 #define LDAP_SASL_SIMPLE	((char*)0)
509 #define LDAP_SASL_NULL		("")
510 
511 
512 /* authentication methods available */
513 #define LDAP_AUTH_NONE   ((ber_tag_t) 0x00U) /* no authentication */
514 #define LDAP_AUTH_SIMPLE ((ber_tag_t) 0x80U) /* context specific + primitive */
515 #define LDAP_AUTH_SASL   ((ber_tag_t) 0xa3U) /* context specific + constructed */
516 #define LDAP_AUTH_KRBV4  ((ber_tag_t) 0xffU) /* means do both of the following */
517 #define LDAP_AUTH_KRBV41 ((ber_tag_t) 0x81U) /* context specific + primitive */
518 #define LDAP_AUTH_KRBV42 ((ber_tag_t) 0x82U) /* context specific + primitive */
519 
520 /* used by the Windows API but not used on the wire */
521 #define LDAP_AUTH_NEGOTIATE ((ber_tag_t) 0x04FFU)
522 
523 /* filter types */
524 #define LDAP_FILTER_AND	((ber_tag_t) 0xa0U)	/* context specific + constructed */
525 #define LDAP_FILTER_OR	((ber_tag_t) 0xa1U)	/* context specific + constructed */
526 #define LDAP_FILTER_NOT	((ber_tag_t) 0xa2U)	/* context specific + constructed */
527 #define LDAP_FILTER_EQUALITY ((ber_tag_t) 0xa3U) /* context specific + constructed */
528 #define LDAP_FILTER_SUBSTRINGS ((ber_tag_t) 0xa4U) /* context specific + constructed */
529 #define LDAP_FILTER_GE ((ber_tag_t) 0xa5U) /* context specific + constructed */
530 #define LDAP_FILTER_LE ((ber_tag_t) 0xa6U) /* context specific + constructed */
531 #define LDAP_FILTER_PRESENT ((ber_tag_t) 0x87U) /* context specific + primitive   */
532 #define LDAP_FILTER_APPROX ((ber_tag_t) 0xa8U)	/* context specific + constructed */
533 #define LDAP_FILTER_EXT	((ber_tag_t) 0xa9U)	/* context specific + constructed */
534 
535 /* extended filter component types */
536 #define LDAP_FILTER_EXT_OID		((ber_tag_t) 0x81U)	/* context specific */
537 #define LDAP_FILTER_EXT_TYPE	((ber_tag_t) 0x82U)	/* context specific */
538 #define LDAP_FILTER_EXT_VALUE	((ber_tag_t) 0x83U)	/* context specific */
539 #define LDAP_FILTER_EXT_DNATTRS	((ber_tag_t) 0x84U)	/* context specific */
540 
541 /* substring filter component types */
542 #define LDAP_SUBSTRING_INITIAL	((ber_tag_t) 0x80U)	/* context specific */
543 #define LDAP_SUBSTRING_ANY		((ber_tag_t) 0x81U)	/* context specific */
544 #define LDAP_SUBSTRING_FINAL	((ber_tag_t) 0x82U)	/* context specific */
545 
546 /* search scopes */
547 #define LDAP_SCOPE_BASE			((ber_int_t) 0x0000)
548 #define LDAP_SCOPE_BASEOBJECT	LDAP_SCOPE_BASE
549 #define LDAP_SCOPE_ONELEVEL		((ber_int_t) 0x0001)
550 #define LDAP_SCOPE_ONE			LDAP_SCOPE_ONELEVEL
551 #define LDAP_SCOPE_SUBTREE		((ber_int_t) 0x0002)
552 #define LDAP_SCOPE_SUB			LDAP_SCOPE_SUBTREE
553 #define LDAP_SCOPE_SUBORDINATE	((ber_int_t) 0x0003) /* OpenLDAP extension */
554 #define LDAP_SCOPE_CHILDREN		LDAP_SCOPE_SUBORDINATE
555 #define LDAP_SCOPE_DEFAULT		((ber_int_t) -1)	 /* OpenLDAP extension */
556 
557 /* substring filter component types */
558 #define LDAP_SUBSTRING_INITIAL	((ber_tag_t) 0x80U)	/* context specific */
559 #define LDAP_SUBSTRING_ANY		((ber_tag_t) 0x81U)	/* context specific */
560 #define LDAP_SUBSTRING_FINAL	((ber_tag_t) 0x82U)	/* context specific */
561 
562 /*
563  * LDAP Result Codes
564  */
565 #define LDAP_SUCCESS				0x00
566 
567 #define LDAP_RANGE(n,x,y)	(((x) <= (n)) && ((n) <= (y)))
568 
569 #define LDAP_OPERATIONS_ERROR		0x01
570 #define LDAP_PROTOCOL_ERROR			0x02
571 #define LDAP_TIMELIMIT_EXCEEDED		0x03
572 #define LDAP_SIZELIMIT_EXCEEDED		0x04
573 #define LDAP_COMPARE_FALSE			0x05
574 #define LDAP_COMPARE_TRUE			0x06
575 #define LDAP_AUTH_METHOD_NOT_SUPPORTED	0x07
576 #define LDAP_STRONG_AUTH_NOT_SUPPORTED	LDAP_AUTH_METHOD_NOT_SUPPORTED
577 #define LDAP_STRONG_AUTH_REQUIRED	0x08
578 #define LDAP_STRONGER_AUTH_REQUIRED	LDAP_STRONG_AUTH_REQUIRED
579 #define LDAP_PARTIAL_RESULTS		0x09	/* LDAPv2+ (not LDAPv3) */
580 
581 #define	LDAP_REFERRAL				0x0a /* LDAPv3 */
582 #define LDAP_ADMINLIMIT_EXCEEDED	0x0b /* LDAPv3 */
583 #define	LDAP_UNAVAILABLE_CRITICAL_EXTENSION	0x0c /* LDAPv3 */
584 #define LDAP_CONFIDENTIALITY_REQUIRED	0x0d /* LDAPv3 */
585 #define	LDAP_SASL_BIND_IN_PROGRESS	0x0e /* LDAPv3 */
586 
587 #define LDAP_ATTR_ERROR(n)	LDAP_RANGE((n),0x10,0x15) /* 16-21 */
588 
589 #define LDAP_NO_SUCH_ATTRIBUTE		0x10
590 #define LDAP_UNDEFINED_TYPE			0x11
591 #define LDAP_INAPPROPRIATE_MATCHING	0x12
592 #define LDAP_CONSTRAINT_VIOLATION	0x13
593 #define LDAP_TYPE_OR_VALUE_EXISTS	0x14
594 #define LDAP_INVALID_SYNTAX			0x15
595 
596 #define LDAP_NAME_ERROR(n)	LDAP_RANGE((n),0x20,0x24) /* 32-34,36 */
597 
598 #define LDAP_NO_SUCH_OBJECT			0x20
599 #define LDAP_ALIAS_PROBLEM			0x21
600 #define LDAP_INVALID_DN_SYNTAX		0x22
601 #define LDAP_IS_LEAF				0x23 /* not LDAPv3 */
602 #define LDAP_ALIAS_DEREF_PROBLEM	0x24
603 
604 #define LDAP_SECURITY_ERROR(n)	LDAP_RANGE((n),0x2F,0x32) /* 47-50 */
605 
606 #define LDAP_X_PROXY_AUTHZ_FAILURE	0x2F /* LDAPv3 proxy authorization */
607 #define LDAP_INAPPROPRIATE_AUTH		0x30
608 #define LDAP_INVALID_CREDENTIALS	0x31
609 #define LDAP_INSUFFICIENT_ACCESS	0x32
610 
611 #define LDAP_SERVICE_ERROR(n)	LDAP_RANGE((n),0x33,0x36) /* 51-54 */
612 
613 #define LDAP_BUSY					0x33
614 #define LDAP_UNAVAILABLE			0x34
615 #define LDAP_UNWILLING_TO_PERFORM	0x35
616 #define LDAP_LOOP_DETECT			0x36
617 
618 #define LDAP_UPDATE_ERROR(n)	LDAP_RANGE((n),0x40,0x47) /* 64-69,71 */
619 
620 #define LDAP_NAMING_VIOLATION		0x40
621 #define LDAP_OBJECT_CLASS_VIOLATION	0x41
622 #define LDAP_NOT_ALLOWED_ON_NONLEAF	0x42
623 #define LDAP_NOT_ALLOWED_ON_RDN		0x43
624 #define LDAP_ALREADY_EXISTS			0x44
625 #define LDAP_NO_OBJECT_CLASS_MODS	0x45
626 #define LDAP_RESULTS_TOO_LARGE		0x46 /* CLDAP */
627 #define LDAP_AFFECTS_MULTIPLE_DSAS	0x47
628 
629 #define LDAP_VLV_ERROR				0x4C
630 
631 #define LDAP_OTHER					0x50
632 
633 /* LCUP operation codes (113-117) - not implemented */
634 #define LDAP_CUP_RESOURCES_EXHAUSTED	0x71
635 #define LDAP_CUP_SECURITY_VIOLATION		0x72
636 #define LDAP_CUP_INVALID_DATA			0x73
637 #define LDAP_CUP_UNSUPPORTED_SCHEME		0x74
638 #define LDAP_CUP_RELOAD_REQUIRED		0x75
639 
640 /* Cancel operation codes (118-121) */
641 #define LDAP_CANCELLED				0x76
642 #define LDAP_NO_SUCH_OPERATION		0x77
643 #define LDAP_TOO_LATE				0x78
644 #define LDAP_CANNOT_CANCEL			0x79
645 
646 /* Assertion control (122) */
647 #define LDAP_ASSERTION_FAILED		0x7A
648 
649 /* Proxied Authorization Denied (123) */
650 #define LDAP_PROXIED_AUTHORIZATION_DENIED		0x7B
651 
652 /* Experimental result codes */
653 #define LDAP_E_ERROR(n)	LDAP_RANGE((n),0x1000,0x3FFF)
654 
655 /* LDAP Sync (4096) */
656 #define LDAP_SYNC_REFRESH_REQUIRED		0x1000
657 
658 
659 /* Private Use result codes */
660 #define LDAP_X_ERROR(n)	LDAP_RANGE((n),0x4000,0xFFFF)
661 
662 #define LDAP_X_SYNC_REFRESH_REQUIRED	0x4100 /* defunct */
663 #define LDAP_X_ASSERTION_FAILED			0x410f /* defunct */
664 
665 /* for the LDAP No-Op control */
666 #define LDAP_X_NO_OPERATION				0x410e
667 
668 /* for the Chaining Behavior control (consecutive result codes requested;
669  * see <draft-sermersheim-ldap-chaining> ) */
670 #ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
671 #define	LDAP_X_NO_REFERRALS_FOUND		0x4110
672 #define LDAP_X_CANNOT_CHAIN			0x4111
673 #endif
674 
675 /* for Distributed Procedures (see <draft-sermersheim-ldap-distproc>) */
676 #ifdef LDAP_X_DISTPROC_BASE
677 #define LDAP_X_INVALIDREFERENCE			0x4112
678 #endif
679 
680 #ifdef LDAP_X_TXN
681 #define LDAP_X_TXN_SPECIFY_OKAY		0x4120
682 #define LDAP_X_TXN_ID_INVALID		0x4121
683 #endif
684 
685 /* API Error Codes
686  *
687  * Based on draft-ietf-ldap-c-api-xx
688  * but with new negative code values
689  */
690 #define LDAP_API_ERROR(n)		((n)<0)
691 #define LDAP_API_RESULT(n)		((n)<=0)
692 
693 #define LDAP_SERVER_DOWN				(-1)
694 #define LDAP_LOCAL_ERROR				(-2)
695 #define LDAP_ENCODING_ERROR				(-3)
696 #define LDAP_DECODING_ERROR				(-4)
697 #define LDAP_TIMEOUT					(-5)
698 #define LDAP_AUTH_UNKNOWN				(-6)
699 #define LDAP_FILTER_ERROR				(-7)
700 #define LDAP_USER_CANCELLED				(-8)
701 #define LDAP_PARAM_ERROR				(-9)
702 #define LDAP_NO_MEMORY					(-10)
703 #define LDAP_CONNECT_ERROR				(-11)
704 #define LDAP_NOT_SUPPORTED				(-12)
705 #define LDAP_CONTROL_NOT_FOUND			(-13)
706 #define LDAP_NO_RESULTS_RETURNED		(-14)
707 #define LDAP_MORE_RESULTS_TO_RETURN		(-15)	/* Obsolete */
708 #define LDAP_CLIENT_LOOP				(-16)
709 #define LDAP_REFERRAL_LIMIT_EXCEEDED	(-17)
710 #define	LDAP_X_CONNECTING			(-18)
711 
712 
713 /*
714  * This structure represents both ldap messages and ldap responses.
715  * These are really the same, except in the case of search responses,
716  * where a response has multiple messages.
717  */
718 
719 typedef struct ldapmsg LDAPMessage;
720 
721 /* for modifications */
722 typedef struct ldapmod {
723 	int		mod_op;
724 
725 #define LDAP_MOD_OP			(0x0007)
726 #define LDAP_MOD_ADD		(0x0000)
727 #define LDAP_MOD_DELETE		(0x0001)
728 #define LDAP_MOD_REPLACE	(0x0002)
729 #define LDAP_MOD_INCREMENT	(0x0003) /* OpenLDAP extension */
730 #define LDAP_MOD_BVALUES	(0x0080)
731 /* IMPORTANT: do not use code 0x1000 (or above),
732  * it is used internally by the backends!
733  * (see ldap/servers/slapd/slap.h)
734  */
735 
736 	char		*mod_type;
737 	union mod_vals_u {
738 		char		**modv_strvals;
739 		struct berval	**modv_bvals;
740 	} mod_vals;
741 #define mod_values	mod_vals.modv_strvals
742 #define mod_bvalues	mod_vals.modv_bvals
743 } LDAPMod;
744 
745 /*
746  * structure representing an ldap session which can
747  * encompass connections to multiple servers (in the
748  * face of referrals).
749  */
750 typedef struct ldap LDAP;
751 
752 #define LDAP_DEREF_NEVER		0x00
753 #define LDAP_DEREF_SEARCHING	0x01
754 #define LDAP_DEREF_FINDING		0x02
755 #define LDAP_DEREF_ALWAYS		0x03
756 
757 #define LDAP_NO_LIMIT			0
758 
759 /* how many messages to retrieve results for */
760 #define LDAP_MSG_ONE			0x00
761 #define LDAP_MSG_ALL			0x01
762 #define LDAP_MSG_RECEIVED		0x02
763 
764 /*
765  * types for ldap URL handling
766  */
767 typedef struct ldap_url_desc {
768 	struct ldap_url_desc *lud_next;
769 	char	*lud_scheme;
770 	char	*lud_host;
771 	int		lud_port;
772 	char	*lud_dn;
773 	char	**lud_attrs;
774 	int		lud_scope;
775 	char	*lud_filter;
776 	char	**lud_exts;
777 	int		lud_crit_exts;
778 } LDAPURLDesc;
779 
780 #define LDAP_URL_SUCCESS		0x00	/* Success */
781 #define LDAP_URL_ERR_MEM		0x01	/* can't allocate memory space */
782 #define LDAP_URL_ERR_PARAM		0x02	/* parameter is bad */
783 
784 #define LDAP_URL_ERR_BADSCHEME	0x03	/* URL doesn't begin with "ldap[si]://" */
785 #define LDAP_URL_ERR_BADENCLOSURE 0x04	/* URL is missing trailing ">" */
786 #define LDAP_URL_ERR_BADURL		0x05	/* URL is bad */
787 #define LDAP_URL_ERR_BADHOST	0x06	/* host port is bad */
788 #define LDAP_URL_ERR_BADATTRS	0x07	/* bad (or missing) attributes */
789 #define LDAP_URL_ERR_BADSCOPE	0x08	/* scope string is invalid (or missing) */
790 #define LDAP_URL_ERR_BADFILTER	0x09	/* bad or missing filter */
791 #define LDAP_URL_ERR_BADEXTS	0x0a	/* bad or missing extensions */
792 
793 /*
794  * LDAP sync (RFC4533) API
795  */
796 
797 typedef struct ldap_sync_t ldap_sync_t;
798 
799 typedef enum {
800 	/* these are private - the client should never see them */
801 	LDAP_SYNC_CAPI_NONE		= -1,
802 
803 	LDAP_SYNC_CAPI_PHASE_FLAG	= 0x10U,
804 	LDAP_SYNC_CAPI_IDSET_FLAG	= 0x20U,
805 	LDAP_SYNC_CAPI_DONE_FLAG	= 0x40U,
806 
807 	/* these are passed to ls_search_entry() */
808 	LDAP_SYNC_CAPI_PRESENT		= LDAP_SYNC_PRESENT,
809 	LDAP_SYNC_CAPI_ADD		= LDAP_SYNC_ADD,
810 	LDAP_SYNC_CAPI_MODIFY		= LDAP_SYNC_MODIFY,
811 	LDAP_SYNC_CAPI_DELETE		= LDAP_SYNC_DELETE,
812 
813 	/* these are passed to ls_intermediate() */
814 	LDAP_SYNC_CAPI_PRESENTS		= ( LDAP_SYNC_CAPI_PHASE_FLAG | LDAP_SYNC_CAPI_PRESENT ),
815 	LDAP_SYNC_CAPI_DELETES		= ( LDAP_SYNC_CAPI_PHASE_FLAG | LDAP_SYNC_CAPI_DELETE ),
816 
817 	LDAP_SYNC_CAPI_PRESENTS_IDSET	= ( LDAP_SYNC_CAPI_PRESENTS | LDAP_SYNC_CAPI_IDSET_FLAG ),
818 	LDAP_SYNC_CAPI_DELETES_IDSET	= ( LDAP_SYNC_CAPI_DELETES | LDAP_SYNC_CAPI_IDSET_FLAG ),
819 
820 	LDAP_SYNC_CAPI_DONE		= ( LDAP_SYNC_CAPI_DONE_FLAG | LDAP_SYNC_CAPI_PRESENTS )
821 } ldap_sync_refresh_t;
822 
823 /*
824  * Called when an entry is returned by ldap_result().
825  * If phase is LDAP_SYNC_CAPI_ADD or LDAP_SYNC_CAPI_MODIFY,
826  * the entry has been either added or modified, and thus
827  * the complete view of the entry should be in the LDAPMessage.
828  * If phase is LDAP_SYNC_CAPI_PRESENT or LDAP_SYNC_CAPI_DELETE,
829  * only the DN should be in the LDAPMessage.
830  */
831 typedef int (*ldap_sync_search_entry_f) LDAP_P((
832 	ldap_sync_t			*ls,
833 	LDAPMessage			*msg,
834 	struct berval			*entryUUID,
835 	ldap_sync_refresh_t		phase ));
836 
837 /*
838  * Called when a reference is returned; the client should know
839  * what to do with it.
840  */
841 typedef int (*ldap_sync_search_reference_f) LDAP_P((
842 	ldap_sync_t			*ls,
843 	LDAPMessage			*msg ));
844 
845 /*
846  * Called when specific intermediate/final messages are returned.
847  * If phase is LDAP_SYNC_CAPI_PRESENTS or LDAP_SYNC_CAPI_DELETES,
848  * a "presents" or "deletes" phase begins.
849  * If phase is LDAP_SYNC_CAPI_DONE, a special "presents" phase
850  * with refreshDone set to "TRUE" has been returned, to indicate
851  * that the refresh phase of a refreshAndPersist is complete.
852  * In the above cases, syncUUIDs is NULL.
853  *
854  * If phase is LDAP_SYNC_CAPI_PRESENTS_IDSET or
855  * LDAP_SYNC_CAPI_DELETES_IDSET, syncUUIDs is an array of UUIDs
856  * that are either present or have been deleted.
857  */
858 typedef int (*ldap_sync_intermediate_f) LDAP_P((
859 	ldap_sync_t			*ls,
860 	LDAPMessage			*msg,
861 	BerVarray			syncUUIDs,
862 	ldap_sync_refresh_t		phase ));
863 
864 /*
865  * Called when a searchResultDone is returned.  In refreshAndPersist,
866  * this can only occur if the search for any reason is being terminated
867  * by the server.
868  */
869 typedef int (*ldap_sync_search_result_f) LDAP_P((
870 	ldap_sync_t			*ls,
871 	LDAPMessage			*msg,
872 	int				refreshDeletes ));
873 
874 /*
875  * This structure contains all information about the persistent search;
876  * the caller is responsible for connecting, setting version, binding, tls...
877  */
878 struct ldap_sync_t {
879 	/* conf search params */
880 	char				*ls_base;
881 	int				ls_scope;
882 	char				*ls_filter;
883 	char				**ls_attrs;
884 	int				ls_timelimit;
885 	int				ls_sizelimit;
886 
887 	/* poll timeout */
888 	int				ls_timeout;
889 
890 	/* helpers - add as appropriate */
891 	ldap_sync_search_entry_f	ls_search_entry;
892 	ldap_sync_search_reference_f	ls_search_reference;
893 	ldap_sync_intermediate_f	ls_intermediate;
894 	ldap_sync_search_result_f	ls_search_result;
895 
896 	/* set by the caller as appropriate */
897 	void				*ls_private;
898 
899 	/* conn stuff */
900 	LDAP				*ls_ld;
901 
902 	/* --- the parameters below are private - do not modify --- */
903 
904 	/* FIXME: make the structure opaque, and provide an interface
905 	 * to modify the public values? */
906 
907 	/* result stuff */
908 	int				ls_msgid;
909 
910 	/* sync stuff */
911 	/* needed by refreshOnly */
912 	int				ls_reloadHint;
913 
914 	/* opaque - need to pass between sessions, updated by the API */
915 	struct berval			ls_cookie;
916 
917 	/* state variable - do not modify */
918 	ldap_sync_refresh_t		ls_refreshPhase;
919 };
920 
921 /*
922  * End of LDAP sync (RFC4533) API
923  */
924 
925 /*
926  * Connection callbacks...
927  */
928 struct ldap_conncb;
929 struct sockaddr;
930 
931 /* Called after a connection is established */
932 typedef int (ldap_conn_add_f) LDAP_P(( LDAP *ld, Sockbuf *sb, LDAPURLDesc *srv, struct sockaddr *addr,
933 	struct ldap_conncb *ctx ));
934 /* Called before a connection is closed */
935 typedef void (ldap_conn_del_f) LDAP_P(( LDAP *ld, Sockbuf *sb, struct ldap_conncb *ctx ));
936 
937 /* Callbacks are pushed on a stack. Last one pushed is first one executed. The
938  * delete callback is called with a NULL Sockbuf just before freeing the LDAP handle.
939  */
940 typedef struct ldap_conncb {
941 	ldap_conn_add_f *lc_add;
942 	ldap_conn_del_f *lc_del;
943 	void *lc_arg;
944 } ldap_conncb;
945 
946 /*
947  * The API draft spec says we should declare (or cause to be declared)
948  * 'struct timeval'.   We don't.  See IETF LDAPext discussions.
949  */
950 struct timeval;
951 
952 /*
953  * in options.c:
954  */
955 LDAP_F( int )
956 ldap_get_option LDAP_P((
957 	LDAP *ld,
958 	int option,
959 	void *outvalue));
960 
961 LDAP_F( int )
962 ldap_set_option LDAP_P((
963 	LDAP *ld,
964 	int option,
965 	LDAP_CONST void *invalue));
966 
967 /* V3 REBIND Function Callback Prototype */
968 typedef int (LDAP_REBIND_PROC) LDAP_P((
969 	LDAP *ld, LDAP_CONST char *url,
970 	ber_tag_t request, ber_int_t msgid,
971 	void *params ));
972 
973 LDAP_F( int )
974 ldap_set_rebind_proc LDAP_P((
975 	LDAP *ld,
976 	LDAP_REBIND_PROC *rebind_proc,
977 	void *params ));
978 
979 /* V3 referral selection Function Callback Prototype */
980 typedef int (LDAP_NEXTREF_PROC) LDAP_P((
981 	LDAP *ld, char ***refsp, int *cntp,
982 	void *params ));
983 
984 LDAP_F( int )
985 ldap_set_nextref_proc LDAP_P((
986 	LDAP *ld,
987 	LDAP_NEXTREF_PROC *nextref_proc,
988 	void *params ));
989 
990 /* V3 URLLIST Function Callback Prototype */
991 typedef int (LDAP_URLLIST_PROC) LDAP_P((
992 	LDAP *ld,
993 	LDAPURLDesc **urllist,
994 	LDAPURLDesc **url,
995 	void *params ));
996 
997 LDAP_F( int )
998 ldap_set_urllist_proc LDAP_P((
999 	LDAP *ld,
1000 	LDAP_URLLIST_PROC *urllist_proc,
1001 	void *params ));
1002 
1003 /*
1004  * in controls.c:
1005  */
1006 #if LDAP_DEPRECATED
1007 LDAP_F( int )
1008 ldap_create_control LDAP_P((	/* deprecated, use ldap_control_create */
1009 	LDAP_CONST char *requestOID,
1010 	BerElement *ber,
1011 	int iscritical,
1012 	LDAPControl **ctrlp ));
1013 
1014 LDAP_F( LDAPControl * )
1015 ldap_find_control LDAP_P((	/* deprecated, use ldap_control_find */
1016 	LDAP_CONST char *oid,
1017 	LDAPControl **ctrls ));
1018 #endif
1019 
1020 LDAP_F( int )
1021 ldap_control_create LDAP_P((
1022 	LDAP_CONST char *requestOID,
1023 	int iscritical,
1024 	struct berval *value,
1025 	int dupval,
1026 	LDAPControl **ctrlp ));
1027 
1028 LDAP_F( LDAPControl * )
1029 ldap_control_find LDAP_P((
1030 	LDAP_CONST char *oid,
1031 	LDAPControl **ctrls,
1032 	LDAPControl ***nextctrlp ));
1033 
1034 LDAP_F( void )
1035 ldap_control_free LDAP_P((
1036 	LDAPControl *ctrl ));
1037 
1038 LDAP_F( void )
1039 ldap_controls_free LDAP_P((
1040 	LDAPControl **ctrls ));
1041 
1042 LDAP_F( LDAPControl ** )
1043 ldap_controls_dup LDAP_P((
1044 	LDAPControl *LDAP_CONST *controls ));
1045 
1046 LDAP_F( LDAPControl * )
1047 ldap_control_dup LDAP_P((
1048 	LDAP_CONST LDAPControl *c ));
1049 
1050 /*
1051  * in dnssrv.c:
1052  */
1053 LDAP_F( int )
1054 ldap_domain2dn LDAP_P((
1055 	LDAP_CONST char* domain,
1056 	char** dn ));
1057 
1058 LDAP_F( int )
1059 ldap_dn2domain LDAP_P((
1060 	LDAP_CONST char* dn,
1061 	char** domain ));
1062 
1063 LDAP_F( int )
1064 ldap_domain2hostlist LDAP_P((
1065 	LDAP_CONST char *domain,
1066 	char** hostlist ));
1067 
1068 /*
1069  * in extended.c:
1070  */
1071 LDAP_F( int )
1072 ldap_extended_operation LDAP_P((
1073 	LDAP			*ld,
1074 	LDAP_CONST char	*reqoid,
1075 	struct berval	*reqdata,
1076 	LDAPControl		**serverctrls,
1077 	LDAPControl		**clientctrls,
1078 	int				*msgidp ));
1079 
1080 LDAP_F( int )
1081 ldap_extended_operation_s LDAP_P((
1082 	LDAP			*ld,
1083 	LDAP_CONST char	*reqoid,
1084 	struct berval	*reqdata,
1085 	LDAPControl		**serverctrls,
1086 	LDAPControl		**clientctrls,
1087 	char			**retoidp,
1088 	struct berval	**retdatap ));
1089 
1090 LDAP_F( int )
1091 ldap_parse_extended_result LDAP_P((
1092 	LDAP			*ld,
1093 	LDAPMessage		*res,
1094 	char			**retoidp,
1095 	struct berval	**retdatap,
1096 	int				freeit ));
1097 
1098 LDAP_F( int )
1099 ldap_parse_intermediate LDAP_P((
1100 	LDAP			*ld,
1101 	LDAPMessage		*res,
1102 	char			**retoidp,
1103 	struct berval	**retdatap,
1104 	LDAPControl		***serverctrls,
1105 	int				freeit ));
1106 
1107 
1108 /*
1109  * in abandon.c:
1110  */
1111 LDAP_F( int )
1112 ldap_abandon_ext LDAP_P((
1113 	LDAP			*ld,
1114 	int				msgid,
1115 	LDAPControl		**serverctrls,
1116 	LDAPControl		**clientctrls ));
1117 
1118 #if LDAP_DEPRECATED
1119 LDAP_F( int )
1120 ldap_abandon LDAP_P((	/* deprecated, use ldap_abandon_ext */
1121 	LDAP *ld,
1122 	int msgid ));
1123 #endif
1124 
1125 /*
1126  * in add.c:
1127  */
1128 LDAP_F( int )
1129 ldap_add_ext LDAP_P((
1130 	LDAP			*ld,
1131 	LDAP_CONST char	*dn,
1132 	LDAPMod			**attrs,
1133 	LDAPControl		**serverctrls,
1134 	LDAPControl		**clientctrls,
1135 	int 			*msgidp ));
1136 
1137 LDAP_F( int )
1138 ldap_add_ext_s LDAP_P((
1139 	LDAP			*ld,
1140 	LDAP_CONST char	*dn,
1141 	LDAPMod			**attrs,
1142 	LDAPControl		**serverctrls,
1143 	LDAPControl		**clientctrls ));
1144 
1145 #if LDAP_DEPRECATED
1146 LDAP_F( int )
1147 ldap_add LDAP_P((	/* deprecated, use ldap_add_ext */
1148 	LDAP *ld,
1149 	LDAP_CONST char *dn,
1150 	LDAPMod **attrs ));
1151 
1152 LDAP_F( int )
1153 ldap_add_s LDAP_P((	/* deprecated, use ldap_add_ext_s */
1154 	LDAP *ld,
1155 	LDAP_CONST char *dn,
1156 	LDAPMod **attrs ));
1157 #endif
1158 
1159 
1160 /*
1161  * in sasl.c:
1162  */
1163 LDAP_F( int )
1164 ldap_sasl_bind LDAP_P((
1165 	LDAP			*ld,
1166 	LDAP_CONST char	*dn,
1167 	LDAP_CONST char	*mechanism,
1168 	struct berval	*cred,
1169 	LDAPControl		**serverctrls,
1170 	LDAPControl		**clientctrls,
1171 	int				*msgidp ));
1172 
1173 /* Interaction flags (should be passed about in a control)
1174  *  Automatic (default): use defaults, prompt otherwise
1175  *  Interactive: prompt always
1176  *  Quiet: never prompt
1177  */
1178 #define LDAP_SASL_AUTOMATIC		0U
1179 #define LDAP_SASL_INTERACTIVE	1U
1180 #define LDAP_SASL_QUIET			2U
1181 
1182 /*
1183  * V3 SASL Interaction Function Callback Prototype
1184  *	when using Cyrus SASL, interact is pointer to sasl_interact_t
1185  *  should likely passed in a control (and provided controls)
1186  */
1187 typedef int (LDAP_SASL_INTERACT_PROC) LDAP_P((
1188 	LDAP *ld, unsigned flags, void* defaults, void *interact ));
1189 
1190 LDAP_F( int )
1191 ldap_sasl_interactive_bind_s LDAP_P((
1192 	LDAP *ld,
1193 	LDAP_CONST char *dn, /* usually NULL */
1194 	LDAP_CONST char *saslMechanism,
1195 	LDAPControl **serverControls,
1196 	LDAPControl **clientControls,
1197 
1198 	/* should be client controls */
1199 	unsigned flags,
1200 	LDAP_SASL_INTERACT_PROC *proc,
1201 	void *defaults ));
1202 
1203 LDAP_F( int )
1204 ldap_sasl_bind_s LDAP_P((
1205 	LDAP			*ld,
1206 	LDAP_CONST char	*dn,
1207 	LDAP_CONST char	*mechanism,
1208 	struct berval	*cred,
1209 	LDAPControl		**serverctrls,
1210 	LDAPControl		**clientctrls,
1211 	struct berval	**servercredp ));
1212 
1213 LDAP_F( int )
1214 ldap_parse_sasl_bind_result LDAP_P((
1215 	LDAP			*ld,
1216 	LDAPMessage		*res,
1217 	struct berval	**servercredp,
1218 	int				freeit ));
1219 
1220 #if LDAP_DEPRECATED
1221 /*
1222  * in bind.c:
1223  *	(deprecated)
1224  */
1225 LDAP_F( int )
1226 ldap_bind LDAP_P((	/* deprecated, use ldap_sasl_bind */
1227 	LDAP *ld,
1228 	LDAP_CONST char *who,
1229 	LDAP_CONST char *passwd,
1230 	int authmethod ));
1231 
1232 LDAP_F( int )
1233 ldap_bind_s LDAP_P((	/* deprecated, use ldap_sasl_bind_s */
1234 	LDAP *ld,
1235 	LDAP_CONST char *who,
1236 	LDAP_CONST char *cred,
1237 	int authmethod ));
1238 
1239 /*
1240  * in sbind.c:
1241  */
1242 LDAP_F( int )
1243 ldap_simple_bind LDAP_P(( /* deprecated, use ldap_sasl_bind */
1244 	LDAP *ld,
1245 	LDAP_CONST char *who,
1246 	LDAP_CONST char *passwd ));
1247 
1248 LDAP_F( int )
1249 ldap_simple_bind_s LDAP_P(( /* deprecated, use ldap_sasl_bind_s */
1250 	LDAP *ld,
1251 	LDAP_CONST char *who,
1252 	LDAP_CONST char *passwd ));
1253 
1254 #endif
1255 
1256 
1257 /*
1258  * in compare.c:
1259  */
1260 LDAP_F( int )
1261 ldap_compare_ext LDAP_P((
1262 	LDAP			*ld,
1263 	LDAP_CONST char	*dn,
1264 	LDAP_CONST char	*attr,
1265 	struct berval	*bvalue,
1266 	LDAPControl		**serverctrls,
1267 	LDAPControl		**clientctrls,
1268 	int 			*msgidp ));
1269 
1270 LDAP_F( int )
1271 ldap_compare_ext_s LDAP_P((
1272 	LDAP			*ld,
1273 	LDAP_CONST char	*dn,
1274 	LDAP_CONST char	*attr,
1275 	struct berval	*bvalue,
1276 	LDAPControl		**serverctrls,
1277 	LDAPControl		**clientctrls ));
1278 
1279 #if LDAP_DEPRECATED
1280 LDAP_F( int )
1281 ldap_compare LDAP_P((	/* deprecated, use ldap_compare_ext */
1282 	LDAP *ld,
1283 	LDAP_CONST char *dn,
1284 	LDAP_CONST char *attr,
1285 	LDAP_CONST char *value ));
1286 
1287 LDAP_F( int )
1288 ldap_compare_s LDAP_P((	/* deprecated, use ldap_compare_ext_s */
1289 	LDAP *ld,
1290 	LDAP_CONST char *dn,
1291 	LDAP_CONST char *attr,
1292 	LDAP_CONST char *value ));
1293 #endif
1294 
1295 
1296 /*
1297  * in delete.c:
1298  */
1299 LDAP_F( int )
1300 ldap_delete_ext LDAP_P((
1301 	LDAP			*ld,
1302 	LDAP_CONST char	*dn,
1303 	LDAPControl		**serverctrls,
1304 	LDAPControl		**clientctrls,
1305 	int 			*msgidp ));
1306 
1307 LDAP_F( int )
1308 ldap_delete_ext_s LDAP_P((
1309 	LDAP			*ld,
1310 	LDAP_CONST char	*dn,
1311 	LDAPControl		**serverctrls,
1312 	LDAPControl		**clientctrls ));
1313 
1314 #if LDAP_DEPRECATED
1315 LDAP_F( int )
1316 ldap_delete LDAP_P((	/* deprecated, use ldap_delete_ext */
1317 	LDAP *ld,
1318 	LDAP_CONST char *dn ));
1319 
1320 LDAP_F( int )
1321 ldap_delete_s LDAP_P((	/* deprecated, use ldap_delete_ext_s */
1322 	LDAP *ld,
1323 	LDAP_CONST char *dn ));
1324 #endif
1325 
1326 
1327 /*
1328  * in error.c:
1329  */
1330 LDAP_F( int )
1331 ldap_parse_result LDAP_P((
1332 	LDAP			*ld,
1333 	LDAPMessage		*res,
1334 	int				*errcodep,
1335 	char			**matcheddnp,
1336 	char			**errmsgp,
1337 	char			***referralsp,
1338 	LDAPControl		***serverctrls,
1339 	int				freeit ));
1340 
1341 LDAP_F( char * )
1342 ldap_err2string LDAP_P((
1343 	int err ));
1344 
1345 #if LDAP_DEPRECATED
1346 LDAP_F( int )
1347 ldap_result2error LDAP_P((	/* deprecated, use ldap_parse_result */
1348 	LDAP *ld,
1349 	LDAPMessage *r,
1350 	int freeit ));
1351 
1352 LDAP_F( void )
1353 ldap_perror LDAP_P((	/* deprecated, use ldap_err2string */
1354 	LDAP *ld,
1355 	LDAP_CONST char *s ));
1356 #endif
1357 
1358 
1359 /*
1360  * gssapi.c:
1361  */
1362 LDAP_F( int )
1363 ldap_gssapi_bind LDAP_P((
1364 	LDAP *ld,
1365 	LDAP_CONST char *dn,
1366 	LDAP_CONST char *creds ));
1367 
1368 LDAP_F( int )
1369 ldap_gssapi_bind_s LDAP_P((
1370 	LDAP *ld,
1371 	LDAP_CONST char *dn,
1372 	LDAP_CONST char *creds ));
1373 
1374 
1375 /*
1376  * in modify.c:
1377  */
1378 LDAP_F( int )
1379 ldap_modify_ext LDAP_P((
1380 	LDAP			*ld,
1381 	LDAP_CONST char	*dn,
1382 	LDAPMod			**mods,
1383 	LDAPControl		**serverctrls,
1384 	LDAPControl		**clientctrls,
1385 	int 			*msgidp ));
1386 
1387 LDAP_F( int )
1388 ldap_modify_ext_s LDAP_P((
1389 	LDAP			*ld,
1390 	LDAP_CONST char	*dn,
1391 	LDAPMod			**mods,
1392 	LDAPControl		**serverctrls,
1393 	LDAPControl		**clientctrls ));
1394 
1395 #if LDAP_DEPRECATED
1396 LDAP_F( int )
1397 ldap_modify LDAP_P((	/* deprecated, use ldap_modify_ext */
1398 	LDAP *ld,
1399 	LDAP_CONST char *dn,
1400 	LDAPMod **mods ));
1401 
1402 LDAP_F( int )
1403 ldap_modify_s LDAP_P((	/* deprecated, use ldap_modify_ext_s */
1404 	LDAP *ld,
1405 	LDAP_CONST char *dn,
1406 	LDAPMod **mods ));
1407 #endif
1408 
1409 
1410 /*
1411  * in modrdn.c:
1412  */
1413 LDAP_F( int )
1414 ldap_rename LDAP_P((
1415 	LDAP *ld,
1416 	LDAP_CONST char *dn,
1417 	LDAP_CONST char *newrdn,
1418 	LDAP_CONST char *newSuperior,
1419 	int deleteoldrdn,
1420 	LDAPControl **sctrls,
1421 	LDAPControl **cctrls,
1422 	int *msgidp ));
1423 
1424 LDAP_F( int )
1425 ldap_rename_s LDAP_P((
1426 	LDAP *ld,
1427 	LDAP_CONST char *dn,
1428 	LDAP_CONST char *newrdn,
1429 	LDAP_CONST char *newSuperior,
1430 	int deleteoldrdn,
1431 	LDAPControl **sctrls,
1432 	LDAPControl **cctrls ));
1433 
1434 #if LDAP_DEPRECATED
1435 LDAP_F( int )
1436 ldap_rename2 LDAP_P((	/* deprecated, use ldap_rename */
1437 	LDAP *ld,
1438 	LDAP_CONST char *dn,
1439 	LDAP_CONST char *newrdn,
1440 	LDAP_CONST char *newSuperior,
1441 	int deleteoldrdn ));
1442 
1443 LDAP_F( int )
1444 ldap_rename2_s LDAP_P((	/* deprecated, use ldap_rename_s */
1445 	LDAP *ld,
1446 	LDAP_CONST char *dn,
1447 	LDAP_CONST char *newrdn,
1448 	LDAP_CONST char *newSuperior,
1449 	int deleteoldrdn ));
1450 
1451 LDAP_F( int )
1452 ldap_modrdn LDAP_P((	/* deprecated, use ldap_rename */
1453 	LDAP *ld,
1454 	LDAP_CONST char *dn,
1455 	LDAP_CONST char *newrdn ));
1456 
1457 LDAP_F( int )
1458 ldap_modrdn_s LDAP_P((	/* deprecated, use ldap_rename_s */
1459 	LDAP *ld,
1460 	LDAP_CONST char *dn,
1461 	LDAP_CONST char *newrdn ));
1462 
1463 LDAP_F( int )
1464 ldap_modrdn2 LDAP_P((	/* deprecated, use ldap_rename */
1465 	LDAP *ld,
1466 	LDAP_CONST char *dn,
1467 	LDAP_CONST char *newrdn,
1468 	int deleteoldrdn ));
1469 
1470 LDAP_F( int )
1471 ldap_modrdn2_s LDAP_P((	/* deprecated, use ldap_rename_s */
1472 	LDAP *ld,
1473 	LDAP_CONST char *dn,
1474 	LDAP_CONST char *newrdn,
1475 	int deleteoldrdn));
1476 #endif
1477 
1478 
1479 /*
1480  * in open.c:
1481  */
1482 #if LDAP_DEPRECATED
1483 LDAP_F( LDAP * )
1484 ldap_init LDAP_P(( /* deprecated, use ldap_create or ldap_initialize */
1485 	LDAP_CONST char *host,
1486 	int port ));
1487 
1488 LDAP_F( LDAP * )
1489 ldap_open LDAP_P((	/* deprecated, use ldap_create or ldap_initialize */
1490 	LDAP_CONST char *host,
1491 	int port ));
1492 #endif
1493 
1494 LDAP_F( int )
1495 ldap_create LDAP_P((
1496 	LDAP **ldp ));
1497 
1498 LDAP_F( int )
1499 ldap_initialize LDAP_P((
1500 	LDAP **ldp,
1501 	LDAP_CONST char *url ));
1502 
1503 /*
1504  * in tls.c
1505  */
1506 
1507 LDAP_F( int )
1508 ldap_tls_inplace LDAP_P((
1509 	LDAP *ld ));
1510 
1511 LDAP_F( int )
1512 ldap_start_tls LDAP_P((
1513 	LDAP *ld,
1514 	LDAPControl **serverctrls,
1515 	LDAPControl **clientctrls,
1516 	int *msgidp ));
1517 
1518 LDAP_F( int )
1519 ldap_install_tls LDAP_P((
1520 	LDAP *ld ));
1521 
1522 LDAP_F( int )
1523 ldap_start_tls_s LDAP_P((
1524 	LDAP *ld,
1525 	LDAPControl **serverctrls,
1526 	LDAPControl **clientctrls ));
1527 
1528 /*
1529  * in messages.c:
1530  */
1531 LDAP_F( LDAPMessage * )
1532 ldap_first_message LDAP_P((
1533 	LDAP *ld,
1534 	LDAPMessage *chain ));
1535 
1536 LDAP_F( LDAPMessage * )
1537 ldap_next_message LDAP_P((
1538 	LDAP *ld,
1539 	LDAPMessage *msg ));
1540 
1541 LDAP_F( int )
1542 ldap_count_messages LDAP_P((
1543 	LDAP *ld,
1544 	LDAPMessage *chain ));
1545 
1546 /*
1547  * in references.c:
1548  */
1549 LDAP_F( LDAPMessage * )
1550 ldap_first_reference LDAP_P((
1551 	LDAP *ld,
1552 	LDAPMessage *chain ));
1553 
1554 LDAP_F( LDAPMessage * )
1555 ldap_next_reference LDAP_P((
1556 	LDAP *ld,
1557 	LDAPMessage *ref ));
1558 
1559 LDAP_F( int )
1560 ldap_count_references LDAP_P((
1561 	LDAP *ld,
1562 	LDAPMessage *chain ));
1563 
1564 LDAP_F( int )
1565 ldap_parse_reference LDAP_P((
1566 	LDAP			*ld,
1567 	LDAPMessage		*ref,
1568 	char			***referralsp,
1569 	LDAPControl		***serverctrls,
1570 	int				freeit));
1571 
1572 
1573 /*
1574  * in getentry.c:
1575  */
1576 LDAP_F( LDAPMessage * )
1577 ldap_first_entry LDAP_P((
1578 	LDAP *ld,
1579 	LDAPMessage *chain ));
1580 
1581 LDAP_F( LDAPMessage * )
1582 ldap_next_entry LDAP_P((
1583 	LDAP *ld,
1584 	LDAPMessage *entry ));
1585 
1586 LDAP_F( int )
1587 ldap_count_entries LDAP_P((
1588 	LDAP *ld,
1589 	LDAPMessage *chain ));
1590 
1591 LDAP_F( int )
1592 ldap_get_entry_controls LDAP_P((
1593 	LDAP			*ld,
1594 	LDAPMessage		*entry,
1595 	LDAPControl		***serverctrls));
1596 
1597 
1598 /*
1599  * in addentry.c
1600  */
1601 LDAP_F( LDAPMessage * )
1602 ldap_delete_result_entry LDAP_P((
1603 	LDAPMessage **list,
1604 	LDAPMessage *e ));
1605 
1606 LDAP_F( void )
1607 ldap_add_result_entry LDAP_P((
1608 	LDAPMessage **list,
1609 	LDAPMessage *e ));
1610 
1611 
1612 /*
1613  * in getdn.c
1614  */
1615 LDAP_F( char * )
1616 ldap_get_dn LDAP_P((
1617 	LDAP *ld,
1618 	LDAPMessage *entry ));
1619 
1620 typedef struct ldap_ava {
1621 	struct berval la_attr;
1622 	struct berval la_value;
1623 	unsigned la_flags;
1624 #define LDAP_AVA_NULL				0x0000U
1625 #define LDAP_AVA_STRING				0x0001U
1626 #define LDAP_AVA_BINARY				0x0002U
1627 #define LDAP_AVA_NONPRINTABLE		0x0004U
1628 #define LDAP_AVA_FREE_ATTR			0x0010U
1629 #define LDAP_AVA_FREE_VALUE			0x0020U
1630 
1631 	void *la_private;
1632 } LDAPAVA;
1633 
1634 typedef LDAPAVA** LDAPRDN;
1635 typedef LDAPRDN* LDAPDN;
1636 
1637 /* DN formats */
1638 #define LDAP_DN_FORMAT_LDAP			0x0000U
1639 #define LDAP_DN_FORMAT_LDAPV3		0x0010U
1640 #define LDAP_DN_FORMAT_LDAPV2		0x0020U
1641 #define LDAP_DN_FORMAT_DCE			0x0030U
1642 #define LDAP_DN_FORMAT_UFN			0x0040U	/* dn2str only */
1643 #define LDAP_DN_FORMAT_AD_CANONICAL	0x0050U	/* dn2str only */
1644 #define LDAP_DN_FORMAT_LBER			0x00F0U /* for testing only */
1645 #define LDAP_DN_FORMAT_MASK			0x00F0U
1646 
1647 /* DN flags */
1648 #define LDAP_DN_PRETTY				0x0100U
1649 #define LDAP_DN_SKIP				0x0200U
1650 #define LDAP_DN_P_NOLEADTRAILSPACES	0x1000U
1651 #define LDAP_DN_P_NOSPACEAFTERRDN	0x2000U
1652 #define LDAP_DN_PEDANTIC			0xF000U
1653 
1654 LDAP_F( void ) ldap_rdnfree LDAP_P(( LDAPRDN rdn ));
1655 LDAP_F( void ) ldap_dnfree LDAP_P(( LDAPDN dn ));
1656 
1657 LDAP_F( int )
1658 ldap_bv2dn LDAP_P((
1659 	struct berval *bv,
1660 	LDAPDN *dn,
1661 	unsigned flags ));
1662 
1663 LDAP_F( int )
1664 ldap_str2dn LDAP_P((
1665 	LDAP_CONST char *str,
1666 	LDAPDN *dn,
1667 	unsigned flags ));
1668 
1669 LDAP_F( int )
1670 ldap_dn2bv LDAP_P((
1671 	LDAPDN dn,
1672 	struct berval *bv,
1673 	unsigned flags ));
1674 
1675 LDAP_F( int )
1676 ldap_dn2str LDAP_P((
1677 	LDAPDN dn,
1678 	char **str,
1679 	unsigned flags ));
1680 
1681 LDAP_F( int )
1682 ldap_bv2rdn LDAP_P((
1683 	struct berval *bv,
1684 	LDAPRDN *rdn,
1685 	char **next,
1686 	unsigned flags ));
1687 
1688 LDAP_F( int )
1689 ldap_str2rdn LDAP_P((
1690 	LDAP_CONST char *str,
1691 	LDAPRDN *rdn,
1692 	char **next,
1693 	unsigned flags ));
1694 
1695 LDAP_F( int )
1696 ldap_rdn2bv LDAP_P((
1697 	LDAPRDN rdn,
1698 	struct berval *bv,
1699 	unsigned flags ));
1700 
1701 LDAP_F( int )
1702 ldap_rdn2str LDAP_P((
1703 	LDAPRDN rdn,
1704 	char **str,
1705 	unsigned flags ));
1706 
1707 LDAP_F( int )
1708 ldap_dn_normalize LDAP_P((
1709 	LDAP_CONST char *in, unsigned iflags,
1710 	char **out, unsigned oflags ));
1711 
1712 LDAP_F( char * )
1713 ldap_dn2ufn LDAP_P(( /* deprecated, use ldap_str2dn/dn2str */
1714 	LDAP_CONST char *dn ));
1715 
1716 LDAP_F( char ** )
1717 ldap_explode_dn LDAP_P(( /* deprecated, ldap_str2dn */
1718 	LDAP_CONST char *dn,
1719 	int notypes ));
1720 
1721 LDAP_F( char ** )
1722 ldap_explode_rdn LDAP_P(( /* deprecated, ldap_str2rdn */
1723 	LDAP_CONST char *rdn,
1724 	int notypes ));
1725 
1726 typedef int LDAPDN_rewrite_func
1727 	LDAP_P(( LDAPDN dn, unsigned flags, void *ctx ));
1728 
1729 LDAP_F( int )
1730 ldap_X509dn2bv LDAP_P(( void *x509_name, struct berval *dn,
1731 	LDAPDN_rewrite_func *func, unsigned flags ));
1732 
1733 LDAP_F( char * )
1734 ldap_dn2dcedn LDAP_P(( /* deprecated, ldap_str2dn/dn2str */
1735 	LDAP_CONST char *dn ));
1736 
1737 LDAP_F( char * )
1738 ldap_dcedn2dn LDAP_P(( /* deprecated, ldap_str2dn/dn2str */
1739 	LDAP_CONST char *dce ));
1740 
1741 LDAP_F( char * )
1742 ldap_dn2ad_canonical LDAP_P(( /* deprecated, ldap_str2dn/dn2str */
1743 	LDAP_CONST char *dn ));
1744 
1745 LDAP_F( int )
1746 ldap_get_dn_ber LDAP_P((
1747 	LDAP *ld, LDAPMessage *e, BerElement **berout, struct berval *dn ));
1748 
1749 LDAP_F( int )
1750 ldap_get_attribute_ber LDAP_P((
1751 	LDAP *ld, LDAPMessage *e, BerElement *ber, struct berval *attr,
1752 	struct berval **vals ));
1753 
1754 /*
1755  * in getattr.c
1756  */
1757 LDAP_F( char * )
1758 ldap_first_attribute LDAP_P((
1759 	LDAP *ld,
1760 	LDAPMessage *entry,
1761 	BerElement **ber ));
1762 
1763 LDAP_F( char * )
1764 ldap_next_attribute LDAP_P((
1765 	LDAP *ld,
1766 	LDAPMessage *entry,
1767 	BerElement *ber ));
1768 
1769 
1770 /*
1771  * in getvalues.c
1772  */
1773 LDAP_F( struct berval ** )
1774 ldap_get_values_len LDAP_P((
1775 	LDAP *ld,
1776 	LDAPMessage *entry,
1777 	LDAP_CONST char *target ));
1778 
1779 LDAP_F( int )
1780 ldap_count_values_len LDAP_P((
1781 	struct berval **vals ));
1782 
1783 LDAP_F( void )
1784 ldap_value_free_len LDAP_P((
1785 	struct berval **vals ));
1786 
1787 #if LDAP_DEPRECATED
1788 LDAP_F( char ** )
1789 ldap_get_values LDAP_P((	/* deprecated, use ldap_get_values_len */
1790 	LDAP *ld,
1791 	LDAPMessage *entry,
1792 	LDAP_CONST char *target ));
1793 
1794 LDAP_F( int )
1795 ldap_count_values LDAP_P((	/* deprecated, use ldap_count_values_len */
1796 	char **vals ));
1797 
1798 LDAP_F( void )
1799 ldap_value_free LDAP_P((	/* deprecated, use ldap_value_free_len */
1800 	char **vals ));
1801 #endif
1802 
1803 /*
1804  * in result.c:
1805  */
1806 LDAP_F( int )
1807 ldap_result LDAP_P((
1808 	LDAP *ld,
1809 	int msgid,
1810 	int all,
1811 	struct timeval *timeout,
1812 	LDAPMessage **result ));
1813 
1814 LDAP_F( int )
1815 ldap_msgtype LDAP_P((
1816 	LDAPMessage *lm ));
1817 
1818 LDAP_F( int )
1819 ldap_msgid   LDAP_P((
1820 	LDAPMessage *lm ));
1821 
1822 LDAP_F( int )
1823 ldap_msgfree LDAP_P((
1824 	LDAPMessage *lm ));
1825 
1826 LDAP_F( int )
1827 ldap_msgdelete LDAP_P((
1828 	LDAP *ld,
1829 	int msgid ));
1830 
1831 
1832 /*
1833  * in search.c:
1834  */
1835 LDAP_F( int )
1836 ldap_bv2escaped_filter_value LDAP_P((
1837 	struct berval *in,
1838 	struct berval *out ));
1839 
1840 LDAP_F( int )
1841 ldap_search_ext LDAP_P((
1842 	LDAP			*ld,
1843 	LDAP_CONST char	*base,
1844 	int				scope,
1845 	LDAP_CONST char	*filter,
1846 	char			**attrs,
1847 	int				attrsonly,
1848 	LDAPControl		**serverctrls,
1849 	LDAPControl		**clientctrls,
1850 	struct timeval	*timeout,
1851 	int				sizelimit,
1852 	int				*msgidp ));
1853 
1854 LDAP_F( int )
1855 ldap_search_ext_s LDAP_P((
1856 	LDAP			*ld,
1857 	LDAP_CONST char	*base,
1858 	int				scope,
1859 	LDAP_CONST char	*filter,
1860 	char			**attrs,
1861 	int				attrsonly,
1862 	LDAPControl		**serverctrls,
1863 	LDAPControl		**clientctrls,
1864 	struct timeval	*timeout,
1865 	int				sizelimit,
1866 	LDAPMessage		**res ));
1867 
1868 #if LDAP_DEPRECATED
1869 LDAP_F( int )
1870 ldap_search LDAP_P((	/* deprecated, use ldap_search_ext */
1871 	LDAP *ld,
1872 	LDAP_CONST char *base,
1873 	int scope,
1874 	LDAP_CONST char *filter,
1875 	char **attrs,
1876 	int attrsonly ));
1877 
1878 LDAP_F( int )
1879 ldap_search_s LDAP_P((	/* deprecated, use ldap_search_ext_s */
1880 	LDAP *ld,
1881 	LDAP_CONST char *base,
1882 	int scope,
1883 	LDAP_CONST char *filter,
1884 	char **attrs,
1885 	int attrsonly,
1886 	LDAPMessage **res ));
1887 
1888 LDAP_F( int )
1889 ldap_search_st LDAP_P((	/* deprecated, use ldap_search_ext_s */
1890 	LDAP *ld,
1891 	LDAP_CONST char *base,
1892 	int scope,
1893 	LDAP_CONST char *filter,
1894     char **attrs,
1895 	int attrsonly,
1896 	struct timeval *timeout,
1897 	LDAPMessage **res ));
1898 #endif
1899 
1900 /*
1901  * in unbind.c
1902  */
1903 LDAP_F( int )
1904 ldap_unbind_ext LDAP_P((
1905 	LDAP			*ld,
1906 	LDAPControl		**serverctrls,
1907 	LDAPControl		**clientctrls));
1908 
1909 LDAP_F( int )
1910 ldap_unbind_ext_s LDAP_P((
1911 	LDAP			*ld,
1912 	LDAPControl		**serverctrls,
1913 	LDAPControl		**clientctrls));
1914 
1915 #if LDAP_DEPRECATED
1916 LDAP_F( int )
1917 ldap_unbind LDAP_P(( /* deprecated, use ldap_unbind_ext */
1918 	LDAP *ld ));
1919 
1920 LDAP_F( int )
1921 ldap_unbind_s LDAP_P(( /* deprecated, use ldap_unbind_ext_s */
1922 	LDAP *ld ));
1923 #endif
1924 
1925 /*
1926  * in filter.c
1927  */
1928 LDAP_F( int )
1929 ldap_put_vrFilter LDAP_P((
1930 	BerElement *ber,
1931 	const char *vrf ));
1932 
1933 /*
1934  * in free.c
1935  */
1936 
1937 LDAP_F( void * )
1938 ldap_memalloc LDAP_P((
1939 	ber_len_t s ));
1940 
1941 LDAP_F( void * )
1942 ldap_memrealloc LDAP_P((
1943 	void* p,
1944 	ber_len_t s ));
1945 
1946 LDAP_F( void * )
1947 ldap_memcalloc LDAP_P((
1948 	ber_len_t n,
1949 	ber_len_t s ));
1950 
1951 LDAP_F( void )
1952 ldap_memfree LDAP_P((
1953 	void* p ));
1954 
1955 LDAP_F( void )
1956 ldap_memvfree LDAP_P((
1957 	void** v ));
1958 
1959 LDAP_F( char * )
1960 ldap_strdup LDAP_P((
1961 	LDAP_CONST char * ));
1962 
1963 LDAP_F( void )
1964 ldap_mods_free LDAP_P((
1965 	LDAPMod **mods,
1966 	int freemods ));
1967 
1968 
1969 #if LDAP_DEPRECATED
1970 /*
1971  * in sort.c (deprecated, use custom code instead)
1972  */
1973 typedef int (LDAP_SORT_AD_CMP_PROC) LDAP_P(( /* deprecated */
1974 	LDAP_CONST char *left,
1975 	LDAP_CONST char *right ));
1976 
1977 typedef int (LDAP_SORT_AV_CMP_PROC) LDAP_P(( /* deprecated */
1978 	LDAP_CONST void *left,
1979 	LDAP_CONST void *right ));
1980 
1981 LDAP_F( int )	/* deprecated */
1982 ldap_sort_entries LDAP_P(( LDAP *ld,
1983 	LDAPMessage **chain,
1984 	LDAP_CONST char *attr,
1985 	LDAP_SORT_AD_CMP_PROC *cmp ));
1986 
1987 LDAP_F( int )	/* deprecated */
1988 ldap_sort_values LDAP_P((
1989 	LDAP *ld,
1990 	char **vals,
1991 	LDAP_SORT_AV_CMP_PROC *cmp ));
1992 
1993 LDAP_F( int ) /* deprecated */
1994 ldap_sort_strcasecmp LDAP_P((
1995 	LDAP_CONST void *a,
1996 	LDAP_CONST void *b ));
1997 #endif
1998 
1999 /*
2000  * in url.c
2001  */
2002 LDAP_F( int )
2003 ldap_is_ldap_url LDAP_P((
2004 	LDAP_CONST char *url ));
2005 
2006 LDAP_F( int )
2007 ldap_is_ldaps_url LDAP_P((
2008 	LDAP_CONST char *url ));
2009 
2010 LDAP_F( int )
2011 ldap_is_ldapi_url LDAP_P((
2012 	LDAP_CONST char *url ));
2013 
2014 LDAP_F( int )
2015 ldap_url_parse LDAP_P((
2016 	LDAP_CONST char *url,
2017 	LDAPURLDesc **ludpp ));
2018 
2019 LDAP_F( char * )
2020 ldap_url_desc2str LDAP_P((
2021 	LDAPURLDesc *ludp ));
2022 
2023 LDAP_F( void )
2024 ldap_free_urldesc LDAP_P((
2025 	LDAPURLDesc *ludp ));
2026 
2027 
2028 /*
2029  * LDAP Cancel Extended Operation <draft-zeilenga-ldap-cancel-xx.txt>
2030  *  in cancel.c
2031  */
2032 #define LDAP_API_FEATURE_CANCEL 1000
2033 
2034 LDAP_F( int )
2035 ldap_cancel LDAP_P(( LDAP *ld,
2036 	int cancelid,
2037 	LDAPControl		**sctrls,
2038 	LDAPControl		**cctrls,
2039 	int				*msgidp ));
2040 
2041 LDAP_F( int )
2042 ldap_cancel_s LDAP_P(( LDAP *ld,
2043 	int cancelid,
2044 	LDAPControl **sctrl,
2045 	LDAPControl **cctrl ));
2046 
2047 /*
2048  * LDAP Turn Extended Operation <draft-zeilenga-ldap-turn-xx.txt>
2049  *  in turn.c
2050  */
2051 #define LDAP_API_FEATURE_TURN 1000
2052 
2053 LDAP_F( int )
2054 ldap_turn LDAP_P(( LDAP *ld,
2055 	int mutual,
2056 	LDAP_CONST char* identifier,
2057 	LDAPControl		**sctrls,
2058 	LDAPControl		**cctrls,
2059 	int				*msgidp ));
2060 
2061 LDAP_F( int )
2062 ldap_turn_s LDAP_P(( LDAP *ld,
2063 	int mutual,
2064 	LDAP_CONST char* identifier,
2065 	LDAPControl **sctrl,
2066 	LDAPControl **cctrl ));
2067 
2068 /*
2069  * LDAP Paged Results
2070  *	in pagectrl.c
2071  */
2072 #define LDAP_API_FEATURE_PAGED_RESULTS 2000
2073 
2074 LDAP_F( int )
2075 ldap_create_page_control_value LDAP_P((
2076 	LDAP *ld,
2077 	ber_int_t pagesize,
2078 	struct berval *cookie,
2079 	struct berval *value ));
2080 
2081 LDAP_F( int )
2082 ldap_create_page_control LDAP_P((
2083 	LDAP *ld,
2084 	ber_int_t pagesize,
2085 	struct berval *cookie,
2086 	int iscritical,
2087 	LDAPControl **ctrlp ));
2088 
2089 #if LDAP_DEPRECATED
2090 LDAP_F( int )
2091 ldap_parse_page_control LDAP_P((
2092 	/* deprecated, use ldap_parse_pageresponse_control */
2093 	LDAP *ld,
2094 	LDAPControl **ctrls,
2095 	ber_int_t *count,
2096 	struct berval **cookie ));
2097 #endif
2098 
2099 LDAP_F( int )
2100 ldap_parse_pageresponse_control LDAP_P((
2101 	LDAP *ld,
2102 	LDAPControl *ctrl,
2103 	ber_int_t *count,
2104 	struct berval *cookie ));
2105 
2106 /*
2107  * LDAP Server Side Sort
2108  *	in sortctrl.c
2109  */
2110 #define LDAP_API_FEATURE_SERVER_SIDE_SORT 2000
2111 
2112 /* structure for a sort-key */
2113 typedef struct ldapsortkey {
2114 	char *attributeType;
2115 	char *orderingRule;
2116 	int reverseOrder;
2117 } LDAPSortKey;
2118 
2119 LDAP_F( int )
2120 ldap_create_sort_keylist LDAP_P((
2121 	LDAPSortKey ***sortKeyList,
2122 	char *keyString ));
2123 
2124 LDAP_F( void )
2125 ldap_free_sort_keylist LDAP_P((
2126 	LDAPSortKey **sortkeylist ));
2127 
2128 LDAP_F( int )
2129 ldap_create_sort_control_value LDAP_P((
2130 	LDAP *ld,
2131 	LDAPSortKey **keyList,
2132 	struct berval *value ));
2133 
2134 LDAP_F( int )
2135 ldap_create_sort_control LDAP_P((
2136 	LDAP *ld,
2137 	LDAPSortKey **keyList,
2138 	int iscritical,
2139 	LDAPControl **ctrlp ));
2140 
2141 LDAP_F( int )
2142 ldap_parse_sortresponse_control LDAP_P((
2143 	LDAP *ld,
2144 	LDAPControl *ctrl,
2145 	ber_int_t *result,
2146 	char **attribute ));
2147 
2148 /*
2149  * LDAP Virtual List View
2150  *	in vlvctrl.c
2151  */
2152 #define LDAP_API_FEATURE_VIRTUAL_LIST_VIEW 2000
2153 
2154 /* structure for virtual list */
2155 typedef struct ldapvlvinfo {
2156 	ber_int_t ldvlv_version;
2157     ber_int_t ldvlv_before_count;
2158     ber_int_t ldvlv_after_count;
2159     ber_int_t ldvlv_offset;
2160     ber_int_t ldvlv_count;
2161     struct berval *	ldvlv_attrvalue;
2162     struct berval *	ldvlv_context;
2163     void *			ldvlv_extradata;
2164 } LDAPVLVInfo;
2165 
2166 LDAP_F( int )
2167 ldap_create_vlv_control_value LDAP_P((
2168 	LDAP *ld,
2169 	LDAPVLVInfo *ldvlistp,
2170 	struct berval *value));
2171 
2172 LDAP_F( int )
2173 ldap_create_vlv_control LDAP_P((
2174 	LDAP *ld,
2175 	LDAPVLVInfo *ldvlistp,
2176 	LDAPControl **ctrlp ));
2177 
2178 LDAP_F( int )
2179 ldap_parse_vlvresponse_control LDAP_P((
2180 	LDAP          *ld,
2181 	LDAPControl   *ctrls,
2182 	ber_int_t *target_posp,
2183 	ber_int_t *list_countp,
2184 	struct berval **contextp,
2185 	int           *errcodep ));
2186 
2187 /*
2188  * LDAP Who Am I?
2189  *	in whoami.c
2190  */
2191 #define LDAP_API_FEATURE_WHOAMI 1000
2192 
2193 LDAP_F( int )
2194 ldap_parse_whoami LDAP_P((
2195 	LDAP *ld,
2196 	LDAPMessage *res,
2197 	struct berval **authzid ));
2198 
2199 LDAP_F( int )
2200 ldap_whoami LDAP_P(( LDAP *ld,
2201 	LDAPControl		**sctrls,
2202 	LDAPControl		**cctrls,
2203 	int				*msgidp ));
2204 
2205 LDAP_F( int )
2206 ldap_whoami_s LDAP_P((
2207 	LDAP *ld,
2208 	struct berval **authzid,
2209 	LDAPControl **sctrls,
2210 	LDAPControl **cctrls ));
2211 
2212 /*
2213  * LDAP Password Modify
2214  *	in passwd.c
2215  */
2216 #define LDAP_API_FEATURE_PASSWD_MODIFY 1000
2217 
2218 LDAP_F( int )
2219 ldap_parse_passwd LDAP_P((
2220 	LDAP *ld,
2221 	LDAPMessage *res,
2222 	struct berval *newpasswd ));
2223 
2224 LDAP_F( int )
2225 ldap_passwd LDAP_P(( LDAP *ld,
2226 	struct berval	*user,
2227 	struct berval	*oldpw,
2228 	struct berval	*newpw,
2229 	LDAPControl		**sctrls,
2230 	LDAPControl		**cctrls,
2231 	int				*msgidp ));
2232 
2233 LDAP_F( int )
2234 ldap_passwd_s LDAP_P((
2235 	LDAP *ld,
2236 	struct berval	*user,
2237 	struct berval	*oldpw,
2238 	struct berval	*newpw,
2239 	struct berval *newpasswd,
2240 	LDAPControl **sctrls,
2241 	LDAPControl **cctrls ));
2242 
2243 #ifdef LDAP_CONTROL_PASSWORDPOLICYREQUEST
2244 /*
2245  * LDAP Password Policy controls
2246  *	in ppolicy.c
2247  */
2248 #define LDAP_API_FEATURE_PASSWORD_POLICY 1000
2249 
2250 typedef enum passpolicyerror_enum {
2251        PP_passwordExpired = 0,
2252        PP_accountLocked = 1,
2253        PP_changeAfterReset = 2,
2254        PP_passwordModNotAllowed = 3,
2255        PP_mustSupplyOldPassword = 4,
2256        PP_insufficientPasswordQuality = 5,
2257        PP_passwordTooShort = 6,
2258        PP_passwordTooYoung = 7,
2259        PP_passwordInHistory = 8,
2260        PP_noError = 65535
2261 } LDAPPasswordPolicyError;
2262 
2263 LDAP_F( int )
2264 ldap_create_passwordpolicy_control LDAP_P((
2265         LDAP *ld,
2266         LDAPControl **ctrlp ));
2267 
2268 LDAP_F( int )
2269 ldap_parse_passwordpolicy_control LDAP_P((
2270         LDAP *ld,
2271         LDAPControl *ctrl,
2272         ber_int_t *expirep,
2273         ber_int_t *gracep,
2274         LDAPPasswordPolicyError *errorp ));
2275 
2276 LDAP_F( const char * )
2277 ldap_passwordpolicy_err2txt LDAP_P(( LDAPPasswordPolicyError ));
2278 #endif /* LDAP_CONTROL_PASSWORDPOLICYREQUEST */
2279 
2280 /*
2281  * LDAP Dynamic Directory Services Refresh -- RFC 2589
2282  *	in dds.c
2283  */
2284 #define LDAP_API_FEATURE_REFRESH 1000
2285 
2286 LDAP_F( int )
2287 ldap_parse_refresh LDAP_P((
2288 	LDAP *ld,
2289 	LDAPMessage *res,
2290 	ber_int_t *newttl ));
2291 
2292 LDAP_F( int )
2293 ldap_refresh LDAP_P(( LDAP *ld,
2294 	struct berval	*dn,
2295 	ber_int_t ttl,
2296 	LDAPControl		**sctrls,
2297 	LDAPControl		**cctrls,
2298 	int				*msgidp ));
2299 
2300 LDAP_F( int )
2301 ldap_refresh_s LDAP_P((
2302 	LDAP *ld,
2303 	struct berval	*dn,
2304 	ber_int_t ttl,
2305 	ber_int_t *newttl,
2306 	LDAPControl **sctrls,
2307 	LDAPControl **cctrls ));
2308 
2309 /*
2310  * LDAP Transactions
2311  */
2312 #ifdef LDAP_X_TXN
2313 LDAP_F( int )
2314 ldap_txn_start LDAP_P(( LDAP *ld,
2315 	LDAPControl		**sctrls,
2316 	LDAPControl		**cctrls,
2317 	int				*msgidp ));
2318 
2319 LDAP_F( int )
2320 ldap_txn_start_s LDAP_P(( LDAP *ld,
2321 	LDAPControl **sctrl,
2322 	LDAPControl **cctrl,
2323 	struct berval **rettxnid ));
2324 
2325 LDAP_F( int )
2326 ldap_txn_end LDAP_P(( LDAP *ld,
2327 	int	commit,
2328 	struct berval	*txnid,
2329 	LDAPControl		**sctrls,
2330 	LDAPControl		**cctrls,
2331 	int				*msgidp ));
2332 
2333 LDAP_F( int )
2334 ldap_txn_end_s LDAP_P(( LDAP *ld,
2335 	int	commit,
2336 	struct berval *txnid,
2337 	LDAPControl **sctrl,
2338 	LDAPControl **cctrl,
2339 	int *retidp ));
2340 #endif
2341 
2342 /*
2343  * in ldap_sync.c
2344  */
2345 
2346 /*
2347  * initialize the persistent search structure
2348  */
2349 LDAP_F( ldap_sync_t * )
2350 ldap_sync_initialize LDAP_P((
2351 	ldap_sync_t	*ls ));
2352 
2353 /*
2354  * destroy the persistent search structure
2355  */
2356 LDAP_F( void )
2357 ldap_sync_destroy LDAP_P((
2358 	ldap_sync_t	*ls,
2359 	int		freeit ));
2360 
2361 /*
2362  * initialize a refreshOnly sync
2363  */
2364 LDAP_F( int )
2365 ldap_sync_init LDAP_P((
2366 	ldap_sync_t	*ls,
2367 	int		mode ));
2368 
2369 /*
2370  * initialize a refreshOnly sync
2371  */
2372 LDAP_F( int )
2373 ldap_sync_init_refresh_only LDAP_P((
2374 	ldap_sync_t	*ls ));
2375 
2376 /*
2377  * initialize a refreshAndPersist sync
2378  */
2379 LDAP_F( int )
2380 ldap_sync_init_refresh_and_persist LDAP_P((
2381 	ldap_sync_t	*ls ));
2382 
2383 /*
2384  * poll for new responses
2385  */
2386 LDAP_F( int )
2387 ldap_sync_poll LDAP_P((
2388 	ldap_sync_t	*ls ));
2389 
2390 #ifdef LDAP_CONTROL_X_SESSION_TRACKING
2391 
2392 /*
2393  * in stctrl.c
2394  */
2395 LDAP_F( int )
2396 ldap_create_session_tracking_value LDAP_P((
2397 	LDAP		*ld,
2398 	char		*sessionSourceIp,
2399 	char		*sessionSourceName,
2400 	char		*formatOID,
2401 	struct berval	*sessionTrackingIdentifier,
2402 	struct berval	*value ));
2403 
2404 LDAP_F( int )
2405 ldap_create_session_tracking LDAP_P((
2406 	LDAP		*ld,
2407 	char		*sessionSourceIp,
2408 	char		*sessionSourceName,
2409 	char		*formatOID,
2410 	struct berval	*sessionTrackingIdentifier,
2411 	LDAPControl	**ctrlp ));
2412 
2413 LDAP_F( int )
2414 ldap_parse_session_tracking_control LDAP_P((
2415 	LDAP *ld,
2416 	LDAPControl *ctrl,
2417 	struct berval *ip,
2418 	struct berval *name,
2419 	struct berval *oid,
2420 	struct berval *id ));
2421 
2422 #endif /* LDAP_CONTROL_X_SESSION_TRACKING */
2423 
2424 /*
2425  * in assertion.c
2426  */
2427 LDAP_F (int)
2428 ldap_create_assertion_control_value LDAP_P((
2429 	LDAP		*ld,
2430 	char		*assertion,
2431 	struct berval	*value ));
2432 
2433 LDAP_F( int )
2434 ldap_create_assertion_control LDAP_P((
2435 	LDAP		*ld,
2436 	char		*filter,
2437 	int		iscritical,
2438 	LDAPControl	**ctrlp ));
2439 
2440 /*
2441  * in deref.c
2442  */
2443 
2444 typedef struct LDAPDerefSpec {
2445 	char *derefAttr;
2446 	char **attributes;
2447 } LDAPDerefSpec;
2448 
2449 typedef struct LDAPDerefVal {
2450 	char *type;
2451 	BerVarray vals;
2452 	struct LDAPDerefVal *next;
2453 } LDAPDerefVal;
2454 
2455 typedef struct LDAPDerefRes {
2456 	char *derefAttr;
2457 	struct berval derefVal;
2458 	LDAPDerefVal *attrVals;
2459 	struct LDAPDerefRes *next;
2460 } LDAPDerefRes;
2461 
2462 LDAP_F( int )
2463 ldap_create_deref_control_value LDAP_P((
2464 	LDAP *ld,
2465 	LDAPDerefSpec *ds,
2466 	struct berval *value ));
2467 
2468 LDAP_F( int )
2469 ldap_create_deref_control LDAP_P((
2470 	LDAP		*ld,
2471 	LDAPDerefSpec	*ds,
2472 	int		iscritical,
2473 	LDAPControl	**ctrlp ));
2474 
2475 LDAP_F( void )
2476 ldap_derefresponse_free LDAP_P((
2477 	LDAPDerefRes *dr ));
2478 
2479 LDAP_F( int )
2480 ldap_parse_derefresponse_control LDAP_P((
2481 	LDAP *ld,
2482 	LDAPControl *ctrl,
2483 	LDAPDerefRes **drp ));
2484 
2485 LDAP_F( int )
2486 ldap_parse_deref_control LDAP_P((
2487 	LDAP		*ld,
2488 	LDAPControl	**ctrls,
2489 	LDAPDerefRes	**drp ));
2490 
2491 LDAP_END_DECL
2492 #endif /* _LDAP_H */
2493