1 /* $OpenLDAP$ */
2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
3  *
4  * Copyright 1998-2021 The OpenLDAP Foundation.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted only as authorized by the OpenLDAP
9  * Public License.
10  *
11  * A copy of this license is available in file LICENSE in the
12  * top-level directory of the distribution or, alternatively, at
13  * <http://www.OpenLDAP.org/license.html>.
14  */
15 /* Portions Copyright (c) 1990 Regents of the University of Michigan.
16  * All rights reserved.
17  *
18  * Redistribution and use in source and binary forms are permitted
19  * provided that this notice is preserved and that due credit is given
20  * to the University of Michigan at Ann Arbor. The name of the University
21  * may not be used to endorse or promote products derived from this
22  * software without specific prior written permission. This software
23  * is provided ``as is'' without express or implied warranty.
24  */
25 
26 #ifndef _LDAP_H
27 #define _LDAP_H
28 
29 /* pull in lber */
30 #include <lber.h>
31 
32 /* include version and API feature defines */
33 #include <ldap_features.h>
34 
35 LDAP_BEGIN_DECL
36 
37 #define LDAP_VERSION1	1
38 #define LDAP_VERSION2	2
39 #define LDAP_VERSION3	3
40 
41 #define LDAP_VERSION_MIN	LDAP_VERSION2
42 #define	LDAP_VERSION		LDAP_VERSION2
43 #define LDAP_VERSION_MAX	LDAP_VERSION3
44 
45 /*
46  * We use 3000+n here because it is above 1823 (for RFC 1823),
47  * above 2000+rev of IETF LDAPEXT draft (now quite dated),
48  * yet below allocations for new RFCs (just in case there is
49  * someday an RFC produced).
50  */
51 #define LDAP_API_VERSION	3001
52 #define LDAP_VENDOR_NAME	"OpenLDAP"
53 
54 /* OpenLDAP API Features */
55 #define LDAP_API_FEATURE_X_OPENLDAP LDAP_VENDOR_VERSION
56 
57 #if defined( LDAP_API_FEATURE_X_OPENLDAP_REENTRANT )
58 #	define	LDAP_API_FEATURE_THREAD_SAFE 		1
59 #endif
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
63 #endif
64 
65 
66 #define LDAP_PORT		389		/* ldap:///		default LDAP port */
67 #define LDAPS_PORT		636		/* ldaps:///	default LDAP over TLS port */
68 
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 */
73 
74 /* RFC 4511:  maxInt INTEGER ::= 2147483647 -- (2^^31 - 1) -- */
75 #define LDAP_MAXINT (2147483647)
76 
77 /*
78  * LDAP_OPTions
79  *	0x0000 - 0x0fff reserved for api options
80  *	0x1000 - 0x3fff reserved for api extended options
81  *	0x4000 - 0x7fff reserved for private and experimental options
82  */
83 
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 */
117 
118 /* API Extensions */
119 #define LDAP_OPT_API_EXTENSION_BASE 0x4000  /* API extensions */
120 
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 */
137 
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
167 
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
173 
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
177 
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)
186 
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
190 
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
207 
208 /*
209  * OpenLDAP per connection tcp-keepalive settings
210  * (Linux only, ignored where unsupported)
211  */
212 #define LDAP_OPT_X_KEEPALIVE_IDLE		0x6300
213 #define LDAP_OPT_X_KEEPALIVE_PROBES		0x6301
214 #define LDAP_OPT_X_KEEPALIVE_INTERVAL	0x6302
215 
216 /* Private API Extensions -- reserved for application use */
217 #define LDAP_OPT_PRIVATE_EXTENSION_BASE 0x7000  /* Private API inclusive */
218 
219 /*
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.
224  */
225 #define LDAP_OPT_SUCCESS	0
226 #define	LDAP_OPT_ERROR		(-1)
227 
228 /* option on/off values */
229 #define LDAP_OPT_ON		((void *) &ber_pvt_opt_on)
230 #define LDAP_OPT_OFF	((void *) 0)
231 
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 */
240 } LDAPAPIInfo;
241 
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;
248 
249 /*
250  * LDAP Control structure
251  */
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 */
256 } LDAPControl;
257 
258 /* LDAP Controls */
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 */
263 
264 #define LDAP_CONTROL_VALUESRETURNFILTER "1.2.826.0.1.3344810.2.3"/* RFC 3876 */
265 
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 */
269 
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 */
272 
273 /*	non-standard track controls */
274 #define LDAP_CONTROL_PAGEDRESULTS	"1.2.840.113556.1.4.319"   /* RFC 2696 */
275 
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 */
278 
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"
285 
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
290 
291 #define LDAP_SYNC_REFRESH_PRESENTS		0
292 #define LDAP_SYNC_REFRESH_DELETES		1
293 
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)
298 
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)
303 
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
309 
310 /* LDAP Don't Use Copy Control (RFC 6171) */
311 #define LDAP_CONTROL_DONTUSECOPY		"1.3.6.1.1.22"
312 
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"
317 
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"
327 
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"
332 
333 #define	LDAP_CHAINING_PREFERRED				0
334 #define	LDAP_CHAINING_REQUIRED				1
335 #define LDAP_REFERRALS_PREFERRED			2
336 #define LDAP_REFERRALS_REQUIRED				3
337 
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"
347 
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"
353 
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
358 
359 
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 */
369 
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
375 
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
383 
384 /* LDAP VLV */
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"
387 
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"
390 
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 */
393 
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 */
399 
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"
404 
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
408 
409 /* LDAP Extended Operations */
410 #define LDAP_EXOP_START_TLS		"1.3.6.1.4.1.1466.20037"	/* RFC 4511 */
411 
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)
417 
418 #define LDAP_EXOP_CANCEL		"1.3.6.1.1.8"					/* RFC 3909 */
419 #define LDAP_EXOP_X_CANCEL		LDAP_EXOP_CANCEL
420 
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)
425 
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
428 
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 */
432 
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
435 
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
439 
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"
455 
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"
461 
462 /* LDAP Features */
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"
470 
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
475 
476 /*
477  * specific LDAP instantiations of BER types we know about
478  */
479 
480 /* Overview of LBER tag construction
481  *
482  *	Bits
483  *	______
484  *	8 7 | CLASS
485  *	0 0 = UNIVERSAL
486  *	0 1 = APPLICATION
487  *	1 0 = CONTEXT-SPECIFIC
488  *	1 1 = PRIVATE
489  *		_____
490  *		| 6 | DATA-TYPE
491  *		  0 = PRIMITIVE
492  *		  1 = CONSTRUCTED
493  *			___________
494  *			| 5 ... 1 | TAG-NUMBER
495  */
496 
497 /* general stuff */
498 #define LDAP_TAG_MESSAGE	((ber_tag_t) 0x30U)	/* constructed + 16 */
499 #define LDAP_TAG_MSGID		((ber_tag_t) 0x02U)	/* integer */
500 
501 #define LDAP_TAG_LDAPDN		((ber_tag_t) 0x04U)	/* octet string */
502 #define LDAP_TAG_LDAPCRED	((ber_tag_t) 0x04U)	/* octet string */
503 
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 */
506 
507 #define LDAP_TAG_NEWSUPERIOR	((ber_tag_t) 0x80U)	/* context-specific + primitive + 0 */
508 
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 */
513 
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 */
516 
517 #define LDAP_TAG_SASL_RES_CREDS	((ber_tag_t) 0x87U)	/* context specific + primitive */
518 
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 */
532 
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 */
547 
548 #define LDAP_RES_ANY			(-1)
549 #define LDAP_RES_UNSOLICITED	(0)
550 
551 
552 /* sasl methods */
553 #define LDAP_SASL_SIMPLE	((char*)0)
554 #define LDAP_SASL_NULL		("")
555 
556 
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 */
564 
565 /* used by the Windows API but not used on the wire */
566 #define LDAP_AUTH_NEGOTIATE ((ber_tag_t) 0x04FFU)
567 
568 /* filter types */
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 */
579 
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 */
585 
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 */
590 
591 /* search scopes */
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 */
601 
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 */
606 
607 /*
608  * LDAP Result Codes
609  */
610 #define LDAP_SUCCESS				0x00
611 
612 #define LDAP_RANGE(n,x,y)	(((x) <= (n)) && ((n) <= (y)))
613 
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) */
625 
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 */
631 
632 #define LDAP_ATTR_ERROR(n)	LDAP_RANGE((n),0x10,0x15) /* 16-21 */
633 
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
640 
641 #define LDAP_NAME_ERROR(n)	LDAP_RANGE((n),0x20,0x24) /* 32-34,36 */
642 
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
648 
649 #define LDAP_SECURITY_ERROR(n)	LDAP_RANGE((n),0x2F,0x32) /* 47-50 */
650 
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
655 
656 #define LDAP_SERVICE_ERROR(n)	LDAP_RANGE((n),0x33,0x36) /* 51-54 */
657 
658 #define LDAP_BUSY					0x33
659 #define LDAP_UNAVAILABLE			0x34
660 #define LDAP_UNWILLING_TO_PERFORM	0x35
661 #define LDAP_LOOP_DETECT			0x36
662 
663 #define LDAP_UPDATE_ERROR(n)	LDAP_RANGE((n),0x40,0x47) /* 64-69,71 */
664 
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
673 
674 #define LDAP_VLV_ERROR				0x4C
675 
676 #define LDAP_OTHER					0x50
677 
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
684 
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
690 
691 /* Assertion control (122) */
692 #define LDAP_ASSERTION_FAILED		0x7A
693 
694 /* Proxied Authorization Denied (123) */
695 #define LDAP_PROXIED_AUTHORIZATION_DENIED		0x7B
696 
697 /* Experimental result codes */
698 #define LDAP_E_ERROR(n)	LDAP_RANGE((n),0x1000,0x3FFF)
699 
700 /* LDAP Sync (4096) */
701 #define LDAP_SYNC_REFRESH_REQUIRED		0x1000
702 
703 
704 /* Private Use result codes */
705 #define LDAP_X_ERROR(n)	LDAP_RANGE((n),0x4000,0xFFFF)
706 
707 #define LDAP_X_SYNC_REFRESH_REQUIRED	0x4100 /* defunct */
708 #define LDAP_X_ASSERTION_FAILED			0x410f /* defunct */
709 
710 /* for the LDAP No-Op control */
711 #define LDAP_X_NO_OPERATION				0x410e
712 
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
718 #endif
719 
720 /* for Distributed Procedures (see <draft-sermersheim-ldap-distproc>) */
721 #ifdef LDAP_X_DISTPROC_BASE
722 #define LDAP_X_INVALIDREFERENCE			0x4112
723 #endif
724 
725 #define LDAP_TXN_SPECIFY_OKAY		0x4120
726 #define LDAP_TXN_ID_INVALID			0x4121
727 
728 /* API Error Codes
729  *
730  * Based on draft-ietf-ldap-c-api-xx
731  * but with new negative code values
732  */
733 #define LDAP_API_ERROR(n)		((n)<0)
734 #define LDAP_API_RESULT(n)		((n)<=0)
735 
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)
754 
755 
756 /*
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.
760  */
761 
762 typedef struct ldapmsg LDAPMessage;
763 
764 /* for modifications */
765 typedef struct ldapmod {
766 	int		mod_op;
767 
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)
777  */
778 
779 	char		*mod_type;
780 	union mod_vals_u {
781 		char		**modv_strvals;
782 		struct berval	**modv_bvals;
783 	} mod_vals;
784 #define mod_values	mod_vals.modv_strvals
785 #define mod_bvalues	mod_vals.modv_bvals
786 } LDAPMod;
787 
788 /*
789  * structure representing an ldap session which can
790  * encompass connections to multiple servers (in the
791  * face of referrals).
792  */
793 typedef struct ldap LDAP;
794 
795 #define LDAP_DEREF_NEVER		0x00
796 #define LDAP_DEREF_SEARCHING	0x01
797 #define LDAP_DEREF_FINDING		0x02
798 #define LDAP_DEREF_ALWAYS		0x03
799 
800 #define LDAP_NO_LIMIT			0
801 
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
806 
807 /*
808  * types for ldap URL handling
809  */
810 typedef struct ldap_url_desc {
811 	struct ldap_url_desc *lud_next;
812 	char	*lud_scheme;
813 	char	*lud_host;
814 	int		lud_port;
815 	char	*lud_dn;
816 	char	**lud_attrs;
817 	int		lud_scope;
818 	char	*lud_filter;
819 	char	**lud_exts;
820 	int		lud_crit_exts;
821 } LDAPURLDesc;
822 
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 */
826 
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 */
835 
836 /*
837  * LDAP sync (RFC4533) API
838  */
839 
840 typedef struct ldap_sync_t ldap_sync_t;
841 
842 typedef enum {
843 	/* these are private - the client should never see them */
844 	LDAP_SYNC_CAPI_NONE		= -1,
845 
846 	LDAP_SYNC_CAPI_PHASE_FLAG	= 0x10U,
847 	LDAP_SYNC_CAPI_IDSET_FLAG	= 0x20U,
848 	LDAP_SYNC_CAPI_DONE_FLAG	= 0x40U,
849 
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,
855 
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 ),
859 
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 ),
862 
863 	LDAP_SYNC_CAPI_DONE		= ( LDAP_SYNC_CAPI_DONE_FLAG | LDAP_SYNC_CAPI_PRESENTS )
864 } ldap_sync_refresh_t;
865 
866 /*
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.
873  */
874 typedef int (*ldap_sync_search_entry_f) LDAP_P((
875 	ldap_sync_t			*ls,
876 	LDAPMessage			*msg,
877 	struct berval			*entryUUID,
878 	ldap_sync_refresh_t		phase ));
879 
880 /*
881  * Called when a reference is returned; the client should know
882  * what to do with it.
883  */
884 typedef int (*ldap_sync_search_reference_f) LDAP_P((
885 	ldap_sync_t			*ls,
886 	LDAPMessage			*msg ));
887 
888 /*
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.
896  *
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.
900  */
901 typedef int (*ldap_sync_intermediate_f) LDAP_P((
902 	ldap_sync_t			*ls,
903 	LDAPMessage			*msg,
904 	BerVarray			syncUUIDs,
905 	ldap_sync_refresh_t		phase ));
906 
907 /*
908  * Called when a searchResultDone is returned.  In refreshAndPersist,
909  * this can only occur if the search for any reason is being terminated
910  * by the server.
911  */
912 typedef int (*ldap_sync_search_result_f) LDAP_P((
913 	ldap_sync_t			*ls,
914 	LDAPMessage			*msg,
915 	int				refreshDeletes ));
916 
917 /*
918  * This structure contains all information about the persistent search;
919  * the caller is responsible for connecting, setting version, binding, tls...
920  */
921 struct ldap_sync_t {
922 	/* conf search params */
923 	char				*ls_base;
924 	int				ls_scope;
925 	char				*ls_filter;
926 	char				**ls_attrs;
927 	int				ls_timelimit;
928 	int				ls_sizelimit;
929 
930 	/* poll timeout */
931 	int				ls_timeout;
932 
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;
938 
939 	/* set by the caller as appropriate */
940 	void				*ls_private;
941 
942 	/* conn stuff */
943 	LDAP				*ls_ld;
944 
945 	/* --- the parameters below are private - do not modify --- */
946 
947 	/* FIXME: make the structure opaque, and provide an interface
948 	 * to modify the public values? */
949 
950 	/* result stuff */
951 	int				ls_msgid;
952 
953 	/* sync stuff */
954 	/* needed by refreshOnly */
955 	int				ls_reloadHint;
956 
957 	/* opaque - need to pass between sessions, updated by the API */
958 	struct berval			ls_cookie;
959 
960 	/* state variable - do not modify */
961 	ldap_sync_refresh_t		ls_refreshPhase;
962 };
963 
964 /*
965  * End of LDAP sync (RFC4533) API
966  */
967 
968 /*
969  * Connection callbacks...
970  */
971 struct ldap_conncb;
972 struct sockaddr;
973 
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 ));
979 
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.
982  */
983 typedef struct ldap_conncb {
984 	ldap_conn_add_f *lc_add;
985 	ldap_conn_del_f *lc_del;
986 	void *lc_arg;
987 } ldap_conncb;
988 
989 /*
990  * The API draft spec says we should declare (or cause to be declared)
991  * 'struct timeval'.   We don't.  See IETF LDAPext discussions.
992  */
993 struct timeval;
994 
995 /*
996  * in options.c:
997  */
998 LDAP_F( int )
999 ldap_get_option LDAP_P((
1000 	LDAP *ld,
1001 	int option,
1002 	void *outvalue));
1003 
1004 LDAP_F( int )
1005 ldap_set_option LDAP_P((
1006 	LDAP *ld,
1007 	int option,
1008 	LDAP_CONST void *invalue));
1009 
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,
1014 	void *params ));
1015 
1016 LDAP_F( int )
1017 ldap_set_rebind_proc LDAP_P((
1018 	LDAP *ld,
1019 	LDAP_REBIND_PROC *rebind_proc,
1020 	void *params ));
1021 
1022 /* V3 referral selection Function Callback Prototype */
1023 typedef int (LDAP_NEXTREF_PROC) LDAP_P((
1024 	LDAP *ld, char ***refsp, int *cntp,
1025 	void *params ));
1026 
1027 LDAP_F( int )
1028 ldap_set_nextref_proc LDAP_P((
1029 	LDAP *ld,
1030 	LDAP_NEXTREF_PROC *nextref_proc,
1031 	void *params ));
1032 
1033 /* V3 URLLIST Function Callback Prototype */
1034 typedef int (LDAP_URLLIST_PROC) LDAP_P((
1035 	LDAP *ld,
1036 	LDAPURLDesc **urllist,
1037 	LDAPURLDesc **url,
1038 	void *params ));
1039 
1040 LDAP_F( int )
1041 ldap_set_urllist_proc LDAP_P((
1042 	LDAP *ld,
1043 	LDAP_URLLIST_PROC *urllist_proc,
1044 	void *params ));
1045 
1046 /*
1047  * in controls.c:
1048  */
1049 #if LDAP_DEPRECATED
1050 LDAP_F( int )
1051 ldap_create_control LDAP_P((	/* deprecated, use ldap_control_create */
1052 	LDAP_CONST char *requestOID,
1053 	BerElement *ber,
1054 	int iscritical,
1055 	LDAPControl **ctrlp ));
1056 
1057 LDAP_F( LDAPControl * )
1058 ldap_find_control LDAP_P((	/* deprecated, use ldap_control_find */
1059 	LDAP_CONST char *oid,
1060 	LDAPControl **ctrls ));
1061 #endif
1062 
1063 LDAP_F( int )
1064 ldap_control_create LDAP_P((
1065 	LDAP_CONST char *requestOID,
1066 	int iscritical,
1067 	struct berval *value,
1068 	int dupval,
1069 	LDAPControl **ctrlp ));
1070 
1071 LDAP_F( LDAPControl * )
1072 ldap_control_find LDAP_P((
1073 	LDAP_CONST char *oid,
1074 	LDAPControl **ctrls,
1075 	LDAPControl ***nextctrlp ));
1076 
1077 LDAP_F( void )
1078 ldap_control_free LDAP_P((
1079 	LDAPControl *ctrl ));
1080 
1081 LDAP_F( void )
1082 ldap_controls_free LDAP_P((
1083 	LDAPControl **ctrls ));
1084 
1085 LDAP_F( LDAPControl ** )
1086 ldap_controls_dup LDAP_P((
1087 	LDAPControl *LDAP_CONST *controls ));
1088 
1089 LDAP_F( LDAPControl * )
1090 ldap_control_dup LDAP_P((
1091 	LDAP_CONST LDAPControl *c ));
1092 
1093 /*
1094  * in dnssrv.c:
1095  */
1096 LDAP_F( int )
1097 ldap_domain2dn LDAP_P((
1098 	LDAP_CONST char* domain,
1099 	char** dn ));
1100 
1101 LDAP_F( int )
1102 ldap_dn2domain LDAP_P((
1103 	LDAP_CONST char* dn,
1104 	char** domain ));
1105 
1106 LDAP_F( int )
1107 ldap_domain2hostlist LDAP_P((
1108 	LDAP_CONST char *domain,
1109 	char** hostlist ));
1110 
1111 /*
1112  * in extended.c:
1113  */
1114 LDAP_F( int )
1115 ldap_extended_operation LDAP_P((
1116 	LDAP			*ld,
1117 	LDAP_CONST char	*reqoid,
1118 	struct berval	*reqdata,
1119 	LDAPControl		**serverctrls,
1120 	LDAPControl		**clientctrls,
1121 	int				*msgidp ));
1122 
1123 LDAP_F( int )
1124 ldap_extended_operation_s LDAP_P((
1125 	LDAP			*ld,
1126 	LDAP_CONST char	*reqoid,
1127 	struct berval	*reqdata,
1128 	LDAPControl		**serverctrls,
1129 	LDAPControl		**clientctrls,
1130 	char			**retoidp,
1131 	struct berval	**retdatap ));
1132 
1133 LDAP_F( int )
1134 ldap_parse_extended_result LDAP_P((
1135 	LDAP			*ld,
1136 	LDAPMessage		*res,
1137 	char			**retoidp,
1138 	struct berval	**retdatap,
1139 	int				freeit ));
1140 
1141 LDAP_F( int )
1142 ldap_parse_intermediate LDAP_P((
1143 	LDAP			*ld,
1144 	LDAPMessage		*res,
1145 	char			**retoidp,
1146 	struct berval	**retdatap,
1147 	LDAPControl		***serverctrls,
1148 	int				freeit ));
1149 
1150 
1151 /*
1152  * in abandon.c:
1153  */
1154 LDAP_F( int )
1155 ldap_abandon_ext LDAP_P((
1156 	LDAP			*ld,
1157 	int				msgid,
1158 	LDAPControl		**serverctrls,
1159 	LDAPControl		**clientctrls ));
1160 
1161 #if LDAP_DEPRECATED
1162 LDAP_F( int )
1163 ldap_abandon LDAP_P((	/* deprecated, use ldap_abandon_ext */
1164 	LDAP *ld,
1165 	int msgid ));
1166 #endif
1167 
1168 /*
1169  * in add.c:
1170  */
1171 LDAP_F( int )
1172 ldap_add_ext LDAP_P((
1173 	LDAP			*ld,
1174 	LDAP_CONST char	*dn,
1175 	LDAPMod			**attrs,
1176 	LDAPControl		**serverctrls,
1177 	LDAPControl		**clientctrls,
1178 	int 			*msgidp ));
1179 
1180 LDAP_F( int )
1181 ldap_add_ext_s LDAP_P((
1182 	LDAP			*ld,
1183 	LDAP_CONST char	*dn,
1184 	LDAPMod			**attrs,
1185 	LDAPControl		**serverctrls,
1186 	LDAPControl		**clientctrls ));
1187 
1188 #if LDAP_DEPRECATED
1189 LDAP_F( int )
1190 ldap_add LDAP_P((	/* deprecated, use ldap_add_ext */
1191 	LDAP *ld,
1192 	LDAP_CONST char *dn,
1193 	LDAPMod **attrs ));
1194 
1195 LDAP_F( int )
1196 ldap_add_s LDAP_P((	/* deprecated, use ldap_add_ext_s */
1197 	LDAP *ld,
1198 	LDAP_CONST char *dn,
1199 	LDAPMod **attrs ));
1200 #endif
1201 
1202 
1203 /*
1204  * in sasl.c:
1205  */
1206 LDAP_F( int )
1207 ldap_sasl_bind LDAP_P((
1208 	LDAP			*ld,
1209 	LDAP_CONST char	*dn,
1210 	LDAP_CONST char	*mechanism,
1211 	struct berval	*cred,
1212 	LDAPControl		**serverctrls,
1213 	LDAPControl		**clientctrls,
1214 	int				*msgidp ));
1215 
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
1220  */
1221 #define LDAP_SASL_AUTOMATIC		0U
1222 #define LDAP_SASL_INTERACTIVE	1U
1223 #define LDAP_SASL_QUIET			2U
1224 
1225 /*
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)
1229  */
1230 typedef int (LDAP_SASL_INTERACT_PROC) LDAP_P((
1231 	LDAP *ld, unsigned flags, void* defaults, void *interact ));
1232 
1233 LDAP_F( int )
1234 ldap_sasl_interactive_bind LDAP_P((
1235 	LDAP *ld,
1236 	LDAP_CONST char *dn, /* usually NULL */
1237 	LDAP_CONST char *saslMechanism,
1238 	LDAPControl **serverControls,
1239 	LDAPControl **clientControls,
1240 
1241 	/* should be client controls */
1242 	unsigned flags,
1243 	LDAP_SASL_INTERACT_PROC *proc,
1244 	void *defaults,
1245 
1246 	/* as obtained from ldap_result() */
1247 	LDAPMessage *result,
1248 
1249 	/* returned during bind processing */
1250 	const char **rmech,
1251 	int *msgid ));
1252 
1253 LDAP_F( int )
1254 ldap_sasl_interactive_bind_s LDAP_P((
1255 	LDAP *ld,
1256 	LDAP_CONST char *dn, /* usually NULL */
1257 	LDAP_CONST char *saslMechanism,
1258 	LDAPControl **serverControls,
1259 	LDAPControl **clientControls,
1260 
1261 	/* should be client controls */
1262 	unsigned flags,
1263 	LDAP_SASL_INTERACT_PROC *proc,
1264 	void *defaults ));
1265 
1266 LDAP_F( int )
1267 ldap_sasl_bind_s LDAP_P((
1268 	LDAP			*ld,
1269 	LDAP_CONST char	*dn,
1270 	LDAP_CONST char	*mechanism,
1271 	struct berval	*cred,
1272 	LDAPControl		**serverctrls,
1273 	LDAPControl		**clientctrls,
1274 	struct berval	**servercredp ));
1275 
1276 LDAP_F( int )
1277 ldap_parse_sasl_bind_result LDAP_P((
1278 	LDAP			*ld,
1279 	LDAPMessage		*res,
1280 	struct berval	**servercredp,
1281 	int				freeit ));
1282 
1283 #if LDAP_DEPRECATED
1284 /*
1285  * in bind.c:
1286  *	(deprecated)
1287  */
1288 LDAP_F( int )
1289 ldap_bind LDAP_P((	/* deprecated, use ldap_sasl_bind */
1290 	LDAP *ld,
1291 	LDAP_CONST char *who,
1292 	LDAP_CONST char *passwd,
1293 	int authmethod ));
1294 
1295 LDAP_F( int )
1296 ldap_bind_s LDAP_P((	/* deprecated, use ldap_sasl_bind_s */
1297 	LDAP *ld,
1298 	LDAP_CONST char *who,
1299 	LDAP_CONST char *cred,
1300 	int authmethod ));
1301 
1302 /*
1303  * in sbind.c:
1304  */
1305 LDAP_F( int )
1306 ldap_simple_bind LDAP_P(( /* deprecated, use ldap_sasl_bind */
1307 	LDAP *ld,
1308 	LDAP_CONST char *who,
1309 	LDAP_CONST char *passwd ));
1310 
1311 LDAP_F( int )
1312 ldap_simple_bind_s LDAP_P(( /* deprecated, use ldap_sasl_bind_s */
1313 	LDAP *ld,
1314 	LDAP_CONST char *who,
1315 	LDAP_CONST char *passwd ));
1316 
1317 #endif
1318 
1319 
1320 /*
1321  * in compare.c:
1322  */
1323 LDAP_F( int )
1324 ldap_compare_ext LDAP_P((
1325 	LDAP			*ld,
1326 	LDAP_CONST char	*dn,
1327 	LDAP_CONST char	*attr,
1328 	struct berval	*bvalue,
1329 	LDAPControl		**serverctrls,
1330 	LDAPControl		**clientctrls,
1331 	int 			*msgidp ));
1332 
1333 LDAP_F( int )
1334 ldap_compare_ext_s LDAP_P((
1335 	LDAP			*ld,
1336 	LDAP_CONST char	*dn,
1337 	LDAP_CONST char	*attr,
1338 	struct berval	*bvalue,
1339 	LDAPControl		**serverctrls,
1340 	LDAPControl		**clientctrls ));
1341 
1342 #if LDAP_DEPRECATED
1343 LDAP_F( int )
1344 ldap_compare LDAP_P((	/* deprecated, use ldap_compare_ext */
1345 	LDAP *ld,
1346 	LDAP_CONST char *dn,
1347 	LDAP_CONST char *attr,
1348 	LDAP_CONST char *value ));
1349 
1350 LDAP_F( int )
1351 ldap_compare_s LDAP_P((	/* deprecated, use ldap_compare_ext_s */
1352 	LDAP *ld,
1353 	LDAP_CONST char *dn,
1354 	LDAP_CONST char *attr,
1355 	LDAP_CONST char *value ));
1356 #endif
1357 
1358 
1359 /*
1360  * in delete.c:
1361  */
1362 LDAP_F( int )
1363 ldap_delete_ext LDAP_P((
1364 	LDAP			*ld,
1365 	LDAP_CONST char	*dn,
1366 	LDAPControl		**serverctrls,
1367 	LDAPControl		**clientctrls,
1368 	int 			*msgidp ));
1369 
1370 LDAP_F( int )
1371 ldap_delete_ext_s LDAP_P((
1372 	LDAP			*ld,
1373 	LDAP_CONST char	*dn,
1374 	LDAPControl		**serverctrls,
1375 	LDAPControl		**clientctrls ));
1376 
1377 #if LDAP_DEPRECATED
1378 LDAP_F( int )
1379 ldap_delete LDAP_P((	/* deprecated, use ldap_delete_ext */
1380 	LDAP *ld,
1381 	LDAP_CONST char *dn ));
1382 
1383 LDAP_F( int )
1384 ldap_delete_s LDAP_P((	/* deprecated, use ldap_delete_ext_s */
1385 	LDAP *ld,
1386 	LDAP_CONST char *dn ));
1387 #endif
1388 
1389 
1390 /*
1391  * in error.c:
1392  */
1393 LDAP_F( int )
1394 ldap_parse_result LDAP_P((
1395 	LDAP			*ld,
1396 	LDAPMessage		*res,
1397 	int				*errcodep,
1398 	char			**matcheddnp,
1399 	char			**diagmsgp,
1400 	char			***referralsp,
1401 	LDAPControl		***serverctrls,
1402 	int				freeit ));
1403 
1404 LDAP_F( char * )
1405 ldap_err2string LDAP_P((
1406 	int err ));
1407 
1408 #if LDAP_DEPRECATED
1409 LDAP_F( int )
1410 ldap_result2error LDAP_P((	/* deprecated, use ldap_parse_result */
1411 	LDAP *ld,
1412 	LDAPMessage *r,
1413 	int freeit ));
1414 
1415 LDAP_F( void )
1416 ldap_perror LDAP_P((	/* deprecated, use ldap_err2string */
1417 	LDAP *ld,
1418 	LDAP_CONST char *s ));
1419 #endif
1420 
1421 
1422 /*
1423  * in modify.c:
1424  */
1425 LDAP_F( int )
1426 ldap_modify_ext LDAP_P((
1427 	LDAP			*ld,
1428 	LDAP_CONST char	*dn,
1429 	LDAPMod			**mods,
1430 	LDAPControl		**serverctrls,
1431 	LDAPControl		**clientctrls,
1432 	int 			*msgidp ));
1433 
1434 LDAP_F( int )
1435 ldap_modify_ext_s LDAP_P((
1436 	LDAP			*ld,
1437 	LDAP_CONST char	*dn,
1438 	LDAPMod			**mods,
1439 	LDAPControl		**serverctrls,
1440 	LDAPControl		**clientctrls ));
1441 
1442 #if LDAP_DEPRECATED
1443 LDAP_F( int )
1444 ldap_modify LDAP_P((	/* deprecated, use ldap_modify_ext */
1445 	LDAP *ld,
1446 	LDAP_CONST char *dn,
1447 	LDAPMod **mods ));
1448 
1449 LDAP_F( int )
1450 ldap_modify_s LDAP_P((	/* deprecated, use ldap_modify_ext_s */
1451 	LDAP *ld,
1452 	LDAP_CONST char *dn,
1453 	LDAPMod **mods ));
1454 #endif
1455 
1456 
1457 /*
1458  * in modrdn.c:
1459  */
1460 LDAP_F( int )
1461 ldap_rename LDAP_P((
1462 	LDAP *ld,
1463 	LDAP_CONST char *dn,
1464 	LDAP_CONST char *newrdn,
1465 	LDAP_CONST char *newSuperior,
1466 	int deleteoldrdn,
1467 	LDAPControl **sctrls,
1468 	LDAPControl **cctrls,
1469 	int *msgidp ));
1470 
1471 LDAP_F( int )
1472 ldap_rename_s LDAP_P((
1473 	LDAP *ld,
1474 	LDAP_CONST char *dn,
1475 	LDAP_CONST char *newrdn,
1476 	LDAP_CONST char *newSuperior,
1477 	int deleteoldrdn,
1478 	LDAPControl **sctrls,
1479 	LDAPControl **cctrls ));
1480 
1481 #if LDAP_DEPRECATED
1482 LDAP_F( int )
1483 ldap_rename2 LDAP_P((	/* deprecated, use ldap_rename */
1484 	LDAP *ld,
1485 	LDAP_CONST char *dn,
1486 	LDAP_CONST char *newrdn,
1487 	LDAP_CONST char *newSuperior,
1488 	int deleteoldrdn ));
1489 
1490 LDAP_F( int )
1491 ldap_rename2_s LDAP_P((	/* deprecated, use ldap_rename_s */
1492 	LDAP *ld,
1493 	LDAP_CONST char *dn,
1494 	LDAP_CONST char *newrdn,
1495 	LDAP_CONST char *newSuperior,
1496 	int deleteoldrdn ));
1497 
1498 LDAP_F( int )
1499 ldap_modrdn LDAP_P((	/* deprecated, use ldap_rename */
1500 	LDAP *ld,
1501 	LDAP_CONST char *dn,
1502 	LDAP_CONST char *newrdn ));
1503 
1504 LDAP_F( int )
1505 ldap_modrdn_s LDAP_P((	/* deprecated, use ldap_rename_s */
1506 	LDAP *ld,
1507 	LDAP_CONST char *dn,
1508 	LDAP_CONST char *newrdn ));
1509 
1510 LDAP_F( int )
1511 ldap_modrdn2 LDAP_P((	/* deprecated, use ldap_rename */
1512 	LDAP *ld,
1513 	LDAP_CONST char *dn,
1514 	LDAP_CONST char *newrdn,
1515 	int deleteoldrdn ));
1516 
1517 LDAP_F( int )
1518 ldap_modrdn2_s LDAP_P((	/* deprecated, use ldap_rename_s */
1519 	LDAP *ld,
1520 	LDAP_CONST char *dn,
1521 	LDAP_CONST char *newrdn,
1522 	int deleteoldrdn));
1523 #endif
1524 
1525 
1526 /*
1527  * in open.c:
1528  */
1529 #if LDAP_DEPRECATED
1530 LDAP_F( LDAP * )
1531 ldap_init LDAP_P(( /* deprecated, use ldap_create or ldap_initialize */
1532 	LDAP_CONST char *host,
1533 	int port ));
1534 
1535 LDAP_F( LDAP * )
1536 ldap_open LDAP_P((	/* deprecated, use ldap_create or ldap_initialize */
1537 	LDAP_CONST char *host,
1538 	int port ));
1539 #endif
1540 
1541 LDAP_F( int )
1542 ldap_create LDAP_P((
1543 	LDAP **ldp ));
1544 
1545 LDAP_F( int )
1546 ldap_initialize LDAP_P((
1547 	LDAP **ldp,
1548 	LDAP_CONST char *url ));
1549 
1550 LDAP_F( LDAP * )
1551 ldap_dup LDAP_P((
1552 	LDAP *old ));
1553 
1554 LDAP_F( int )
1555 ldap_connect( LDAP *ld );
1556 
1557 /*
1558  * in tls.c
1559  */
1560 
1561 LDAP_F( int )
1562 ldap_tls_inplace LDAP_P((
1563 	LDAP *ld ));
1564 
1565 LDAP_F( int )
1566 ldap_start_tls LDAP_P((
1567 	LDAP *ld,
1568 	LDAPControl **serverctrls,
1569 	LDAPControl **clientctrls,
1570 	int *msgidp ));
1571 
1572 LDAP_F( int )
1573 ldap_install_tls LDAP_P((
1574 	LDAP *ld ));
1575 
1576 LDAP_F( int )
1577 ldap_start_tls_s LDAP_P((
1578 	LDAP *ld,
1579 	LDAPControl **serverctrls,
1580 	LDAPControl **clientctrls ));
1581 
1582 /*
1583  * in messages.c:
1584  */
1585 LDAP_F( LDAPMessage * )
1586 ldap_first_message LDAP_P((
1587 	LDAP *ld,
1588 	LDAPMessage *chain ));
1589 
1590 LDAP_F( LDAPMessage * )
1591 ldap_next_message LDAP_P((
1592 	LDAP *ld,
1593 	LDAPMessage *msg ));
1594 
1595 LDAP_F( int )
1596 ldap_count_messages LDAP_P((
1597 	LDAP *ld,
1598 	LDAPMessage *chain ));
1599 
1600 /*
1601  * in references.c:
1602  */
1603 LDAP_F( LDAPMessage * )
1604 ldap_first_reference LDAP_P((
1605 	LDAP *ld,
1606 	LDAPMessage *chain ));
1607 
1608 LDAP_F( LDAPMessage * )
1609 ldap_next_reference LDAP_P((
1610 	LDAP *ld,
1611 	LDAPMessage *ref ));
1612 
1613 LDAP_F( int )
1614 ldap_count_references LDAP_P((
1615 	LDAP *ld,
1616 	LDAPMessage *chain ));
1617 
1618 LDAP_F( int )
1619 ldap_parse_reference LDAP_P((
1620 	LDAP			*ld,
1621 	LDAPMessage		*ref,
1622 	char			***referralsp,
1623 	LDAPControl		***serverctrls,
1624 	int				freeit));
1625 
1626 
1627 /*
1628  * in getentry.c:
1629  */
1630 LDAP_F( LDAPMessage * )
1631 ldap_first_entry LDAP_P((
1632 	LDAP *ld,
1633 	LDAPMessage *chain ));
1634 
1635 LDAP_F( LDAPMessage * )
1636 ldap_next_entry LDAP_P((
1637 	LDAP *ld,
1638 	LDAPMessage *entry ));
1639 
1640 LDAP_F( int )
1641 ldap_count_entries LDAP_P((
1642 	LDAP *ld,
1643 	LDAPMessage *chain ));
1644 
1645 LDAP_F( int )
1646 ldap_get_entry_controls LDAP_P((
1647 	LDAP			*ld,
1648 	LDAPMessage		*entry,
1649 	LDAPControl		***serverctrls));
1650 
1651 
1652 /*
1653  * in addentry.c
1654  */
1655 LDAP_F( LDAPMessage * )
1656 ldap_delete_result_entry LDAP_P((
1657 	LDAPMessage **list,
1658 	LDAPMessage *e ));
1659 
1660 LDAP_F( void )
1661 ldap_add_result_entry LDAP_P((
1662 	LDAPMessage **list,
1663 	LDAPMessage *e ));
1664 
1665 
1666 /*
1667  * in getdn.c
1668  */
1669 LDAP_F( char * )
1670 ldap_get_dn LDAP_P((
1671 	LDAP *ld,
1672 	LDAPMessage *entry ));
1673 
1674 typedef struct ldap_ava {
1675 	struct berval la_attr;
1676 	struct berval la_value;
1677 	unsigned la_flags;
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
1684 
1685 	void *la_private;
1686 } LDAPAVA;
1687 
1688 typedef LDAPAVA** LDAPRDN;
1689 typedef LDAPRDN* LDAPDN;
1690 
1691 /* DN formats */
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
1700 
1701 /* DN flags */
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
1707 
1708 LDAP_F( void ) ldap_rdnfree LDAP_P(( LDAPRDN rdn ));
1709 LDAP_F( void ) ldap_dnfree LDAP_P(( LDAPDN dn ));
1710 
1711 LDAP_F( int )
1712 ldap_bv2dn LDAP_P((
1713 	struct berval *bv,
1714 	LDAPDN *dn,
1715 	unsigned flags ));
1716 
1717 LDAP_F( int )
1718 ldap_str2dn LDAP_P((
1719 	LDAP_CONST char *str,
1720 	LDAPDN *dn,
1721 	unsigned flags ));
1722 
1723 LDAP_F( int )
1724 ldap_dn2bv LDAP_P((
1725 	LDAPDN dn,
1726 	struct berval *bv,
1727 	unsigned flags ));
1728 
1729 LDAP_F( int )
1730 ldap_dn2str LDAP_P((
1731 	LDAPDN dn,
1732 	char **str,
1733 	unsigned flags ));
1734 
1735 LDAP_F( int )
1736 ldap_bv2rdn LDAP_P((
1737 	struct berval *bv,
1738 	LDAPRDN *rdn,
1739 	char **next,
1740 	unsigned flags ));
1741 
1742 LDAP_F( int )
1743 ldap_str2rdn LDAP_P((
1744 	LDAP_CONST char *str,
1745 	LDAPRDN *rdn,
1746 	char **next,
1747 	unsigned flags ));
1748 
1749 LDAP_F( int )
1750 ldap_rdn2bv LDAP_P((
1751 	LDAPRDN rdn,
1752 	struct berval *bv,
1753 	unsigned flags ));
1754 
1755 LDAP_F( int )
1756 ldap_rdn2str LDAP_P((
1757 	LDAPRDN rdn,
1758 	char **str,
1759 	unsigned flags ));
1760 
1761 LDAP_F( int )
1762 ldap_dn_normalize LDAP_P((
1763 	LDAP_CONST char *in, unsigned iflags,
1764 	char **out, unsigned oflags ));
1765 
1766 LDAP_F( char * )
1767 ldap_dn2ufn LDAP_P(( /* deprecated, use ldap_str2dn/dn2str */
1768 	LDAP_CONST char *dn ));
1769 
1770 LDAP_F( char ** )
1771 ldap_explode_dn LDAP_P(( /* deprecated, ldap_str2dn */
1772 	LDAP_CONST char *dn,
1773 	int notypes ));
1774 
1775 LDAP_F( char ** )
1776 ldap_explode_rdn LDAP_P(( /* deprecated, ldap_str2rdn */
1777 	LDAP_CONST char *rdn,
1778 	int notypes ));
1779 
1780 typedef int LDAPDN_rewrite_func
1781 	LDAP_P(( LDAPDN dn, unsigned flags, void *ctx ));
1782 
1783 LDAP_F( int )
1784 ldap_X509dn2bv LDAP_P(( void *x509_name, struct berval *dn,
1785 	LDAPDN_rewrite_func *func, unsigned flags ));
1786 
1787 LDAP_F( char * )
1788 ldap_dn2dcedn LDAP_P(( /* deprecated, ldap_str2dn/dn2str */
1789 	LDAP_CONST char *dn ));
1790 
1791 LDAP_F( char * )
1792 ldap_dcedn2dn LDAP_P(( /* deprecated, ldap_str2dn/dn2str */
1793 	LDAP_CONST char *dce ));
1794 
1795 LDAP_F( char * )
1796 ldap_dn2ad_canonical LDAP_P(( /* deprecated, ldap_str2dn/dn2str */
1797 	LDAP_CONST char *dn ));
1798 
1799 LDAP_F( int )
1800 ldap_get_dn_ber LDAP_P((
1801 	LDAP *ld, LDAPMessage *e, BerElement **berout, struct berval *dn ));
1802 
1803 LDAP_F( int )
1804 ldap_get_attribute_ber LDAP_P((
1805 	LDAP *ld, LDAPMessage *e, BerElement *ber, struct berval *attr,
1806 	struct berval **vals ));
1807 
1808 /*
1809  * in getattr.c
1810  */
1811 LDAP_F( char * )
1812 ldap_first_attribute LDAP_P((
1813 	LDAP *ld,
1814 	LDAPMessage *entry,
1815 	BerElement **ber ));
1816 
1817 LDAP_F( char * )
1818 ldap_next_attribute LDAP_P((
1819 	LDAP *ld,
1820 	LDAPMessage *entry,
1821 	BerElement *ber ));
1822 
1823 
1824 /*
1825  * in getvalues.c
1826  */
1827 LDAP_F( struct berval ** )
1828 ldap_get_values_len LDAP_P((
1829 	LDAP *ld,
1830 	LDAPMessage *entry,
1831 	LDAP_CONST char *target ));
1832 
1833 LDAP_F( int )
1834 ldap_count_values_len LDAP_P((
1835 	struct berval **vals ));
1836 
1837 LDAP_F( void )
1838 ldap_value_free_len LDAP_P((
1839 	struct berval **vals ));
1840 
1841 #if LDAP_DEPRECATED
1842 LDAP_F( char ** )
1843 ldap_get_values LDAP_P((	/* deprecated, use ldap_get_values_len */
1844 	LDAP *ld,
1845 	LDAPMessage *entry,
1846 	LDAP_CONST char *target ));
1847 
1848 LDAP_F( int )
1849 ldap_count_values LDAP_P((	/* deprecated, use ldap_count_values_len */
1850 	char **vals ));
1851 
1852 LDAP_F( void )
1853 ldap_value_free LDAP_P((	/* deprecated, use ldap_value_free_len */
1854 	char **vals ));
1855 #endif
1856 
1857 /*
1858  * in result.c:
1859  */
1860 LDAP_F( int )
1861 ldap_result LDAP_P((
1862 	LDAP *ld,
1863 	int msgid,
1864 	int all,
1865 	struct timeval *timeout,
1866 	LDAPMessage **result ));
1867 
1868 LDAP_F( int )
1869 ldap_msgtype LDAP_P((
1870 	LDAPMessage *lm ));
1871 
1872 LDAP_F( int )
1873 ldap_msgid   LDAP_P((
1874 	LDAPMessage *lm ));
1875 
1876 LDAP_F( int )
1877 ldap_msgfree LDAP_P((
1878 	LDAPMessage *lm ));
1879 
1880 LDAP_F( int )
1881 ldap_msgdelete LDAP_P((
1882 	LDAP *ld,
1883 	int msgid ));
1884 
1885 
1886 /*
1887  * in search.c:
1888  */
1889 LDAP_F( int )
1890 ldap_bv2escaped_filter_value LDAP_P((
1891 	struct berval *in,
1892 	struct berval *out ));
1893 
1894 LDAP_F( int )
1895 ldap_search_ext LDAP_P((
1896 	LDAP			*ld,
1897 	LDAP_CONST char	*base,
1898 	int				scope,
1899 	LDAP_CONST char	*filter,
1900 	char			**attrs,
1901 	int				attrsonly,
1902 	LDAPControl		**serverctrls,
1903 	LDAPControl		**clientctrls,
1904 	struct timeval	*timeout,
1905 	int				sizelimit,
1906 	int				*msgidp ));
1907 
1908 LDAP_F( int )
1909 ldap_search_ext_s LDAP_P((
1910 	LDAP			*ld,
1911 	LDAP_CONST char	*base,
1912 	int				scope,
1913 	LDAP_CONST char	*filter,
1914 	char			**attrs,
1915 	int				attrsonly,
1916 	LDAPControl		**serverctrls,
1917 	LDAPControl		**clientctrls,
1918 	struct timeval	*timeout,
1919 	int				sizelimit,
1920 	LDAPMessage		**res ));
1921 
1922 #if LDAP_DEPRECATED
1923 LDAP_F( int )
1924 ldap_search LDAP_P((	/* deprecated, use ldap_search_ext */
1925 	LDAP *ld,
1926 	LDAP_CONST char *base,
1927 	int scope,
1928 	LDAP_CONST char *filter,
1929 	char **attrs,
1930 	int attrsonly ));
1931 
1932 LDAP_F( int )
1933 ldap_search_s LDAP_P((	/* deprecated, use ldap_search_ext_s */
1934 	LDAP *ld,
1935 	LDAP_CONST char *base,
1936 	int scope,
1937 	LDAP_CONST char *filter,
1938 	char **attrs,
1939 	int attrsonly,
1940 	LDAPMessage **res ));
1941 
1942 LDAP_F( int )
1943 ldap_search_st LDAP_P((	/* deprecated, use ldap_search_ext_s */
1944 	LDAP *ld,
1945 	LDAP_CONST char *base,
1946 	int scope,
1947 	LDAP_CONST char *filter,
1948     char **attrs,
1949 	int attrsonly,
1950 	struct timeval *timeout,
1951 	LDAPMessage **res ));
1952 #endif
1953 
1954 /*
1955  * in unbind.c
1956  */
1957 LDAP_F( int )
1958 ldap_unbind_ext LDAP_P((
1959 	LDAP			*ld,
1960 	LDAPControl		**serverctrls,
1961 	LDAPControl		**clientctrls));
1962 
1963 LDAP_F( int )
1964 ldap_unbind_ext_s LDAP_P((
1965 	LDAP			*ld,
1966 	LDAPControl		**serverctrls,
1967 	LDAPControl		**clientctrls));
1968 
1969 LDAP_F( int )
1970 ldap_destroy LDAP_P((
1971 	LDAP			*ld));
1972 
1973 #if LDAP_DEPRECATED
1974 LDAP_F( int )
1975 ldap_unbind LDAP_P(( /* deprecated, use ldap_unbind_ext */
1976 	LDAP *ld ));
1977 
1978 LDAP_F( int )
1979 ldap_unbind_s LDAP_P(( /* deprecated, use ldap_unbind_ext_s */
1980 	LDAP *ld ));
1981 #endif
1982 
1983 /*
1984  * in filter.c
1985  */
1986 LDAP_F( int )
1987 ldap_put_vrFilter LDAP_P((
1988 	BerElement *ber,
1989 	const char *vrf ));
1990 
1991 /*
1992  * in free.c
1993  */
1994 
1995 LDAP_F( void * )
1996 ldap_memalloc LDAP_P((
1997 	ber_len_t s ));
1998 
1999 LDAP_F( void * )
2000 ldap_memrealloc LDAP_P((
2001 	void* p,
2002 	ber_len_t s ));
2003 
2004 LDAP_F( void * )
2005 ldap_memcalloc LDAP_P((
2006 	ber_len_t n,
2007 	ber_len_t s ));
2008 
2009 LDAP_F( void )
2010 ldap_memfree LDAP_P((
2011 	void* p ));
2012 
2013 LDAP_F( void )
2014 ldap_memvfree LDAP_P((
2015 	void** v ));
2016 
2017 LDAP_F( char * )
2018 ldap_strdup LDAP_P((
2019 	LDAP_CONST char * ));
2020 
2021 LDAP_F( void )
2022 ldap_mods_free LDAP_P((
2023 	LDAPMod **mods,
2024 	int freemods ));
2025 
2026 
2027 #if LDAP_DEPRECATED
2028 /*
2029  * in sort.c (deprecated, use custom code instead)
2030  */
2031 typedef int (LDAP_SORT_AD_CMP_PROC) LDAP_P(( /* deprecated */
2032 	LDAP_CONST char *left,
2033 	LDAP_CONST char *right ));
2034 
2035 typedef int (LDAP_SORT_AV_CMP_PROC) LDAP_P(( /* deprecated */
2036 	LDAP_CONST void *left,
2037 	LDAP_CONST void *right ));
2038 
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 ));
2044 
2045 LDAP_F( int )	/* deprecated */
2046 ldap_sort_values LDAP_P((
2047 	LDAP *ld,
2048 	char **vals,
2049 	LDAP_SORT_AV_CMP_PROC *cmp ));
2050 
2051 LDAP_F( int ) /* deprecated */
2052 ldap_sort_strcasecmp LDAP_P((
2053 	LDAP_CONST void *a,
2054 	LDAP_CONST void *b ));
2055 #endif
2056 
2057 /*
2058  * in url.c
2059  */
2060 LDAP_F( int )
2061 ldap_is_ldap_url LDAP_P((
2062 	LDAP_CONST char *url ));
2063 
2064 LDAP_F( int )
2065 ldap_is_ldaps_url LDAP_P((
2066 	LDAP_CONST char *url ));
2067 
2068 LDAP_F( int )
2069 ldap_is_ldapi_url LDAP_P((
2070 	LDAP_CONST char *url ));
2071 
2072 #ifdef LDAP_CONNECTIONLESS
2073 LDAP_F( int )
2074 ldap_is_ldapc_url LDAP_P((
2075 	LDAP_CONST char *url ));
2076 #endif
2077 
2078 LDAP_F( int )
2079 ldap_url_parse LDAP_P((
2080 	LDAP_CONST char *url,
2081 	LDAPURLDesc **ludpp ));
2082 
2083 LDAP_F( char * )
2084 ldap_url_desc2str LDAP_P((
2085 	LDAPURLDesc *ludp ));
2086 
2087 LDAP_F( void )
2088 ldap_free_urldesc LDAP_P((
2089 	LDAPURLDesc *ludp ));
2090 
2091 
2092 /*
2093  * LDAP Cancel Extended Operation <draft-zeilenga-ldap-cancel-xx.txt>
2094  *  in cancel.c
2095  */
2096 #define LDAP_API_FEATURE_CANCEL 1000
2097 
2098 LDAP_F( int )
2099 ldap_cancel LDAP_P(( LDAP *ld,
2100 	int cancelid,
2101 	LDAPControl		**sctrls,
2102 	LDAPControl		**cctrls,
2103 	int				*msgidp ));
2104 
2105 LDAP_F( int )
2106 ldap_cancel_s LDAP_P(( LDAP *ld,
2107 	int cancelid,
2108 	LDAPControl **sctrl,
2109 	LDAPControl **cctrl ));
2110 
2111 /*
2112  * LDAP Turn Extended Operation <draft-zeilenga-ldap-turn-xx.txt>
2113  *  in turn.c
2114  */
2115 #define LDAP_API_FEATURE_TURN 1000
2116 
2117 LDAP_F( int )
2118 ldap_turn LDAP_P(( LDAP *ld,
2119 	int mutual,
2120 	LDAP_CONST char* identifier,
2121 	LDAPControl		**sctrls,
2122 	LDAPControl		**cctrls,
2123 	int				*msgidp ));
2124 
2125 LDAP_F( int )
2126 ldap_turn_s LDAP_P(( LDAP *ld,
2127 	int mutual,
2128 	LDAP_CONST char* identifier,
2129 	LDAPControl **sctrl,
2130 	LDAPControl **cctrl ));
2131 
2132 /*
2133  * LDAP Paged Results
2134  *	in pagectrl.c
2135  */
2136 #define LDAP_API_FEATURE_PAGED_RESULTS 2000
2137 
2138 LDAP_F( int )
2139 ldap_create_page_control_value LDAP_P((
2140 	LDAP *ld,
2141 	ber_int_t pagesize,
2142 	struct berval *cookie,
2143 	struct berval *value ));
2144 
2145 LDAP_F( int )
2146 ldap_create_page_control LDAP_P((
2147 	LDAP *ld,
2148 	ber_int_t pagesize,
2149 	struct berval *cookie,
2150 	int iscritical,
2151 	LDAPControl **ctrlp ));
2152 
2153 #if LDAP_DEPRECATED
2154 LDAP_F( int )
2155 ldap_parse_page_control LDAP_P((
2156 	/* deprecated, use ldap_parse_pageresponse_control */
2157 	LDAP *ld,
2158 	LDAPControl **ctrls,
2159 	ber_int_t *count,
2160 	struct berval **cookie ));
2161 #endif
2162 
2163 LDAP_F( int )
2164 ldap_parse_pageresponse_control LDAP_P((
2165 	LDAP *ld,
2166 	LDAPControl *ctrl,
2167 	ber_int_t *count,
2168 	struct berval *cookie ));
2169 
2170 /*
2171  * LDAP Server Side Sort
2172  *	in sortctrl.c
2173  */
2174 #define LDAP_API_FEATURE_SERVER_SIDE_SORT 2000
2175 
2176 /* structure for a sort-key */
2177 typedef struct ldapsortkey {
2178 	char *attributeType;
2179 	char *orderingRule;
2180 	int reverseOrder;
2181 } LDAPSortKey;
2182 
2183 LDAP_F( int )
2184 ldap_create_sort_keylist LDAP_P((
2185 	LDAPSortKey ***sortKeyList,
2186 	char *keyString ));
2187 
2188 LDAP_F( void )
2189 ldap_free_sort_keylist LDAP_P((
2190 	LDAPSortKey **sortkeylist ));
2191 
2192 LDAP_F( int )
2193 ldap_create_sort_control_value LDAP_P((
2194 	LDAP *ld,
2195 	LDAPSortKey **keyList,
2196 	struct berval *value ));
2197 
2198 LDAP_F( int )
2199 ldap_create_sort_control LDAP_P((
2200 	LDAP *ld,
2201 	LDAPSortKey **keyList,
2202 	int iscritical,
2203 	LDAPControl **ctrlp ));
2204 
2205 LDAP_F( int )
2206 ldap_parse_sortresponse_control LDAP_P((
2207 	LDAP *ld,
2208 	LDAPControl *ctrl,
2209 	ber_int_t *result,
2210 	char **attribute ));
2211 
2212 /*
2213  * LDAP Virtual List View
2214  *	in vlvctrl.c
2215  */
2216 #define LDAP_API_FEATURE_VIRTUAL_LIST_VIEW 2000
2217 
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;
2228 } LDAPVLVInfo;
2229 
2230 LDAP_F( int )
2231 ldap_create_vlv_control_value LDAP_P((
2232 	LDAP *ld,
2233 	LDAPVLVInfo *ldvlistp,
2234 	struct berval *value));
2235 
2236 LDAP_F( int )
2237 ldap_create_vlv_control LDAP_P((
2238 	LDAP *ld,
2239 	LDAPVLVInfo *ldvlistp,
2240 	LDAPControl **ctrlp ));
2241 
2242 LDAP_F( int )
2243 ldap_parse_vlvresponse_control LDAP_P((
2244 	LDAP          *ld,
2245 	LDAPControl   *ctrls,
2246 	ber_int_t *target_posp,
2247 	ber_int_t *list_countp,
2248 	struct berval **contextp,
2249 	int           *errcodep ));
2250 
2251 /*
2252  * LDAP Verify Credentials
2253  */
2254 #define LDAP_API_FEATURE_VERIFY_CREDENTIALS 1000
2255 
2256 LDAP_F( int )
2257 ldap_verify_credentials LDAP_P((
2258 	LDAP		*ld,
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,
2266 	int		*msgidp ));
2267 
2268 LDAP_F( int )
2269 ldap_verify_credentials_s LDAP_P((
2270 	LDAP		*ld,
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,
2278 	int				*code,
2279 	char			**diagmsgp,
2280 	struct berval	**scookie,
2281 	struct berval	**servercredp,
2282 	LDAPControl	***vcoctrls));
2283 
2284 
2285 LDAP_F( int )
2286 ldap_parse_verify_credentials LDAP_P((
2287 	LDAP		*ld,
2288 	LDAPMessage	*res,
2289 	int			*code,
2290 	char			**diagmsgp,
2291 	struct berval	**cookie,
2292 	struct berval	**servercredp,
2293 	LDAPControl	***vcctrls));
2294 
2295 /* not yet implemented */
2296 /* #define LDAP_API_FEATURE_VERIFY_CREDENTIALS_INTERACTIVE 1000 */
2297 #ifdef LDAP_API_FEATURE_VERIFY_CREDENTIALS_INTERACTIVE
2298 LDAP_F( int )
2299 ldap_verify_credentials_interactive LDAP_P((
2300 	LDAP *ld,
2301 	LDAP_CONST char *dn, /* usually NULL */
2302 	LDAP_CONST char *saslMechanism,
2303 	LDAPControl **vcControls,
2304 	LDAPControl **serverControls,
2305 	LDAPControl **clientControls,
2306 
2307 	/* should be client controls */
2308 	unsigned flags,
2309 	LDAP_SASL_INTERACT_PROC *proc,
2310 	void *defaults,
2311 	void *context,
2312 
2313 	/* as obtained from ldap_result() */
2314 	LDAPMessage *result,
2315 
2316 	/* returned during bind processing */
2317 	const char **rmech,
2318 	int *msgid ));
2319 #endif
2320 
2321 /*
2322  * LDAP Who Am I?
2323  *	in whoami.c
2324  */
2325 #define LDAP_API_FEATURE_WHOAMI 1000
2326 
2327 LDAP_F( int )
2328 ldap_parse_whoami LDAP_P((
2329 	LDAP *ld,
2330 	LDAPMessage *res,
2331 	struct berval **authzid ));
2332 
2333 LDAP_F( int )
2334 ldap_whoami LDAP_P(( LDAP *ld,
2335 	LDAPControl		**sctrls,
2336 	LDAPControl		**cctrls,
2337 	int				*msgidp ));
2338 
2339 LDAP_F( int )
2340 ldap_whoami_s LDAP_P((
2341 	LDAP *ld,
2342 	struct berval **authzid,
2343 	LDAPControl **sctrls,
2344 	LDAPControl **cctrls ));
2345 
2346 /*
2347  * LDAP Password Modify
2348  *	in passwd.c
2349  */
2350 #define LDAP_API_FEATURE_PASSWD_MODIFY 1000
2351 
2352 LDAP_F( int )
2353 ldap_parse_passwd LDAP_P((
2354 	LDAP *ld,
2355 	LDAPMessage *res,
2356 	struct berval *newpasswd ));
2357 
2358 LDAP_F( int )
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,
2365 	int				*msgidp ));
2366 
2367 LDAP_F( int )
2368 ldap_passwd_s LDAP_P((
2369 	LDAP *ld,
2370 	struct berval	*user,
2371 	struct berval	*oldpw,
2372 	struct berval	*newpw,
2373 	struct berval *newpasswd,
2374 	LDAPControl **sctrls,
2375 	LDAPControl **cctrls ));
2376 
2377 #ifdef LDAP_CONTROL_PASSWORDPOLICYREQUEST
2378 /*
2379  * LDAP Password Policy controls
2380  *	in ppolicy.c
2381  */
2382 #define LDAP_API_FEATURE_PASSWORD_POLICY 1000
2383 
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,
2395        PP_noError = 65535
2396 } LDAPPasswordPolicyError;
2397 
2398 LDAP_F( int )
2399 ldap_create_passwordpolicy_control LDAP_P((
2400         LDAP *ld,
2401         LDAPControl **ctrlp ));
2402 
2403 LDAP_F( int )
2404 ldap_parse_passwordpolicy_control LDAP_P((
2405         LDAP *ld,
2406         LDAPControl *ctrl,
2407         ber_int_t *expirep,
2408         ber_int_t *gracep,
2409         LDAPPasswordPolicyError *errorp ));
2410 
2411 LDAP_F( const char * )
2412 ldap_passwordpolicy_err2txt LDAP_P(( LDAPPasswordPolicyError ));
2413 #endif /* LDAP_CONTROL_PASSWORDPOLICYREQUEST */
2414 
2415 LDAP_F( int )
2416 ldap_parse_password_expiring_control LDAP_P((
2417 	LDAP           *ld,
2418 	LDAPControl    *ctrl,
2419 	long           *secondsp ));
2420 
2421 /*
2422  * LDAP Dynamic Directory Services Refresh -- RFC 2589
2423  *	in dds.c
2424  */
2425 #define LDAP_API_FEATURE_REFRESH 1000
2426 
2427 LDAP_F( int )
2428 ldap_parse_refresh LDAP_P((
2429 	LDAP *ld,
2430 	LDAPMessage *res,
2431 	ber_int_t *newttl ));
2432 
2433 LDAP_F( int )
2434 ldap_refresh LDAP_P(( LDAP *ld,
2435 	struct berval	*dn,
2436 	ber_int_t ttl,
2437 	LDAPControl		**sctrls,
2438 	LDAPControl		**cctrls,
2439 	int				*msgidp ));
2440 
2441 LDAP_F( int )
2442 ldap_refresh_s LDAP_P((
2443 	LDAP *ld,
2444 	struct berval	*dn,
2445 	ber_int_t ttl,
2446 	ber_int_t *newttl,
2447 	LDAPControl **sctrls,
2448 	LDAPControl **cctrls ));
2449 
2450 /*
2451  * LDAP Transactions
2452  */
2453 LDAP_F( int )
2454 ldap_txn_start LDAP_P(( LDAP *ld,
2455 	LDAPControl		**sctrls,
2456 	LDAPControl		**cctrls,
2457 	int				*msgidp ));
2458 
2459 LDAP_F( int )
2460 ldap_txn_start_s LDAP_P(( LDAP *ld,
2461 	LDAPControl **sctrl,
2462 	LDAPControl **cctrl,
2463 	struct berval **rettxnid ));
2464 
2465 LDAP_F( int )
2466 ldap_txn_end LDAP_P(( LDAP *ld,
2467 	int	commit,
2468 	struct berval	*txnid,
2469 	LDAPControl		**sctrls,
2470 	LDAPControl		**cctrls,
2471 	int				*msgidp ));
2472 
2473 LDAP_F( int )
2474 ldap_txn_end_s LDAP_P(( LDAP *ld,
2475 	int	commit,
2476 	struct berval *txnid,
2477 	LDAPControl **sctrl,
2478 	LDAPControl **cctrl,
2479 	int *retidp ));
2480 
2481 /*
2482  * in ldap_sync.c
2483  */
2484 
2485 /*
2486  * initialize the persistent search structure
2487  */
2488 LDAP_F( ldap_sync_t * )
2489 ldap_sync_initialize LDAP_P((
2490 	ldap_sync_t	*ls ));
2491 
2492 /*
2493  * destroy the persistent search structure
2494  */
2495 LDAP_F( void )
2496 ldap_sync_destroy LDAP_P((
2497 	ldap_sync_t	*ls,
2498 	int		freeit ));
2499 
2500 /*
2501  * initialize a refreshOnly sync
2502  */
2503 LDAP_F( int )
2504 ldap_sync_init LDAP_P((
2505 	ldap_sync_t	*ls,
2506 	int		mode ));
2507 
2508 /*
2509  * initialize a refreshOnly sync
2510  */
2511 LDAP_F( int )
2512 ldap_sync_init_refresh_only LDAP_P((
2513 	ldap_sync_t	*ls ));
2514 
2515 /*
2516  * initialize a refreshAndPersist sync
2517  */
2518 LDAP_F( int )
2519 ldap_sync_init_refresh_and_persist LDAP_P((
2520 	ldap_sync_t	*ls ));
2521 
2522 /*
2523  * poll for new responses
2524  */
2525 LDAP_F( int )
2526 ldap_sync_poll LDAP_P((
2527 	ldap_sync_t	*ls ));
2528 
2529 #ifdef LDAP_CONTROL_X_SESSION_TRACKING
2530 
2531 /*
2532  * in stctrl.c
2533  */
2534 LDAP_F( int )
2535 ldap_create_session_tracking_value LDAP_P((
2536 	LDAP		*ld,
2537 	char		*sessionSourceIp,
2538 	char		*sessionSourceName,
2539 	char		*formatOID,
2540 	struct berval	*sessionTrackingIdentifier,
2541 	struct berval	*value ));
2542 
2543 LDAP_F( int )
2544 ldap_create_session_tracking_control LDAP_P((
2545 	LDAP		*ld,
2546 	char		*sessionSourceIp,
2547 	char		*sessionSourceName,
2548 	char		*formatOID,
2549 	struct berval	*sessionTrackingIdentifier,
2550 	LDAPControl	**ctrlp ));
2551 
2552 LDAP_F( int )
2553 ldap_parse_session_tracking_control LDAP_P((
2554 	LDAP *ld,
2555 	LDAPControl *ctrl,
2556 	struct berval *ip,
2557 	struct berval *name,
2558 	struct berval *oid,
2559 	struct berval *id ));
2560 
2561 #endif /* LDAP_CONTROL_X_SESSION_TRACKING */
2562 
2563 /*
2564  * in msctrl.c
2565  */
2566 #ifdef LDAP_CONTROL_X_DIRSYNC
2567 LDAP_F( int )
2568 ldap_create_dirsync_value LDAP_P((
2569 	LDAP		*ld,
2570 	int		flags,
2571 	int		maxAttrCount,
2572 	struct berval	*cookie,
2573 	struct berval	*value ));
2574 
2575 LDAP_F( int )
2576 ldap_create_dirsync_control LDAP_P((
2577 	LDAP		*ld,
2578 	int		flags,
2579 	int		maxAttrCount,
2580 	struct berval	*cookie,
2581 	LDAPControl	**ctrlp ));
2582 
2583 LDAP_F( int )
2584 ldap_parse_dirsync_control LDAP_P((
2585 	LDAP		*ld,
2586 	LDAPControl	*ctrl,
2587 	int		*continueFlag,
2588 	struct berval	*cookie ));
2589 #endif /* LDAP_CONTROL_X_DIRSYNC */
2590 
2591 #ifdef LDAP_CONTROL_X_EXTENDED_DN
2592 LDAP_F( int )
2593 ldap_create_extended_dn_value LDAP_P((
2594 	LDAP		*ld,
2595 	int		flag,
2596 	struct berval	*value ));
2597 
2598 LDAP_F( int )
2599 ldap_create_extended_dn_control LDAP_P((
2600 	LDAP		*ld,
2601 	int		flag,
2602 	LDAPControl	**ctrlp ));
2603 #endif /* LDAP_CONTROL_X_EXTENDED_DN */
2604 
2605 #ifdef LDAP_CONTROL_X_SHOW_DELETED
2606 LDAP_F( int )
2607 ldap_create_show_deleted_control LDAP_P((
2608 	LDAP		*ld,
2609 	LDAPControl	**ctrlp ));
2610 #endif /* LDAP_CONTROL_X_SHOW_DELETED */
2611 
2612 #ifdef LDAP_CONTROL_X_SERVER_NOTIFICATION
2613 LDAP_F( int )
2614 ldap_create_server_notification_control LDAP_P((
2615 	LDAP		*ld,
2616 	LDAPControl	**ctrlp ));
2617 #endif /* LDAP_CONTROL_X_SERVER_NOTIFICATION */
2618 
2619 /*
2620  * in assertion.c
2621  */
2622 LDAP_F (int)
2623 ldap_create_assertion_control_value LDAP_P((
2624 	LDAP		*ld,
2625 	char		*assertion,
2626 	struct berval	*value ));
2627 
2628 LDAP_F( int )
2629 ldap_create_assertion_control LDAP_P((
2630 	LDAP		*ld,
2631 	char		*filter,
2632 	int		iscritical,
2633 	LDAPControl	**ctrlp ));
2634 
2635 /*
2636  * in deref.c
2637  */
2638 
2639 typedef struct LDAPDerefSpec {
2640 	char *derefAttr;
2641 	char **attributes;
2642 } LDAPDerefSpec;
2643 
2644 typedef struct LDAPDerefVal {
2645 	char *type;
2646 	BerVarray vals;
2647 	struct LDAPDerefVal *next;
2648 } LDAPDerefVal;
2649 
2650 typedef struct LDAPDerefRes {
2651 	char *derefAttr;
2652 	struct berval derefVal;
2653 	LDAPDerefVal *attrVals;
2654 	struct LDAPDerefRes *next;
2655 } LDAPDerefRes;
2656 
2657 LDAP_F( int )
2658 ldap_create_deref_control_value LDAP_P((
2659 	LDAP *ld,
2660 	LDAPDerefSpec *ds,
2661 	struct berval *value ));
2662 
2663 LDAP_F( int )
2664 ldap_create_deref_control LDAP_P((
2665 	LDAP		*ld,
2666 	LDAPDerefSpec	*ds,
2667 	int		iscritical,
2668 	LDAPControl	**ctrlp ));
2669 
2670 LDAP_F( void )
2671 ldap_derefresponse_free LDAP_P((
2672 	LDAPDerefRes *dr ));
2673 
2674 LDAP_F( int )
2675 ldap_parse_derefresponse_control LDAP_P((
2676 	LDAP *ld,
2677 	LDAPControl *ctrl,
2678 	LDAPDerefRes **drp ));
2679 
2680 LDAP_F( int )
2681 ldap_parse_deref_control LDAP_P((
2682 	LDAP		*ld,
2683 	LDAPControl	**ctrls,
2684 	LDAPDerefRes	**drp ));
2685 
2686 /*
2687  * in psearch.c
2688  */
2689 
2690 LDAP_F( int )
2691 ldap_create_persistentsearch_control_value LDAP_P((
2692 	LDAP *ld,
2693 	int changetypes,
2694 	int changesonly,
2695 	int return_echg_ctls,
2696 	struct berval *value ));
2697 
2698 LDAP_F( int )
2699 ldap_create_persistentsearch_control LDAP_P((
2700 	LDAP *ld,
2701 	int changetypes,
2702 	int changesonly,
2703 	int return_echg_ctls,
2704 	int isCritical,
2705 	LDAPControl **ctrlp ));
2706 
2707 LDAP_F( int )
2708 ldap_parse_entrychange_control LDAP_P((
2709 	LDAP *ld,
2710 	LDAPControl *ctrl,
2711 	int *chgtypep,
2712 	struct berval *prevdnp,
2713 	int *chgnumpresentp,
2714 	long *chgnump ));
2715 
2716 /* in account_usability.c */
2717 
2718 LDAP_F( int )
2719 ldap_create_accountusability_control LDAP_P((
2720 	LDAP *ld,
2721 	LDAPControl **ctrlp ));
2722 
2723 typedef struct LDAPAccountUsabilityMoreInfo {
2724 	ber_int_t inactive;
2725 	ber_int_t reset;
2726 	ber_int_t expired;
2727 	ber_int_t remaining_grace;
2728 	ber_int_t seconds_before_unlock;
2729 } LDAPAccountUsabilityMoreInfo;
2730 
2731 typedef union LDAPAccountUsability {
2732 	ber_int_t seconds_remaining;
2733 	LDAPAccountUsabilityMoreInfo more_info;
2734 } LDAPAccountUsability;
2735 
2736 LDAP_F( int )
2737 ldap_parse_accountusability_control LDAP_P((
2738 	LDAP           *ld,
2739 	LDAPControl    *ctrl,
2740 	int            *availablep,
2741 	LDAPAccountUsability *usabilityp ));
2742 
2743 
2744 /*
2745  * high level LDIF to LDAP structure support
2746  */
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 */
2752 
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 */
2760 	union ldif_ops_u {
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 */
2784 	} ldif_ops;
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 */
2795 	int lr_lines;
2796 	LDAPMod	*lr_lm;
2797 	unsigned char *lr_mops;
2798 	char *lr_freeval;
2799 	struct berval *lr_vals;
2800 	struct berval *lr_btype;
2801 } LDIFRecord;
2802 
2803 /* free internal fields - does not free the LDIFRecord */
2804 LDAP_F( void )
2805 ldap_ldif_record_done LDAP_P((
2806 	LDIFRecord *lr ));
2807 
2808 LDAP_F( int )
2809 ldap_parse_ldif_record LDAP_P((
2810 	struct berval *rbuf,
2811 	unsigned long linenum,
2812 	LDIFRecord *lr,
2813 	const char *errstr,
2814 	unsigned int flags ));
2815 
2816 LDAP_END_DECL
2817 #endif /* _LDAP_H */
2818