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