xref: /titanic_54/usr/src/head/ldap.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * Copyright 2001-2003 Sun Microsystems, Inc.  All rights reserved.
3*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
4*7c478bd9Sstevel@tonic-gate  */
5*7c478bd9Sstevel@tonic-gate 
6*7c478bd9Sstevel@tonic-gate /*
7*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the Netscape Public
8*7c478bd9Sstevel@tonic-gate  * License Version 1.1 (the "License"); you may not use this file
9*7c478bd9Sstevel@tonic-gate  * except in compliance with the License. You may obtain a copy of
10*7c478bd9Sstevel@tonic-gate  * the License at http://www.mozilla.org/NPL/
11*7c478bd9Sstevel@tonic-gate  *
12*7c478bd9Sstevel@tonic-gate  * Software distributed under the License is distributed on an "AS
13*7c478bd9Sstevel@tonic-gate  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
14*7c478bd9Sstevel@tonic-gate  * implied. See the License for the specific language governing
15*7c478bd9Sstevel@tonic-gate  * rights and limitations under the License.
16*7c478bd9Sstevel@tonic-gate  *
17*7c478bd9Sstevel@tonic-gate  * The Original Code is Mozilla Communicator client code, released
18*7c478bd9Sstevel@tonic-gate  * March 31, 1998.
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * The Initial Developer of the Original Code is Netscape
21*7c478bd9Sstevel@tonic-gate  * Communications Corporation. Portions created by Netscape are
22*7c478bd9Sstevel@tonic-gate  * Copyright (C) 1998-1999 Netscape Communications Corporation. All
23*7c478bd9Sstevel@tonic-gate  * Rights Reserved.
24*7c478bd9Sstevel@tonic-gate  *
25*7c478bd9Sstevel@tonic-gate  * Contributor(s):
26*7c478bd9Sstevel@tonic-gate  */
27*7c478bd9Sstevel@tonic-gate 
28*7c478bd9Sstevel@tonic-gate #ifndef	_LDAP_H
29*7c478bd9Sstevel@tonic-gate #define	_LDAP_H
30*7c478bd9Sstevel@tonic-gate 
31*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
32*7c478bd9Sstevel@tonic-gate 
33*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
34*7c478bd9Sstevel@tonic-gate extern "C" {
35*7c478bd9Sstevel@tonic-gate #endif
36*7c478bd9Sstevel@tonic-gate 
37*7c478bd9Sstevel@tonic-gate #ifndef	_SOLARIS_SDK
38*7c478bd9Sstevel@tonic-gate #define	_SOLARIS_SDK
39*7c478bd9Sstevel@tonic-gate #endif
40*7c478bd9Sstevel@tonic-gate 
41*7c478bd9Sstevel@tonic-gate #ifndef	LDAP_TYPE_TIMEVAL_DEFINED
42*7c478bd9Sstevel@tonic-gate #include <sys/time.h>
43*7c478bd9Sstevel@tonic-gate #endif
44*7c478bd9Sstevel@tonic-gate #ifndef	LDAP_TYPE_SOCKET_DEFINED	/* API extension */
45*7c478bd9Sstevel@tonic-gate #include <sys/types.h>
46*7c478bd9Sstevel@tonic-gate #include <sys/socket.h>
47*7c478bd9Sstevel@tonic-gate #endif
48*7c478bd9Sstevel@tonic-gate 
49*7c478bd9Sstevel@tonic-gate #include <lber.h>
50*7c478bd9Sstevel@tonic-gate 
51*7c478bd9Sstevel@tonic-gate #define	LDAP_PORT		389
52*7c478bd9Sstevel@tonic-gate #define	LDAPS_PORT		636
53*7c478bd9Sstevel@tonic-gate #define	LDAP_PORT_MAX		65535		/* API extension */
54*7c478bd9Sstevel@tonic-gate #define	LDAP_VERSION1   	1		/* API extension */
55*7c478bd9Sstevel@tonic-gate #define	LDAP_VERSION2   	2
56*7c478bd9Sstevel@tonic-gate #define	LDAP_VERSION3   	3
57*7c478bd9Sstevel@tonic-gate #define	LDAP_VERSION    	LDAP_VERSION2	/* API extension */
58*7c478bd9Sstevel@tonic-gate #define	LDAP_VERSION_MIN	LDAP_VERSION3
59*7c478bd9Sstevel@tonic-gate #define	LDAP_VERSION_MAX	LDAP_VERSION3
60*7c478bd9Sstevel@tonic-gate 
61*7c478bd9Sstevel@tonic-gate #define	LDAP_VENDOR_VERSION	500	/* version # * 100 */
62*7c478bd9Sstevel@tonic-gate #define	LDAP_VENDOR_NAME	"Sun Microsystems Inc."
63*7c478bd9Sstevel@tonic-gate /*
64*7c478bd9Sstevel@tonic-gate  * The following will be an RFC number once the LDAP C API Internet Draft
65*7c478bd9Sstevel@tonic-gate  * is published as a Proposed Standard RFC.  For now we use 2000 + the
66*7c478bd9Sstevel@tonic-gate  * draft revision number (currently 5) since we are close to compliance
67*7c478bd9Sstevel@tonic-gate  * with revision 5 of the draft.
68*7c478bd9Sstevel@tonic-gate  */
69*7c478bd9Sstevel@tonic-gate #define	LDAP_API_VERSION	2005
70*7c478bd9Sstevel@tonic-gate 
71*7c478bd9Sstevel@tonic-gate /*
72*7c478bd9Sstevel@tonic-gate  * C LDAP features we support that are not (yet) part of the LDAP C API
73*7c478bd9Sstevel@tonic-gate  * Internet Draft.  Use the ldap_get_option() call with an option value of
74*7c478bd9Sstevel@tonic-gate  * LDAP_OPT_API_FEATURE_INFO to retrieve information about a feature.
75*7c478bd9Sstevel@tonic-gate  *
76*7c478bd9Sstevel@tonic-gate  * Note that this list is incomplete; it includes only the most widely
77*7c478bd9Sstevel@tonic-gate  * used extensions.  Also, the version is 1 for all of these for now.
78*7c478bd9Sstevel@tonic-gate  */
79*7c478bd9Sstevel@tonic-gate #define	LDAP_API_FEATURE_SERVER_SIDE_SORT	1
80*7c478bd9Sstevel@tonic-gate #define	LDAP_API_FEATURE_VIRTUAL_LIST_VIEW	1
81*7c478bd9Sstevel@tonic-gate #define	LDAP_API_FEATURE_PERSISTENT_SEARCH	1
82*7c478bd9Sstevel@tonic-gate #define	LDAP_API_FEATURE_PROXY_AUTHORIZATION	1
83*7c478bd9Sstevel@tonic-gate #define	LDAP_API_FEATURE_X_LDERRNO		1
84*7c478bd9Sstevel@tonic-gate #define	LDAP_API_FEATURE_X_MEMCACHE		1
85*7c478bd9Sstevel@tonic-gate #define	LDAP_API_FEATURE_X_IO_FUNCTIONS		1
86*7c478bd9Sstevel@tonic-gate #define	LDAP_API_FEATURE_X_EXTIO_FUNCTIONS	1
87*7c478bd9Sstevel@tonic-gate #define	LDAP_API_FEATURE_X_DNS_FUNCTIONS	1
88*7c478bd9Sstevel@tonic-gate #define	LDAP_API_FEATURE_X_MEMALLOC_FUNCTIONS	1
89*7c478bd9Sstevel@tonic-gate #define	LDAP_API_FEATURE_X_THREAD_FUNCTIONS	1
90*7c478bd9Sstevel@tonic-gate #define	LDAP_API_FEATURE_X_EXTHREAD_FUNCTIONS	1
91*7c478bd9Sstevel@tonic-gate #define	LDAP_API_FEATURE_X_GETLANGVALUES	1
92*7c478bd9Sstevel@tonic-gate #define	LDAP_API_FEATURE_X_CLIENT_SIDE_SORT	1
93*7c478bd9Sstevel@tonic-gate #define	LDAP_API_FEATURE_X_URL_FUNCTIONS	1
94*7c478bd9Sstevel@tonic-gate #define	LDAP_API_FEATURE_X_FILTER_FUNCTIONS	1
95*7c478bd9Sstevel@tonic-gate 
96*7c478bd9Sstevel@tonic-gate #define	LDAP_ROOT_DSE		""		/* API extension */
97*7c478bd9Sstevel@tonic-gate #define	LDAP_NO_ATTRS		"1.1"
98*7c478bd9Sstevel@tonic-gate #define	LDAP_ALL_USER_ATTRS	"*"
99*7c478bd9Sstevel@tonic-gate 
100*7c478bd9Sstevel@tonic-gate /*
101*7c478bd9Sstevel@tonic-gate  * Standard options (used with ldap_set_option() and ldap_get_option):
102*7c478bd9Sstevel@tonic-gate  */
103*7c478bd9Sstevel@tonic-gate #define	LDAP_OPT_API_INFO		0x00	/*  0 */
104*7c478bd9Sstevel@tonic-gate #define	LDAP_OPT_DESC			0x01	/*  1 */
105*7c478bd9Sstevel@tonic-gate #define	LDAP_OPT_DEREF			0x02	/*  2 */
106*7c478bd9Sstevel@tonic-gate #define	LDAP_OPT_SIZELIMIT		0x03	/*  3 */
107*7c478bd9Sstevel@tonic-gate #define	LDAP_OPT_TIMELIMIT		0x04	/*  4 */
108*7c478bd9Sstevel@tonic-gate #define	LDAP_OPT_REFERRALS		0x08	/*  8 */
109*7c478bd9Sstevel@tonic-gate #define	LDAP_OPT_RESTART		0x09	/*  9 */
110*7c478bd9Sstevel@tonic-gate #define	LDAP_OPT_PROTOCOL_VERSION	0x11	/* 17 */
111*7c478bd9Sstevel@tonic-gate #define	LDAP_OPT_SERVER_CONTROLS	0x12	/* 18 */
112*7c478bd9Sstevel@tonic-gate #define	LDAP_OPT_CLIENT_CONTROLS	0x13	/* 19 */
113*7c478bd9Sstevel@tonic-gate #define	LDAP_OPT_API_FEATURE_INFO	0x15	/* 21 */
114*7c478bd9Sstevel@tonic-gate #define	LDAP_OPT_HOST_NAME		0x30	/* 48 */
115*7c478bd9Sstevel@tonic-gate #define	LDAP_OPT_ERROR_NUMBER		0x31	/* 49 */
116*7c478bd9Sstevel@tonic-gate #define	LDAP_OPT_ERROR_STRING		0x32	/* 50 */
117*7c478bd9Sstevel@tonic-gate #define	LDAP_OPT_MATCHED_DN		0x33	/* 51 */
118*7c478bd9Sstevel@tonic-gate 
119*7c478bd9Sstevel@tonic-gate /*
120*7c478bd9Sstevel@tonic-gate  * Well-behaved private and experimental extensions will use option values
121*7c478bd9Sstevel@tonic-gate  * between 0x4000 (16384) and 0x7FFF (32767) inclusive.
122*7c478bd9Sstevel@tonic-gate  */
123*7c478bd9Sstevel@tonic-gate #define	LDAP_OPT_PRIVATE_EXTENSION_BASE	0x4000	/* to 0x7FFF inclusive */
124*7c478bd9Sstevel@tonic-gate /*
125*7c478bd9Sstevel@tonic-gate  * Special timeout values for poll and connect:
126*7c478bd9Sstevel@tonic-gate  */
127*7c478bd9Sstevel@tonic-gate #define	LDAP_X_IO_TIMEOUT_NO_WAIT	0	/* return immediately */
128*7c478bd9Sstevel@tonic-gate #define	LDAP_X_IO_TIMEOUT_NO_TIMEOUT    (-1)    /* block indefinitely */
129*7c478bd9Sstevel@tonic-gate /*
130*7c478bd9Sstevel@tonic-gate  * Timeout value for nonblocking connect call
131*7c478bd9Sstevel@tonic-gate  */
132*7c478bd9Sstevel@tonic-gate #define	LDAP_X_OPT_CONNECT_TIMEOUT    (LDAP_OPT_PRIVATE_EXTENSION_BASE + 0x0F01)
133*7c478bd9Sstevel@tonic-gate 	/* 0x4000 + 0x0F01 = 0x4F01 = 20225 - API extension */
134*7c478bd9Sstevel@tonic-gate 
135*7c478bd9Sstevel@tonic-gate /* for on/off options */
136*7c478bd9Sstevel@tonic-gate #define	LDAP_OPT_ON	((void *)1)
137*7c478bd9Sstevel@tonic-gate #define	LDAP_OPT_OFF	((void *)0)
138*7c478bd9Sstevel@tonic-gate 
139*7c478bd9Sstevel@tonic-gate typedef struct ldap	LDAP;		/* opaque connection handle */
140*7c478bd9Sstevel@tonic-gate typedef struct ldapmsg  LDAPMessage;    /* opaque result/entry handle */
141*7c478bd9Sstevel@tonic-gate 
142*7c478bd9Sstevel@tonic-gate #define	NULLMSG ((LDAPMessage *)0)
143*7c478bd9Sstevel@tonic-gate 
144*7c478bd9Sstevel@tonic-gate /* structure representing an LDAP modification */
145*7c478bd9Sstevel@tonic-gate typedef struct ldapmod {
146*7c478bd9Sstevel@tonic-gate 	int		mod_op;		/* kind of mod + form of values */
147*7c478bd9Sstevel@tonic-gate #define	LDAP_MOD_ADD		0x00
148*7c478bd9Sstevel@tonic-gate #define	LDAP_MOD_DELETE		0x01
149*7c478bd9Sstevel@tonic-gate #define	LDAP_MOD_REPLACE	0x02
150*7c478bd9Sstevel@tonic-gate #define	LDAP_MOD_BVALUES	0x80
151*7c478bd9Sstevel@tonic-gate 	char			*mod_type;	/* attribute name to modify */
152*7c478bd9Sstevel@tonic-gate 	union mod_vals_u {
153*7c478bd9Sstevel@tonic-gate 		char		**modv_strvals;
154*7c478bd9Sstevel@tonic-gate 		struct berval   **modv_bvals;
155*7c478bd9Sstevel@tonic-gate 	} mod_vals;		/* values to add/delete/replace */
156*7c478bd9Sstevel@tonic-gate #define	mod_values	mod_vals.modv_strvals
157*7c478bd9Sstevel@tonic-gate #define	mod_bvalues	mod_vals.modv_bvals
158*7c478bd9Sstevel@tonic-gate } LDAPMod;
159*7c478bd9Sstevel@tonic-gate 
160*7c478bd9Sstevel@tonic-gate 
161*7c478bd9Sstevel@tonic-gate /*
162*7c478bd9Sstevel@tonic-gate  * structure for holding ldapv3 controls
163*7c478bd9Sstevel@tonic-gate  */
164*7c478bd9Sstevel@tonic-gate typedef struct ldapcontrol {
165*7c478bd9Sstevel@tonic-gate     char		*ldctl_oid;
166*7c478bd9Sstevel@tonic-gate     struct berval	ldctl_value;
167*7c478bd9Sstevel@tonic-gate     char		ldctl_iscritical;
168*7c478bd9Sstevel@tonic-gate } LDAPControl;
169*7c478bd9Sstevel@tonic-gate 
170*7c478bd9Sstevel@tonic-gate 
171*7c478bd9Sstevel@tonic-gate /*
172*7c478bd9Sstevel@tonic-gate  * LDAP API information.  Can be retrieved by using a sequence like:
173*7c478bd9Sstevel@tonic-gate  *
174*7c478bd9Sstevel@tonic-gate  *    LDAPAPIInfo ldai;
175*7c478bd9Sstevel@tonic-gate  *    ldai.ldapai_info_version = LDAP_API_INFO_VERSION;
176*7c478bd9Sstevel@tonic-gate  *    if ( ldap_get_option( NULL, LDAP_OPT_API_INFO, &ldia ) == 0 ) ...
177*7c478bd9Sstevel@tonic-gate  */
178*7c478bd9Sstevel@tonic-gate #define	LDAP_API_INFO_VERSION		1
179*7c478bd9Sstevel@tonic-gate typedef struct ldapapiinfo {
180*7c478bd9Sstevel@tonic-gate     int	 ldapai_info_version;	  /* version of this struct (1) */
181*7c478bd9Sstevel@tonic-gate     int	ldapai_api_version;	/* revision of API supported */
182*7c478bd9Sstevel@tonic-gate     int  ldapai_protocol_version; /* highest LDAP version supported */
183*7c478bd9Sstevel@tonic-gate     char **ldapai_extensions;	/* names of API extensions */
184*7c478bd9Sstevel@tonic-gate     char *ldapai_vendor_name;	/* name of supplier */
185*7c478bd9Sstevel@tonic-gate     int  ldapai_vendor_version;   /* supplier-specific version times 100 */
186*7c478bd9Sstevel@tonic-gate } LDAPAPIInfo;
187*7c478bd9Sstevel@tonic-gate 
188*7c478bd9Sstevel@tonic-gate 
189*7c478bd9Sstevel@tonic-gate /*
190*7c478bd9Sstevel@tonic-gate  * LDAP API extended features info.  Can be retrieved by using a sequence like:
191*7c478bd9Sstevel@tonic-gate  *
192*7c478bd9Sstevel@tonic-gate  *    LDAPAPIFeatureInfo ldfi;
193*7c478bd9Sstevel@tonic-gate  *    ldfi.ldapaif_info_version = LDAP_FEATURE_INFO_VERSION;
194*7c478bd9Sstevel@tonic-gate  *    ldfi.ldapaif_name = "VIRTUAL_LIST_VIEW";
195*7c478bd9Sstevel@tonic-gate  *    if ( ldap_get_option( NULL, LDAP_OPT_API_FEATURE_INFO, &ldfi ) == 0 ) ...
196*7c478bd9Sstevel@tonic-gate  */
197*7c478bd9Sstevel@tonic-gate #define	LDAP_FEATURE_INFO_VERSION	1
198*7c478bd9Sstevel@tonic-gate typedef struct ldap_apifeature_info {
199*7c478bd9Sstevel@tonic-gate     int   ldapaif_info_version;	/* version of this struct (1) */
200*7c478bd9Sstevel@tonic-gate     char  *ldapaif_name;	/* name of supported feature */
201*7c478bd9Sstevel@tonic-gate     int   ldapaif_version;	/* revision of supported feature */
202*7c478bd9Sstevel@tonic-gate } LDAPAPIFeatureInfo;
203*7c478bd9Sstevel@tonic-gate 
204*7c478bd9Sstevel@tonic-gate 
205*7c478bd9Sstevel@tonic-gate /* possible result types a server can return */
206*7c478bd9Sstevel@tonic-gate #define	LDAP_RES_BIND			0x61	/* 97 */
207*7c478bd9Sstevel@tonic-gate #define	LDAP_RES_SEARCH_ENTRY		0x64	/* 100 */
208*7c478bd9Sstevel@tonic-gate #define	LDAP_RES_SEARCH_RESULT		0x65	/* 101 */
209*7c478bd9Sstevel@tonic-gate #define	LDAP_RES_MODIFY			0x67	/* 103 */
210*7c478bd9Sstevel@tonic-gate #define	LDAP_RES_ADD			0x69	/* 105 */
211*7c478bd9Sstevel@tonic-gate #define	LDAP_RES_DELETE			0x6b	/* 107 */
212*7c478bd9Sstevel@tonic-gate #define	LDAP_RES_MODDN			0x6d	/* 109 */
213*7c478bd9Sstevel@tonic-gate #define	LDAP_RES_COMPARE		0x6f	/* 111 */
214*7c478bd9Sstevel@tonic-gate #define	LDAP_RES_SEARCH_REFERENCE	0x73	/* 115 */
215*7c478bd9Sstevel@tonic-gate #define	LDAP_RES_EXTENDED		0x78	/* 120 */
216*7c478bd9Sstevel@tonic-gate 
217*7c478bd9Sstevel@tonic-gate /* Special values for ldap_result() "msgid" parameter */
218*7c478bd9Sstevel@tonic-gate #define	LDAP_RES_ANY			(-1)
219*7c478bd9Sstevel@tonic-gate #define	LDAP_RES_UNSOLICITED		0
220*7c478bd9Sstevel@tonic-gate 
221*7c478bd9Sstevel@tonic-gate /* built-in SASL methods */
222*7c478bd9Sstevel@tonic-gate #define	LDAP_SASL_SIMPLE	0	/* special value used for simple bind */
223*7c478bd9Sstevel@tonic-gate #define	LDAP_SASL_EXTERNAL	"EXTERNAL"	/* TLS/SSL extension */
224*7c478bd9Sstevel@tonic-gate 
225*7c478bd9Sstevel@tonic-gate #ifdef	_SOLARIS_SDK
226*7c478bd9Sstevel@tonic-gate #define	LDAP_SASL_CRAM_MD5	"CRAM-MD5"
227*7c478bd9Sstevel@tonic-gate #define	LDAP_SASL_DIGEST_MD5 	"DIGEST-MD5"
228*7c478bd9Sstevel@tonic-gate #define	LDAP_SASL_BIND_INPROGRESS	0x0e    /* for backward compatibility */
229*7c478bd9Sstevel@tonic-gate #endif
230*7c478bd9Sstevel@tonic-gate 
231*7c478bd9Sstevel@tonic-gate /* search scopes */
232*7c478bd9Sstevel@tonic-gate #define	LDAP_SCOPE_BASE		0x00
233*7c478bd9Sstevel@tonic-gate #define	LDAP_SCOPE_ONELEVEL	0x01
234*7c478bd9Sstevel@tonic-gate #define	LDAP_SCOPE_SUBTREE	0x02
235*7c478bd9Sstevel@tonic-gate 
236*7c478bd9Sstevel@tonic-gate /* alias dereferencing */
237*7c478bd9Sstevel@tonic-gate #define	LDAP_DEREF_NEVER	0
238*7c478bd9Sstevel@tonic-gate #define	LDAP_DEREF_SEARCHING	1
239*7c478bd9Sstevel@tonic-gate #define	LDAP_DEREF_FINDING	2
240*7c478bd9Sstevel@tonic-gate #define	LDAP_DEREF_ALWAYS	3
241*7c478bd9Sstevel@tonic-gate 
242*7c478bd9Sstevel@tonic-gate /* predefined size/time limits */
243*7c478bd9Sstevel@tonic-gate #define	LDAP_NO_LIMIT		0
244*7c478bd9Sstevel@tonic-gate 
245*7c478bd9Sstevel@tonic-gate /* allowed values for "all" ldap_result() parameter */
246*7c478bd9Sstevel@tonic-gate #define	LDAP_MSG_ONE		0
247*7c478bd9Sstevel@tonic-gate #define	LDAP_MSG_ALL		1
248*7c478bd9Sstevel@tonic-gate #define	LDAP_MSG_RECEIVED	2
249*7c478bd9Sstevel@tonic-gate 
250*7c478bd9Sstevel@tonic-gate /* possible error codes we can be returned */
251*7c478bd9Sstevel@tonic-gate #define	LDAP_SUCCESS			0x00	/* 0 */
252*7c478bd9Sstevel@tonic-gate #define	LDAP_OPERATIONS_ERROR		0x01	/* 1 */
253*7c478bd9Sstevel@tonic-gate #define	LDAP_PROTOCOL_ERROR		0x02	/* 2 */
254*7c478bd9Sstevel@tonic-gate #define	LDAP_TIMELIMIT_EXCEEDED		0x03	/* 3 */
255*7c478bd9Sstevel@tonic-gate #define	LDAP_SIZELIMIT_EXCEEDED		0x04	/* 4 */
256*7c478bd9Sstevel@tonic-gate #define	LDAP_COMPARE_FALSE		0x05	/* 5 */
257*7c478bd9Sstevel@tonic-gate #define	LDAP_COMPARE_TRUE		0x06	/* 6 */
258*7c478bd9Sstevel@tonic-gate #define	LDAP_STRONG_AUTH_NOT_SUPPORTED	0x07	/* 7 */
259*7c478bd9Sstevel@tonic-gate #define	LDAP_STRONG_AUTH_REQUIRED	0x08	/* 8 */
260*7c478bd9Sstevel@tonic-gate #define	LDAP_PARTIAL_RESULTS		0x09	/* 9 (UMich LDAPv2 extn) */
261*7c478bd9Sstevel@tonic-gate #define	LDAP_REFERRAL			0x0a	/* 10 - LDAPv3 */
262*7c478bd9Sstevel@tonic-gate #define	LDAP_ADMINLIMIT_EXCEEDED	0x0b	/* 11 - LDAPv3 */
263*7c478bd9Sstevel@tonic-gate #define	LDAP_UNAVAILABLE_CRITICAL_EXTENSION  0x0c /* 12 - LDAPv3 */
264*7c478bd9Sstevel@tonic-gate #define	LDAP_CONFIDENTIALITY_REQUIRED	0x0d	/* 13 */
265*7c478bd9Sstevel@tonic-gate #define	LDAP_SASL_BIND_IN_PROGRESS	0x0e	/* 14 - LDAPv3 */
266*7c478bd9Sstevel@tonic-gate 
267*7c478bd9Sstevel@tonic-gate #define	LDAP_NO_SUCH_ATTRIBUTE		0x10	/* 16 */
268*7c478bd9Sstevel@tonic-gate #define	LDAP_UNDEFINED_TYPE		0x11	/* 17 */
269*7c478bd9Sstevel@tonic-gate #define	LDAP_INAPPROPRIATE_MATCHING	0x12	/* 18 */
270*7c478bd9Sstevel@tonic-gate #define	LDAP_CONSTRAINT_VIOLATION	0x13	/* 19 */
271*7c478bd9Sstevel@tonic-gate #define	LDAP_TYPE_OR_VALUE_EXISTS	0x14	/* 20 */
272*7c478bd9Sstevel@tonic-gate #define	LDAP_INVALID_SYNTAX		0x15	/* 21 */
273*7c478bd9Sstevel@tonic-gate 
274*7c478bd9Sstevel@tonic-gate #define	LDAP_NO_SUCH_OBJECT		0x20	/* 32 */
275*7c478bd9Sstevel@tonic-gate #define	LDAP_ALIAS_PROBLEM		0x21	/* 33 */
276*7c478bd9Sstevel@tonic-gate #define	LDAP_INVALID_DN_SYNTAX		0x22	/* 34 */
277*7c478bd9Sstevel@tonic-gate #define	LDAP_IS_LEAF			0x23	/* 35 (not used in LDAPv3) */
278*7c478bd9Sstevel@tonic-gate #define	LDAP_ALIAS_DEREF_PROBLEM	0x24	/* 36 */
279*7c478bd9Sstevel@tonic-gate 
280*7c478bd9Sstevel@tonic-gate #define	NAME_ERROR(n)   ((n & 0xf0) == 0x20)
281*7c478bd9Sstevel@tonic-gate 
282*7c478bd9Sstevel@tonic-gate #define	LDAP_INAPPROPRIATE_AUTH		0x30	/* 48 */
283*7c478bd9Sstevel@tonic-gate #define	LDAP_INVALID_CREDENTIALS	0x31	/* 49 */
284*7c478bd9Sstevel@tonic-gate #define	LDAP_INSUFFICIENT_ACCESS	0x32	/* 50 */
285*7c478bd9Sstevel@tonic-gate #define	LDAP_BUSY			0x33	/* 51 */
286*7c478bd9Sstevel@tonic-gate #define	LDAP_UNAVAILABLE		0x34	/* 52 */
287*7c478bd9Sstevel@tonic-gate #define	LDAP_UNWILLING_TO_PERFORM	0x35	/* 53 */
288*7c478bd9Sstevel@tonic-gate #define	LDAP_LOOP_DETECT		0x36	/* 54 */
289*7c478bd9Sstevel@tonic-gate 
290*7c478bd9Sstevel@tonic-gate #define	LDAP_SORT_CONTROL_MISSING	0x3C	/* 60 (server side sort extn) */
291*7c478bd9Sstevel@tonic-gate #define	LDAP_INDEX_RANGE_ERROR		0x3D    /* 61 (VLV extn) */
292*7c478bd9Sstevel@tonic-gate 
293*7c478bd9Sstevel@tonic-gate #define	LDAP_NAMING_VIOLATION		0x40	/* 64 */
294*7c478bd9Sstevel@tonic-gate #define	LDAP_OBJECT_CLASS_VIOLATION	0x41	/* 65 */
295*7c478bd9Sstevel@tonic-gate #define	LDAP_NOT_ALLOWED_ON_NONLEAF	0x42	/* 66 */
296*7c478bd9Sstevel@tonic-gate #define	LDAP_NOT_ALLOWED_ON_RDN		0x43	/* 67 */
297*7c478bd9Sstevel@tonic-gate #define	LDAP_ALREADY_EXISTS		0x44	/* 68 */
298*7c478bd9Sstevel@tonic-gate #define	LDAP_NO_OBJECT_CLASS_MODS	0x45	/* 69 */
299*7c478bd9Sstevel@tonic-gate #define	LDAP_RESULTS_TOO_LARGE		0x46	/* 70 - CLDAP */
300*7c478bd9Sstevel@tonic-gate #define	LDAP_AFFECTS_MULTIPLE_DSAS	0x47	/* 71 */
301*7c478bd9Sstevel@tonic-gate 
302*7c478bd9Sstevel@tonic-gate #define	LDAP_OTHER			0x50	/* 80 */
303*7c478bd9Sstevel@tonic-gate #define	LDAP_SERVER_DOWN		0x51	/* 81 */
304*7c478bd9Sstevel@tonic-gate #define	LDAP_LOCAL_ERROR		0x52	/* 82 */
305*7c478bd9Sstevel@tonic-gate #define	LDAP_ENCODING_ERROR		0x53	/* 83 */
306*7c478bd9Sstevel@tonic-gate #define	LDAP_DECODING_ERROR		0x54	/* 84 */
307*7c478bd9Sstevel@tonic-gate #define	LDAP_TIMEOUT			0x55	/* 85 */
308*7c478bd9Sstevel@tonic-gate #define	LDAP_AUTH_UNKNOWN		0x56	/* 86 */
309*7c478bd9Sstevel@tonic-gate #define	LDAP_FILTER_ERROR		0x57	/* 87 */
310*7c478bd9Sstevel@tonic-gate #define	LDAP_USER_CANCELLED		0x58	/* 88 */
311*7c478bd9Sstevel@tonic-gate #define	LDAP_PARAM_ERROR		0x59	/* 89 */
312*7c478bd9Sstevel@tonic-gate #define	LDAP_NO_MEMORY			0x5a	/* 90 */
313*7c478bd9Sstevel@tonic-gate #define	LDAP_CONNECT_ERROR		0x5b	/* 91 */
314*7c478bd9Sstevel@tonic-gate #define	LDAP_NOT_SUPPORTED		0x5c	/* 92 - LDAPv3 */
315*7c478bd9Sstevel@tonic-gate #define	LDAP_CONTROL_NOT_FOUND		0x5d	/* 93 - LDAPv3 */
316*7c478bd9Sstevel@tonic-gate #define	LDAP_NO_RESULTS_RETURNED	0x5e	/* 94 - LDAPv3 */
317*7c478bd9Sstevel@tonic-gate #define	LDAP_MORE_RESULTS_TO_RETURN	0x5f	/* 95 - LDAPv3 */
318*7c478bd9Sstevel@tonic-gate #define	LDAP_CLIENT_LOOP		0x60	/* 96 - LDAPv3 */
319*7c478bd9Sstevel@tonic-gate #define	LDAP_REFERRAL_LIMIT_EXCEEDED	0x61	/* 97 - LDAPv3 */
320*7c478bd9Sstevel@tonic-gate 
321*7c478bd9Sstevel@tonic-gate /*
322*7c478bd9Sstevel@tonic-gate  * LDAPv3 unsolicited notification messages we know about
323*7c478bd9Sstevel@tonic-gate  */
324*7c478bd9Sstevel@tonic-gate #define	LDAP_NOTICE_OF_DISCONNECTION	"1.3.6.1.4.1.1466.20036"
325*7c478bd9Sstevel@tonic-gate 
326*7c478bd9Sstevel@tonic-gate /*
327*7c478bd9Sstevel@tonic-gate  * LDAPv3 server controls we know about
328*7c478bd9Sstevel@tonic-gate  */
329*7c478bd9Sstevel@tonic-gate #define	LDAP_CONTROL_MANAGEDSAIT	"2.16.840.1.113730.3.4.2"
330*7c478bd9Sstevel@tonic-gate #define	LDAP_CONTROL_SORTREQUEST	"1.2.840.113556.1.4.473"
331*7c478bd9Sstevel@tonic-gate #define	LDAP_CONTROL_SORTRESPONSE	"1.2.840.113556.1.4.474"
332*7c478bd9Sstevel@tonic-gate #define	LDAP_CONTROL_PERSISTENTSEARCH	"2.16.840.1.113730.3.4.3"
333*7c478bd9Sstevel@tonic-gate #define	LDAP_CONTROL_ENTRYCHANGE	"2.16.840.1.113730.3.4.7"
334*7c478bd9Sstevel@tonic-gate #define	LDAP_CONTROL_VLVREQUEST    	"2.16.840.1.113730.3.4.9"
335*7c478bd9Sstevel@tonic-gate #define	LDAP_CONTROL_VLVRESPONSE	"2.16.840.1.113730.3.4.10"
336*7c478bd9Sstevel@tonic-gate #define	LDAP_CONTROL_PROXYAUTH		"2.16.840.1.113730.3.4.12"
337*7c478bd9Sstevel@tonic-gate 	/* version 1 */
338*7c478bd9Sstevel@tonic-gate #define	LDAP_CONTROL_PROXIEDAUTH	"2.16.840.1.113730.3.4.18"
339*7c478bd9Sstevel@tonic-gate 	/* version 2 */
340*7c478bd9Sstevel@tonic-gate 
341*7c478bd9Sstevel@tonic-gate #ifdef	_SOLARIS_SDK
342*7c478bd9Sstevel@tonic-gate /*
343*7c478bd9Sstevel@tonic-gate  * Simple Page control OID
344*7c478bd9Sstevel@tonic-gate  */
345*7c478bd9Sstevel@tonic-gate #define	LDAP_CONTROL_SIMPLE_PAGE	"1.2.840.113556.1.4.319"
346*7c478bd9Sstevel@tonic-gate 
347*7c478bd9Sstevel@tonic-gate /*
348*7c478bd9Sstevel@tonic-gate  * Begin LDAP Display Template Definitions
349*7c478bd9Sstevel@tonic-gate  */
350*7c478bd9Sstevel@tonic-gate #define	LDAP_TEMPLATE_VERSION   1
351*7c478bd9Sstevel@tonic-gate 
352*7c478bd9Sstevel@tonic-gate /*
353*7c478bd9Sstevel@tonic-gate  * general types of items (confined to most significant byte)
354*7c478bd9Sstevel@tonic-gate  */
355*7c478bd9Sstevel@tonic-gate #define	LDAP_SYN_TYPE_TEXT		0x01000000L
356*7c478bd9Sstevel@tonic-gate #define	LDAP_SYN_TYPE_IMAGE		0x02000000L
357*7c478bd9Sstevel@tonic-gate #define	LDAP_SYN_TYPE_BOOLEAN		0x04000000L
358*7c478bd9Sstevel@tonic-gate #define	LDAP_SYN_TYPE_BUTTON		0x08000000L
359*7c478bd9Sstevel@tonic-gate #define	LDAP_SYN_TYPE_ACTION		0x10000000L
360*7c478bd9Sstevel@tonic-gate 
361*7c478bd9Sstevel@tonic-gate /*
362*7c478bd9Sstevel@tonic-gate  * syntax options (confined to second most significant byte)
363*7c478bd9Sstevel@tonic-gate  */
364*7c478bd9Sstevel@tonic-gate #define	LDAP_SYN_OPT_DEFER		0x00010000L
365*7c478bd9Sstevel@tonic-gate 
366*7c478bd9Sstevel@tonic-gate /*
367*7c478bd9Sstevel@tonic-gate  * display template item syntax ids (defined by common agreement)
368*7c478bd9Sstevel@tonic-gate  * these are the valid values for the ti_syntaxid of the tmplitem
369*7c478bd9Sstevel@tonic-gate  * struct (defined below).  A general type is encoded in the
370*7c478bd9Sstevel@tonic-gate  * most-significant 8 bits, and some options are encoded in the next
371*7c478bd9Sstevel@tonic-gate  * 8 bits.  The lower 16 bits are reserved for the distinct types.
372*7c478bd9Sstevel@tonic-gate  */
373*7c478bd9Sstevel@tonic-gate #define	LDAP_SYN_CASEIGNORESTR  (1 | LDAP_SYN_TYPE_TEXT)
374*7c478bd9Sstevel@tonic-gate #define	LDAP_SYN_MULTILINESTR   (2 | LDAP_SYN_TYPE_TEXT)
375*7c478bd9Sstevel@tonic-gate #define	LDAP_SYN_DN		(3 | LDAP_SYN_TYPE_TEXT)
376*7c478bd9Sstevel@tonic-gate #define	LDAP_SYN_BOOLEAN	(4 | LDAP_SYN_TYPE_BOOLEAN)
377*7c478bd9Sstevel@tonic-gate #define	LDAP_SYN_JPEGIMAGE	(5 | LDAP_SYN_TYPE_IMAGE)
378*7c478bd9Sstevel@tonic-gate #define	LDAP_SYN_JPEGBUTTON	(6 | LDAP_SYN_TYPE_BUTTON | LDAP_SYN_OPT_DEFER)
379*7c478bd9Sstevel@tonic-gate #define	LDAP_SYN_FAXIMAGE	(7 | LDAP_SYN_TYPE_IMAGE)
380*7c478bd9Sstevel@tonic-gate #define	LDAP_SYN_FAXBUTTON	(8 | LDAP_SYN_TYPE_BUTTON | LDAP_SYN_OPT_DEFER)
381*7c478bd9Sstevel@tonic-gate #define	LDAP_SYN_AUDIOBUTTON	(9 | LDAP_SYN_TYPE_BUTTON | LDAP_SYN_OPT_DEFER)
382*7c478bd9Sstevel@tonic-gate #define	LDAP_SYN_TIME		(10 | LDAP_SYN_TYPE_TEXT)
383*7c478bd9Sstevel@tonic-gate #define	LDAP_SYN_DATE		(11 | LDAP_SYN_TYPE_TEXT)
384*7c478bd9Sstevel@tonic-gate #define	LDAP_SYN_LABELEDURL	(12 | LDAP_SYN_TYPE_TEXT)
385*7c478bd9Sstevel@tonic-gate #define	LDAP_SYN_SEARCHACTION	(13 | LDAP_SYN_TYPE_ACTION)
386*7c478bd9Sstevel@tonic-gate #define	LDAP_SYN_LINKACTION	(14 | LDAP_SYN_TYPE_ACTION)
387*7c478bd9Sstevel@tonic-gate #define	LDAP_SYN_ADDDNACTION	(15 | LDAP_SYN_TYPE_ACTION)
388*7c478bd9Sstevel@tonic-gate #define	LDAP_SYN_VERIFYDNACTION	(16 | LDAP_SYN_TYPE_ACTION)
389*7c478bd9Sstevel@tonic-gate #define	LDAP_SYN_RFC822ADDR	(17 | LDAP_SYN_TYPE_TEXT)
390*7c478bd9Sstevel@tonic-gate 
391*7c478bd9Sstevel@tonic-gate /*
392*7c478bd9Sstevel@tonic-gate  * handy macros
393*7c478bd9Sstevel@tonic-gate  */
394*7c478bd9Sstevel@tonic-gate #define	LDAP_GET_SYN_TYPE(syid)		((syid) & 0xFF000000UL)
395*7c478bd9Sstevel@tonic-gate #define	LDAP_GET_SYN_OPTIONS(syid)	((syid) & 0x00FF0000UL)
396*7c478bd9Sstevel@tonic-gate 
397*7c478bd9Sstevel@tonic-gate 
398*7c478bd9Sstevel@tonic-gate /*
399*7c478bd9Sstevel@tonic-gate  * display options for output routines (used by entry2text and friends)
400*7c478bd9Sstevel@tonic-gate  */
401*7c478bd9Sstevel@tonic-gate /*
402*7c478bd9Sstevel@tonic-gate  * use calculated label width (based on length of longest label in
403*7c478bd9Sstevel@tonic-gate  * template) instead of contant width
404*7c478bd9Sstevel@tonic-gate  */
405*7c478bd9Sstevel@tonic-gate #define	LDAP_DISP_OPT_AUTOLABELWIDTH    0x00000001L
406*7c478bd9Sstevel@tonic-gate #define	LDAP_DISP_OPT_HTMLBODYONLY	0x00000002L
407*7c478bd9Sstevel@tonic-gate 
408*7c478bd9Sstevel@tonic-gate /*
409*7c478bd9Sstevel@tonic-gate  * perform search actions (applies to ldap_entry2text_search only)
410*7c478bd9Sstevel@tonic-gate  */
411*7c478bd9Sstevel@tonic-gate #define	LDAP_DISP_OPT_DOSEARCHACTIONS   0x00000002L
412*7c478bd9Sstevel@tonic-gate 
413*7c478bd9Sstevel@tonic-gate /*
414*7c478bd9Sstevel@tonic-gate  * include additional info. relevant to "non leaf" entries only
415*7c478bd9Sstevel@tonic-gate  * used by ldap_entry2html and ldap_entry2html_search to include "Browse"
416*7c478bd9Sstevel@tonic-gate  * and "Move Up" HREFs
417*7c478bd9Sstevel@tonic-gate  */
418*7c478bd9Sstevel@tonic-gate #define	LDAP_DISP_OPT_NONLEAF		0x00000004L
419*7c478bd9Sstevel@tonic-gate 
420*7c478bd9Sstevel@tonic-gate /*
421*7c478bd9Sstevel@tonic-gate  * display template item options (may not apply to all types)
422*7c478bd9Sstevel@tonic-gate  * if this bit is set in ti_options, it applies.
423*7c478bd9Sstevel@tonic-gate  */
424*7c478bd9Sstevel@tonic-gate #define	LDAP_DITEM_OPT_READONLY		0x00000001L
425*7c478bd9Sstevel@tonic-gate #define	LDAP_DITEM_OPT_SORTVALUES	0x00000002L
426*7c478bd9Sstevel@tonic-gate #define	LDAP_DITEM_OPT_SINGLEVALUED	0x00000004L
427*7c478bd9Sstevel@tonic-gate #define	LDAP_DITEM_OPT_HIDEIFEMPTY	0x00000008L
428*7c478bd9Sstevel@tonic-gate #define	LDAP_DITEM_OPT_VALUEREQUIRED	0x00000010L
429*7c478bd9Sstevel@tonic-gate #define	LDAP_DITEM_OPT_HIDEIFFALSE	0x00000020L	/* booleans only */
430*7c478bd9Sstevel@tonic-gate 
431*7c478bd9Sstevel@tonic-gate #endif	/* _SOLARIS_SDK */
432*7c478bd9Sstevel@tonic-gate 
433*7c478bd9Sstevel@tonic-gate /* Authentication request and response controls */
434*7c478bd9Sstevel@tonic-gate #define	LDAP_CONTROL_AUTH_REQUEST	"2.16.840.1.113730.3.4.16"
435*7c478bd9Sstevel@tonic-gate #define	LDAP_CONTROL_AUTH_RESPONSE	"2.16.840.1.113730.3.4.15"
436*7c478bd9Sstevel@tonic-gate 
437*7c478bd9Sstevel@tonic-gate /* Password information sent back to client */
438*7c478bd9Sstevel@tonic-gate #define	LDAP_CONTROL_PWEXPIRED		"2.16.840.1.113730.3.4.4"
439*7c478bd9Sstevel@tonic-gate #define	LDAP_CONTROL_PWEXPIRING		"2.16.840.1.113730.3.4.5"
440*7c478bd9Sstevel@tonic-gate 
441*7c478bd9Sstevel@tonic-gate 
442*7c478bd9Sstevel@tonic-gate /*
443*7c478bd9Sstevel@tonic-gate  * Client controls we know about
444*7c478bd9Sstevel@tonic-gate  */
445*7c478bd9Sstevel@tonic-gate #define	LDAP_CONTROL_REFERRALS		"1.2.840.113556.1.4.616"
446*7c478bd9Sstevel@tonic-gate 
447*7c478bd9Sstevel@tonic-gate 
448*7c478bd9Sstevel@tonic-gate /*
449*7c478bd9Sstevel@tonic-gate  * LDAP_API macro definition:
450*7c478bd9Sstevel@tonic-gate  */
451*7c478bd9Sstevel@tonic-gate #ifndef	LDAP_API
452*7c478bd9Sstevel@tonic-gate #define	LDAP_API(rt) rt
453*7c478bd9Sstevel@tonic-gate #endif	/* LDAP_API */
454*7c478bd9Sstevel@tonic-gate 
455*7c478bd9Sstevel@tonic-gate #ifdef	_SOLARIS_SDK
456*7c478bd9Sstevel@tonic-gate /* Simple Page Control functions for Solaris SDK */
457*7c478bd9Sstevel@tonic-gate int ldap_create_page_control(LDAP *ld, unsigned int pagesize,
458*7c478bd9Sstevel@tonic-gate 	struct berval *cookie, char isCritical, LDAPControl **output);
459*7c478bd9Sstevel@tonic-gate int ldap_parse_page_control(LDAP *ld, LDAPControl **controls,
460*7c478bd9Sstevel@tonic-gate 	unsigned int *totalcount, struct berval **cookie);
461*7c478bd9Sstevel@tonic-gate 
462*7c478bd9Sstevel@tonic-gate /* CRAM-MD5 functions */
463*7c478bd9Sstevel@tonic-gate int ldap_sasl_cram_md5_bind_s(LDAP *ld, char *dn,
464*7c478bd9Sstevel@tonic-gate 	struct berval *cred, LDAPControl **serverctrls,
465*7c478bd9Sstevel@tonic-gate 	LDAPControl **clientctrls);
466*7c478bd9Sstevel@tonic-gate /* DIGEST-MD5 Function */
467*7c478bd9Sstevel@tonic-gate int ldap_x_sasl_digest_md5_bind_s(LDAP *ld, char *dn,
468*7c478bd9Sstevel@tonic-gate 	struct berval *cred, LDAPControl **serverctrls,
469*7c478bd9Sstevel@tonic-gate 	LDAPControl **clientctrls);
470*7c478bd9Sstevel@tonic-gate int ldap_x_sasl_digest_md5_bind(LDAP *ld, char *dn,
471*7c478bd9Sstevel@tonic-gate 	struct berval *cred, LDAPControl **serverctrls,
472*7c478bd9Sstevel@tonic-gate 	LDAPControl **clientctrls, struct timeval *timeout,
473*7c478bd9Sstevel@tonic-gate 	LDAPMessage **result);
474*7c478bd9Sstevel@tonic-gate 
475*7c478bd9Sstevel@tonic-gate #endif	/* _SOLARIS_SDK */
476*7c478bd9Sstevel@tonic-gate 
477*7c478bd9Sstevel@tonic-gate LDAP_API(LDAP *) LDAP_CALL ldap_open(const char *host, int port);
478*7c478bd9Sstevel@tonic-gate LDAP_API(LDAP *) LDAP_CALL ldap_init(const char *defhost, int defport);
479*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_set_option(LDAP *ld, int option,
480*7c478bd9Sstevel@tonic-gate 	const void *optdata);
481*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_get_option(LDAP *ld, int option, void *optdata);
482*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_unbind(LDAP *ld);
483*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_unbind_s(LDAP *ld);
484*7c478bd9Sstevel@tonic-gate 
485*7c478bd9Sstevel@tonic-gate /*
486*7c478bd9Sstevel@tonic-gate  * perform ldap operations and obtain results
487*7c478bd9Sstevel@tonic-gate  */
488*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_abandon(LDAP *ld, int msgid);
489*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_add(LDAP *ld, const char *dn, LDAPMod **attrs);
490*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_add_s(LDAP *ld, const char *dn, LDAPMod **attrs);
491*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_simple_bind(LDAP *ld, const char *who,
492*7c478bd9Sstevel@tonic-gate 	const char *passwd);
493*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_simple_bind_s(LDAP *ld, const char *who,
494*7c478bd9Sstevel@tonic-gate 	const char *passwd);
495*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_modify(LDAP *ld, const char *dn, LDAPMod **mods);
496*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_modify_s(LDAP *ld, const char *dn,
497*7c478bd9Sstevel@tonic-gate 	LDAPMod **mods);
498*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_modrdn(LDAP *ld, const char *dn,
499*7c478bd9Sstevel@tonic-gate 	const char *newrdn);
500*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_modrdn_s(LDAP *ld, const char *dn,
501*7c478bd9Sstevel@tonic-gate 	const char *newrdn);
502*7c478bd9Sstevel@tonic-gate 
503*7c478bd9Sstevel@tonic-gate /* The following 2 functions are deprecated */
504*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_modrdn2(LDAP *ld, const char *dn,
505*7c478bd9Sstevel@tonic-gate 	const char *newrdn, int deleteoldrdn);
506*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_modrdn2_s(LDAP *ld, const char *dn,
507*7c478bd9Sstevel@tonic-gate 	const char *newrdn, int deleteoldrdn);
508*7c478bd9Sstevel@tonic-gate 
509*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_compare(LDAP *ld, const char *dn,
510*7c478bd9Sstevel@tonic-gate 	const char *attr, const char *value);
511*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_compare_s(LDAP *ld, const char *dn,
512*7c478bd9Sstevel@tonic-gate 	const char *attr, const char *value);
513*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_delete(LDAP *ld, const char *dn);
514*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_delete_s(LDAP *ld, const char *dn);
515*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_search(LDAP *ld, const char *base, int scope,
516*7c478bd9Sstevel@tonic-gate 	const char *filter, char **attrs, int attrsonly);
517*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_search_s(LDAP *ld, const char *base, int scope,
518*7c478bd9Sstevel@tonic-gate 	const char *filter, char **attrs, int attrsonly, LDAPMessage **res);
519*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_search_st(LDAP *ld, const char *base, int scope,
520*7c478bd9Sstevel@tonic-gate 	const char *filter, char **attrs, int attrsonly,
521*7c478bd9Sstevel@tonic-gate 	struct timeval *timeout, LDAPMessage **res);
522*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_result(LDAP *ld, int msgid, int all,
523*7c478bd9Sstevel@tonic-gate 	struct timeval *timeout, LDAPMessage **result);
524*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_msgfree(LDAPMessage *lm);
525*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_msgid(LDAPMessage *lm);
526*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_msgtype(LDAPMessage *lm);
527*7c478bd9Sstevel@tonic-gate 
528*7c478bd9Sstevel@tonic-gate 
529*7c478bd9Sstevel@tonic-gate /*
530*7c478bd9Sstevel@tonic-gate  * Routines to parse/deal with results and errors returned
531*7c478bd9Sstevel@tonic-gate  */
532*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_result2error(LDAP *ld, LDAPMessage *r,
533*7c478bd9Sstevel@tonic-gate 	int freeit);
534*7c478bd9Sstevel@tonic-gate char *LDAP_CALL ldap_err2string(int err);
535*7c478bd9Sstevel@tonic-gate LDAP_API(void) LDAP_CALL ldap_perror(LDAP *ld, const char *s);
536*7c478bd9Sstevel@tonic-gate LDAP_API(LDAPMessage *) LDAP_CALL ldap_first_entry(LDAP *ld,
537*7c478bd9Sstevel@tonic-gate 	LDAPMessage *chain);
538*7c478bd9Sstevel@tonic-gate LDAP_API(LDAPMessage *) LDAP_CALL ldap_next_entry(LDAP *ld,
539*7c478bd9Sstevel@tonic-gate 	LDAPMessage *entry);
540*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_count_entries(LDAP *ld, LDAPMessage *chain);
541*7c478bd9Sstevel@tonic-gate char *LDAP_CALL ldap_get_dn(LDAP *ld, LDAPMessage *entry);
542*7c478bd9Sstevel@tonic-gate char *LDAP_CALL ldap_dn2ufn(const char *dn);
543*7c478bd9Sstevel@tonic-gate char **LDAP_CALL ldap_explode_dn(const char *dn,
544*7c478bd9Sstevel@tonic-gate 	const int notypes);
545*7c478bd9Sstevel@tonic-gate char **LDAP_CALL ldap_explode_rdn(const char *rdn,
546*7c478bd9Sstevel@tonic-gate 	const int notypes);
547*7c478bd9Sstevel@tonic-gate char *LDAP_CALL ldap_first_attribute(LDAP *ld, LDAPMessage *entry,
548*7c478bd9Sstevel@tonic-gate 	BerElement **ber);
549*7c478bd9Sstevel@tonic-gate char *LDAP_CALL ldap_next_attribute(LDAP *ld, LDAPMessage *entry,
550*7c478bd9Sstevel@tonic-gate 	BerElement *ber);
551*7c478bd9Sstevel@tonic-gate 
552*7c478bd9Sstevel@tonic-gate /* The following function is deprecated */
553*7c478bd9Sstevel@tonic-gate LDAP_API(void) LDAP_CALL ldap_ber_free(BerElement *ber, int freebuf);
554*7c478bd9Sstevel@tonic-gate 
555*7c478bd9Sstevel@tonic-gate char **LDAP_CALL ldap_get_values(LDAP *ld, LDAPMessage *entry,
556*7c478bd9Sstevel@tonic-gate 	const char *target);
557*7c478bd9Sstevel@tonic-gate struct berval **LDAP_CALL ldap_get_values_len(LDAP *ld,
558*7c478bd9Sstevel@tonic-gate 	LDAPMessage *entry, const char *target);
559*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_count_values(char **vals);
560*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_count_values_len(struct berval **vals);
561*7c478bd9Sstevel@tonic-gate LDAP_API(void) LDAP_CALL ldap_value_free(char **vals);
562*7c478bd9Sstevel@tonic-gate LDAP_API(void) LDAP_CALL ldap_value_free_len(struct berval **vals);
563*7c478bd9Sstevel@tonic-gate LDAP_API(void) LDAP_CALL ldap_memfree(void *p);
564*7c478bd9Sstevel@tonic-gate 
565*7c478bd9Sstevel@tonic-gate 
566*7c478bd9Sstevel@tonic-gate /*
567*7c478bd9Sstevel@tonic-gate  * LDAPv3 extended operation calls
568*7c478bd9Sstevel@tonic-gate  */
569*7c478bd9Sstevel@tonic-gate /*
570*7c478bd9Sstevel@tonic-gate  * Note: all of the new asynchronous calls return an LDAP error code,
571*7c478bd9Sstevel@tonic-gate  * not a message id.  A message id is returned via the int *msgidp
572*7c478bd9Sstevel@tonic-gate  * parameter (usually the last parameter) if appropriate.
573*7c478bd9Sstevel@tonic-gate  */
574*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_abandon_ext(LDAP *ld, int msgid,
575*7c478bd9Sstevel@tonic-gate 	LDAPControl **serverctrls, LDAPControl **clientctrls);
576*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_add_ext(LDAP *ld, const char *dn, LDAPMod **attrs,
577*7c478bd9Sstevel@tonic-gate 	LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp);
578*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_add_ext_s(LDAP *ld, const char *dn,
579*7c478bd9Sstevel@tonic-gate 	LDAPMod **attrs, LDAPControl **serverctrls, LDAPControl **clientctrls);
580*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_sasl_bind(LDAP *ld, const char *dn,
581*7c478bd9Sstevel@tonic-gate 	const char *mechanism, const struct berval *cred,
582*7c478bd9Sstevel@tonic-gate 	LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp);
583*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_sasl_bind_s(LDAP *ld, const char *dn,
584*7c478bd9Sstevel@tonic-gate 	const char *mechanism, const struct berval *cred,
585*7c478bd9Sstevel@tonic-gate 	LDAPControl **serverctrls, LDAPControl **clientctrls,
586*7c478bd9Sstevel@tonic-gate 	struct berval **servercredp);
587*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_modify_ext(LDAP *ld, const char *dn,
588*7c478bd9Sstevel@tonic-gate 	LDAPMod **mods, LDAPControl **serverctrls, LDAPControl **clientctrls,
589*7c478bd9Sstevel@tonic-gate 	int *msgidp);
590*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_modify_ext_s(LDAP *ld, const char *dn,
591*7c478bd9Sstevel@tonic-gate 	LDAPMod **mods, LDAPControl **serverctrls, LDAPControl **clientctrls);
592*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_rename(LDAP *ld, const char *dn,
593*7c478bd9Sstevel@tonic-gate 	const char *newrdn, const char *newparent, int deleteoldrdn,
594*7c478bd9Sstevel@tonic-gate 	LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp);
595*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_rename_s(LDAP *ld, const char *dn,
596*7c478bd9Sstevel@tonic-gate 	const char *newrdn, const char *newparent, int deleteoldrdn,
597*7c478bd9Sstevel@tonic-gate 	LDAPControl **serverctrls, LDAPControl **clientctrls);
598*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_compare_ext(LDAP *ld, const char *dn,
599*7c478bd9Sstevel@tonic-gate 	const char *attr, const struct berval *bvalue,
600*7c478bd9Sstevel@tonic-gate 	LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp);
601*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_compare_ext_s(LDAP *ld, const char *dn,
602*7c478bd9Sstevel@tonic-gate 	const char *attr, const struct berval *bvalue,
603*7c478bd9Sstevel@tonic-gate 	LDAPControl **serverctrls, LDAPControl **clientctrls);
604*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_delete_ext(LDAP *ld, const char *dn,
605*7c478bd9Sstevel@tonic-gate 	LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp);
606*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_delete_ext_s(LDAP *ld, const char *dn,
607*7c478bd9Sstevel@tonic-gate 	LDAPControl **serverctrls, LDAPControl **clientctrls);
608*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_search_ext(LDAP *ld, const char *base,
609*7c478bd9Sstevel@tonic-gate 	int scope, const char *filter, char **attrs, int attrsonly,
610*7c478bd9Sstevel@tonic-gate 	LDAPControl **serverctrls, LDAPControl **clientctrls,
611*7c478bd9Sstevel@tonic-gate 	struct timeval *timeoutp, int sizelimit, int *msgidp);
612*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_search_ext_s(LDAP *ld, const char *base,
613*7c478bd9Sstevel@tonic-gate 	int scope, const char *filter, char **attrs, int attrsonly,
614*7c478bd9Sstevel@tonic-gate 	LDAPControl **serverctrls, LDAPControl **clientctrls,
615*7c478bd9Sstevel@tonic-gate 	struct timeval *timeoutp, int sizelimit, LDAPMessage **res);
616*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_extended_operation(LDAP *ld,
617*7c478bd9Sstevel@tonic-gate 	const char *requestoid, const struct berval *requestdata,
618*7c478bd9Sstevel@tonic-gate 	LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp);
619*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_extended_operation_s(LDAP *ld,
620*7c478bd9Sstevel@tonic-gate 	const char *requestoid, const struct berval *requestdata,
621*7c478bd9Sstevel@tonic-gate 	LDAPControl **serverctrls, LDAPControl **clientctrls,
622*7c478bd9Sstevel@tonic-gate 	char **retoidp, struct berval **retdatap);
623*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_unbind_ext(LDAP *ld, LDAPControl **serverctrls,
624*7c478bd9Sstevel@tonic-gate 	LDAPControl **clientctrls);
625*7c478bd9Sstevel@tonic-gate 
626*7c478bd9Sstevel@tonic-gate 
627*7c478bd9Sstevel@tonic-gate /*
628*7c478bd9Sstevel@tonic-gate  * LDAPv3 extended parsing / result handling calls
629*7c478bd9Sstevel@tonic-gate  */
630*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_parse_sasl_bind_result(LDAP *ld,
631*7c478bd9Sstevel@tonic-gate 	LDAPMessage *res, struct berval **servercredp, int freeit);
632*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_parse_result(LDAP *ld, LDAPMessage *res,
633*7c478bd9Sstevel@tonic-gate 	int *errcodep, char **matcheddnp, char **errmsgp, char ***referralsp,
634*7c478bd9Sstevel@tonic-gate 	LDAPControl ***serverctrlsp, int freeit);
635*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_parse_extended_result(LDAP *ld, LDAPMessage *res,
636*7c478bd9Sstevel@tonic-gate 	char **retoidp, struct berval **retdatap, int freeit);
637*7c478bd9Sstevel@tonic-gate LDAP_API(LDAPMessage *) LDAP_CALL ldap_first_message(LDAP *ld,
638*7c478bd9Sstevel@tonic-gate 	LDAPMessage *res);
639*7c478bd9Sstevel@tonic-gate LDAP_API(LDAPMessage *) LDAP_CALL ldap_next_message(LDAP *ld,
640*7c478bd9Sstevel@tonic-gate 	LDAPMessage *msg);
641*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_count_messages(LDAP *ld, LDAPMessage *res);
642*7c478bd9Sstevel@tonic-gate LDAP_API(LDAPMessage *) LDAP_CALL ldap_first_reference(LDAP *ld,
643*7c478bd9Sstevel@tonic-gate 	LDAPMessage *res);
644*7c478bd9Sstevel@tonic-gate LDAP_API(LDAPMessage *) LDAP_CALL ldap_next_reference(LDAP *ld,
645*7c478bd9Sstevel@tonic-gate 	LDAPMessage *ref);
646*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_count_references(LDAP *ld, LDAPMessage *res);
647*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_parse_reference(LDAP *ld, LDAPMessage *ref,
648*7c478bd9Sstevel@tonic-gate 	char ***referralsp, LDAPControl ***serverctrlsp, int freeit);
649*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_get_entry_controls(LDAP *ld, LDAPMessage *entry,
650*7c478bd9Sstevel@tonic-gate 	LDAPControl ***serverctrlsp);
651*7c478bd9Sstevel@tonic-gate LDAP_API(void) LDAP_CALL ldap_control_free(LDAPControl *ctrl);
652*7c478bd9Sstevel@tonic-gate LDAP_API(void) LDAP_CALL ldap_controls_free(LDAPControl **ctrls);
653*7c478bd9Sstevel@tonic-gate 
654*7c478bd9Sstevel@tonic-gate #ifdef  _SOLARIS_SDK
655*7c478bd9Sstevel@tonic-gate char ** ldap_get_reference_urls(LDAP *ld, LDAPMessage *res);
656*7c478bd9Sstevel@tonic-gate #endif
657*7c478bd9Sstevel@tonic-gate 
658*7c478bd9Sstevel@tonic-gate 
659*7c478bd9Sstevel@tonic-gate /* End of core standard C LDAP API definitions */
660*7c478bd9Sstevel@tonic-gate 
661*7c478bd9Sstevel@tonic-gate /*
662*7c478bd9Sstevel@tonic-gate  * Server side sorting of search results (an LDAPv3 extension --
663*7c478bd9Sstevel@tonic-gate  * LDAP_API_FEATURE_SERVER_SIDE_SORT)
664*7c478bd9Sstevel@tonic-gate  */
665*7c478bd9Sstevel@tonic-gate typedef struct LDAPsortkey {	/* structure for a sort-key */
666*7c478bd9Sstevel@tonic-gate 	char *sk_attrtype;
667*7c478bd9Sstevel@tonic-gate 	char *sk_matchruleoid;
668*7c478bd9Sstevel@tonic-gate 	int	sk_reverseorder;
669*7c478bd9Sstevel@tonic-gate } LDAPsortkey;
670*7c478bd9Sstevel@tonic-gate 
671*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_create_sort_control(LDAP *ld,
672*7c478bd9Sstevel@tonic-gate 	LDAPsortkey **sortKeyList, const char ctl_iscritical,
673*7c478bd9Sstevel@tonic-gate 	LDAPControl **ctrlp);
674*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_parse_sort_control(LDAP *ld,
675*7c478bd9Sstevel@tonic-gate 	LDAPControl **ctrls, unsigned long *result, char **attribute);
676*7c478bd9Sstevel@tonic-gate 
677*7c478bd9Sstevel@tonic-gate LDAP_API(void) LDAP_CALL ldap_free_sort_keylist(LDAPsortkey **sortKeyList);
678*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_create_sort_keylist(LDAPsortkey ***sortKeyList,
679*7c478bd9Sstevel@tonic-gate 	const char *string_rep);
680*7c478bd9Sstevel@tonic-gate 
681*7c478bd9Sstevel@tonic-gate 
682*7c478bd9Sstevel@tonic-gate /*
683*7c478bd9Sstevel@tonic-gate  * Virtual list view (an LDAPv3 extension -- LDAP_API_FEATURE_VIRTUAL_LIST_VIEW)
684*7c478bd9Sstevel@tonic-gate  */
685*7c478bd9Sstevel@tonic-gate /*
686*7c478bd9Sstevel@tonic-gate  * structure that describes a VirtualListViewRequest control.
687*7c478bd9Sstevel@tonic-gate  * note that ldvlist_index and ldvlist_size are only relevant to
688*7c478bd9Sstevel@tonic-gate  * ldap_create_virtuallist_control() if ldvlist_attrvalue is NULL.
689*7c478bd9Sstevel@tonic-gate  */
690*7c478bd9Sstevel@tonic-gate typedef struct ldapvirtuallist {
691*7c478bd9Sstevel@tonic-gate     unsigned long	ldvlist_before_count;	/* # entries before target */
692*7c478bd9Sstevel@tonic-gate     unsigned long   ldvlist_after_count;	/* # entries after target */
693*7c478bd9Sstevel@tonic-gate     char	    *ldvlist_attrvalue;		/* jump to this value */
694*7c478bd9Sstevel@tonic-gate     unsigned long   ldvlist_index;		/* list offset */
695*7c478bd9Sstevel@tonic-gate     unsigned long   ldvlist_size;		/* number of items in vlist */
696*7c478bd9Sstevel@tonic-gate     void	*ldvlist_extradata;		/* for use by application */
697*7c478bd9Sstevel@tonic-gate } LDAPVirtualList;
698*7c478bd9Sstevel@tonic-gate 
699*7c478bd9Sstevel@tonic-gate /*
700*7c478bd9Sstevel@tonic-gate  * VLV functions:
701*7c478bd9Sstevel@tonic-gate  */
702*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_create_virtuallist_control(LDAP *ld,
703*7c478bd9Sstevel@tonic-gate 	LDAPVirtualList *ldvlistp, LDAPControl **ctrlp);
704*7c478bd9Sstevel@tonic-gate 
705*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_parse_virtuallist_control(LDAP *ld,
706*7c478bd9Sstevel@tonic-gate 	LDAPControl **ctrls, unsigned long *target_posp,
707*7c478bd9Sstevel@tonic-gate 	unsigned long *list_sizep, int *errcodep);
708*7c478bd9Sstevel@tonic-gate 
709*7c478bd9Sstevel@tonic-gate 
710*7c478bd9Sstevel@tonic-gate /*
711*7c478bd9Sstevel@tonic-gate  * Routines for creating persistent search controls and for handling
712*7c478bd9Sstevel@tonic-gate  * "entry changed notification" controls (an LDAPv3 extension --
713*7c478bd9Sstevel@tonic-gate  * LDAP_API_FEATURE_PERSISTENT_SEARCH)
714*7c478bd9Sstevel@tonic-gate  */
715*7c478bd9Sstevel@tonic-gate #define	LDAP_CHANGETYPE_ADD		1
716*7c478bd9Sstevel@tonic-gate #define	LDAP_CHANGETYPE_DELETE		2
717*7c478bd9Sstevel@tonic-gate #define	LDAP_CHANGETYPE_MODIFY		4
718*7c478bd9Sstevel@tonic-gate #define	LDAP_CHANGETYPE_MODDN		8
719*7c478bd9Sstevel@tonic-gate #define	LDAP_CHANGETYPE_ANY		(1|2|4|8)
720*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_create_persistentsearch_control(LDAP *ld,
721*7c478bd9Sstevel@tonic-gate 	int changetypes, int changesonly, int return_echg_ctls,
722*7c478bd9Sstevel@tonic-gate 	char ctl_iscritical, LDAPControl **ctrlp);
723*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_parse_entrychange_control(LDAP *ld,
724*7c478bd9Sstevel@tonic-gate 	LDAPControl **ctrls, int *chgtypep, char **prevdnp,
725*7c478bd9Sstevel@tonic-gate 	int *chgnumpresentp, ber_int_t *chgnump);
726*7c478bd9Sstevel@tonic-gate 
727*7c478bd9Sstevel@tonic-gate 
728*7c478bd9Sstevel@tonic-gate /*
729*7c478bd9Sstevel@tonic-gate  * Routines for creating Proxied Authorization controls (an LDAPv3
730*7c478bd9Sstevel@tonic-gate  * extension -- LDAP_API_FEATURE_PROXY_AUTHORIZATION)
731*7c478bd9Sstevel@tonic-gate  * ldap_create_proxyauth_control() is for the old (version 1) control.
732*7c478bd9Sstevel@tonic-gate  * ldap_create_proxiedauth_control() is for the newer (version 2) control.
733*7c478bd9Sstevel@tonic-gate  * Version 1 is supported by iPlanet Directory Server 4.1 and later.
734*7c478bd9Sstevel@tonic-gate  * Version 2 is supported by iPlanet Directory Server 5.0 and later.
735*7c478bd9Sstevel@tonic-gate  */
736*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_create_proxyauth_control(LDAP *ld,
737*7c478bd9Sstevel@tonic-gate 	const char *dn, const char ctl_iscritical, LDAPControl **ctrlp);
738*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_create_proxiedauth_control(LDAP *ld,
739*7c478bd9Sstevel@tonic-gate 	const char *authzid, LDAPControl **ctrlp);
740*7c478bd9Sstevel@tonic-gate 
741*7c478bd9Sstevel@tonic-gate 
742*7c478bd9Sstevel@tonic-gate /*
743*7c478bd9Sstevel@tonic-gate  * Functions to get and set LDAP error information (API extension --
744*7c478bd9Sstevel@tonic-gate  * LDAP_API_FEATURE_X_LDERRNO )
745*7c478bd9Sstevel@tonic-gate  */
746*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_get_lderrno(LDAP *ld, char **m, char **s);
747*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_set_lderrno(LDAP *ld, int e, char *m, char *s);
748*7c478bd9Sstevel@tonic-gate 
749*7c478bd9Sstevel@tonic-gate 
750*7c478bd9Sstevel@tonic-gate /*
751*7c478bd9Sstevel@tonic-gate  * LDAP URL functions and definitions (an API extension --
752*7c478bd9Sstevel@tonic-gate  * LDAP_API_FEATURE_X_URL_FUNCTIONS)
753*7c478bd9Sstevel@tonic-gate  */
754*7c478bd9Sstevel@tonic-gate /*
755*7c478bd9Sstevel@tonic-gate  * types for ldap URL handling
756*7c478bd9Sstevel@tonic-gate  */
757*7c478bd9Sstevel@tonic-gate typedef struct ldap_url_desc {
758*7c478bd9Sstevel@tonic-gate     char		*lud_host;
759*7c478bd9Sstevel@tonic-gate     int			lud_port;
760*7c478bd9Sstevel@tonic-gate     char		*lud_dn;
761*7c478bd9Sstevel@tonic-gate     char		**lud_attrs;
762*7c478bd9Sstevel@tonic-gate     int			lud_scope;
763*7c478bd9Sstevel@tonic-gate     char		*lud_filter;
764*7c478bd9Sstevel@tonic-gate     unsigned long	lud_options;
765*7c478bd9Sstevel@tonic-gate #define	LDAP_URL_OPT_SECURE	0x01
766*7c478bd9Sstevel@tonic-gate     char	*lud_string;    /* for internal use only */
767*7c478bd9Sstevel@tonic-gate } LDAPURLDesc;
768*7c478bd9Sstevel@tonic-gate 
769*7c478bd9Sstevel@tonic-gate #define	NULLLDAPURLDESC ((LDAPURLDesc *)NULL)
770*7c478bd9Sstevel@tonic-gate 
771*7c478bd9Sstevel@tonic-gate /*
772*7c478bd9Sstevel@tonic-gate  * possible errors returned by ldap_url_parse()
773*7c478bd9Sstevel@tonic-gate  */
774*7c478bd9Sstevel@tonic-gate #define	LDAP_URL_ERR_NOTLDAP	1	/* URL doesn't begin with "ldap://" */
775*7c478bd9Sstevel@tonic-gate #define	LDAP_URL_ERR_NODN	2	/* URL has no DN (required) */
776*7c478bd9Sstevel@tonic-gate #define	LDAP_URL_ERR_BADSCOPE	3	/* URL scope string is invalid */
777*7c478bd9Sstevel@tonic-gate #define	LDAP_URL_ERR_MEM	4	/* can't allocate memory space */
778*7c478bd9Sstevel@tonic-gate #define	LDAP_URL_ERR_PARAM	5	/* bad parameter to an URL function */
779*7c478bd9Sstevel@tonic-gate #define	LDAP_URL_ERR_HOSTPORT	6	/* URL hostcode is invalid */
780*7c478bd9Sstevel@tonic-gate 
781*7c478bd9Sstevel@tonic-gate /*
782*7c478bd9Sstevel@tonic-gate  * URL functions:
783*7c478bd9Sstevel@tonic-gate  */
784*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_is_ldap_url(const char *url);
785*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_url_parse(const char *url, LDAPURLDesc **ludpp);
786*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_url_parse_nodn(const char *url, LDAPURLDesc **ludpp);
787*7c478bd9Sstevel@tonic-gate LDAP_API(void) LDAP_CALL ldap_free_urldesc(LDAPURLDesc *ludp);
788*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_url_search(LDAP *ld, const char *url,
789*7c478bd9Sstevel@tonic-gate 	int attrsonly);
790*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_url_search_s(LDAP *ld, const char *url,
791*7c478bd9Sstevel@tonic-gate 	int attrsonly, LDAPMessage **res);
792*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_url_search_st(LDAP *ld, const char *url,
793*7c478bd9Sstevel@tonic-gate 	int attrsonly, struct timeval *timeout, LDAPMessage **res);
794*7c478bd9Sstevel@tonic-gate 
795*7c478bd9Sstevel@tonic-gate #ifdef	_SOLARIS_SDK
796*7c478bd9Sstevel@tonic-gate /*
797*7c478bd9Sstevel@tonic-gate  * Additional URL functions plus Character set, Search Preference
798*7c478bd9Sstevel@tonic-gate  * and Display Template functions moved from internal header files
799*7c478bd9Sstevel@tonic-gate  */
800*7c478bd9Sstevel@tonic-gate 
801*7c478bd9Sstevel@tonic-gate /*
802*7c478bd9Sstevel@tonic-gate  * URL functions
803*7c478bd9Sstevel@tonic-gate  */
804*7c478bd9Sstevel@tonic-gate char *ldap_dns_to_url(LDAP *ld, char *dns_name, char *attrs,
805*7c478bd9Sstevel@tonic-gate 	char *scope, char *filter);
806*7c478bd9Sstevel@tonic-gate char *ldap_dn_to_url(LDAP *ld, char *dn, int nameparts);
807*7c478bd9Sstevel@tonic-gate 
808*7c478bd9Sstevel@tonic-gate /*
809*7c478bd9Sstevel@tonic-gate  * Character set functions
810*7c478bd9Sstevel@tonic-gate  */
811*7c478bd9Sstevel@tonic-gate #ifdef	STR_TRANSLATION
812*7c478bd9Sstevel@tonic-gate void ldap_set_string_translators(LDAP *ld,
813*7c478bd9Sstevel@tonic-gate 	BERTranslateProc encode_proc, BERTranslateProc decode_proc);
814*7c478bd9Sstevel@tonic-gate int ldap_translate_from_t61(LDAP *ld, char **bufp,
815*7c478bd9Sstevel@tonic-gate 	unsigned long *lenp, int free_input);
816*7c478bd9Sstevel@tonic-gate int ldap_translate_to_t61(LDAP *ld, char **bufp,
817*7c478bd9Sstevel@tonic-gate 	unsigned long *lenp, int free_input);
818*7c478bd9Sstevel@tonic-gate void ldap_enable_translation(LDAP *ld, LDAPMessage *entry,
819*7c478bd9Sstevel@tonic-gate 	int enable);
820*7c478bd9Sstevel@tonic-gate #ifdef	LDAP_CHARSET_8859
821*7c478bd9Sstevel@tonic-gate int ldap_t61_to_8859(char **bufp, unsigned long *buflenp,
822*7c478bd9Sstevel@tonic-gate 	int free_input);
823*7c478bd9Sstevel@tonic-gate int ldap_8859_to_t61(char **bufp, unsigned long *buflenp,
824*7c478bd9Sstevel@tonic-gate 	int free_input);
825*7c478bd9Sstevel@tonic-gate #endif	/* LDAP_CHARSET_8859 */
826*7c478bd9Sstevel@tonic-gate #endif	/* STR_TRANSLATION */
827*7c478bd9Sstevel@tonic-gate 
828*7c478bd9Sstevel@tonic-gate /*
829*7c478bd9Sstevel@tonic-gate  * Display Temple functions/structures
830*7c478bd9Sstevel@tonic-gate  */
831*7c478bd9Sstevel@tonic-gate /*
832*7c478bd9Sstevel@tonic-gate  * display template item structure
833*7c478bd9Sstevel@tonic-gate  */
834*7c478bd9Sstevel@tonic-gate struct ldap_tmplitem {
835*7c478bd9Sstevel@tonic-gate     unsigned long		ti_syntaxid;
836*7c478bd9Sstevel@tonic-gate     unsigned long		ti_options;
837*7c478bd9Sstevel@tonic-gate     char			*ti_attrname;
838*7c478bd9Sstevel@tonic-gate     char			*ti_label;
839*7c478bd9Sstevel@tonic-gate     char			**ti_args;
840*7c478bd9Sstevel@tonic-gate     struct ldap_tmplitem	*ti_next_in_row;
841*7c478bd9Sstevel@tonic-gate     struct ldap_tmplitem	*ti_next_in_col;
842*7c478bd9Sstevel@tonic-gate     void			*ti_appdata;
843*7c478bd9Sstevel@tonic-gate };
844*7c478bd9Sstevel@tonic-gate 
845*7c478bd9Sstevel@tonic-gate #define	NULLTMPLITEM	((struct ldap_tmplitem *)0)
846*7c478bd9Sstevel@tonic-gate 
847*7c478bd9Sstevel@tonic-gate #define	LDAP_SET_TMPLITEM_APPDATA(ti, datap)  \
848*7c478bd9Sstevel@tonic-gate 	(ti)->ti_appdata = (void *)(datap)
849*7c478bd9Sstevel@tonic-gate 
850*7c478bd9Sstevel@tonic-gate #define	LDAP_GET_TMPLITEM_APPDATA(ti, type)   \
851*7c478bd9Sstevel@tonic-gate 	(type)((ti)->ti_appdata)
852*7c478bd9Sstevel@tonic-gate 
853*7c478bd9Sstevel@tonic-gate #define	LDAP_IS_TMPLITEM_OPTION_SET(ti, option)       \
854*7c478bd9Sstevel@tonic-gate 	(((ti)->ti_options & option) != 0)
855*7c478bd9Sstevel@tonic-gate 
856*7c478bd9Sstevel@tonic-gate /*
857*7c478bd9Sstevel@tonic-gate  * object class array structure
858*7c478bd9Sstevel@tonic-gate  */
859*7c478bd9Sstevel@tonic-gate struct ldap_oclist {
860*7c478bd9Sstevel@tonic-gate     char		**oc_objclasses;
861*7c478bd9Sstevel@tonic-gate     struct ldap_oclist	*oc_next;
862*7c478bd9Sstevel@tonic-gate };
863*7c478bd9Sstevel@tonic-gate 
864*7c478bd9Sstevel@tonic-gate #define	NULLOCLIST	((struct ldap_oclist *)0)
865*7c478bd9Sstevel@tonic-gate 
866*7c478bd9Sstevel@tonic-gate 
867*7c478bd9Sstevel@tonic-gate /*
868*7c478bd9Sstevel@tonic-gate  * add defaults list
869*7c478bd9Sstevel@tonic-gate  */
870*7c478bd9Sstevel@tonic-gate struct ldap_adddeflist {
871*7c478bd9Sstevel@tonic-gate     int			ad_source;
872*7c478bd9Sstevel@tonic-gate #define	LDAP_ADSRC_CONSTANTVALUE	1
873*7c478bd9Sstevel@tonic-gate #define	LDAP_ADSRC_ADDERSDN		2
874*7c478bd9Sstevel@tonic-gate     char		*ad_attrname;
875*7c478bd9Sstevel@tonic-gate     char		*ad_value;
876*7c478bd9Sstevel@tonic-gate     struct ldap_adddeflist	*ad_next;
877*7c478bd9Sstevel@tonic-gate };
878*7c478bd9Sstevel@tonic-gate 
879*7c478bd9Sstevel@tonic-gate #define	NULLADLIST	((struct ldap_adddeflist *)0)
880*7c478bd9Sstevel@tonic-gate 
881*7c478bd9Sstevel@tonic-gate 
882*7c478bd9Sstevel@tonic-gate /*
883*7c478bd9Sstevel@tonic-gate  * display template global options
884*7c478bd9Sstevel@tonic-gate  * if this bit is set in dt_options, it applies.
885*7c478bd9Sstevel@tonic-gate  */
886*7c478bd9Sstevel@tonic-gate /*
887*7c478bd9Sstevel@tonic-gate  * users should be allowed to try to add objects of these entries
888*7c478bd9Sstevel@tonic-gate  */
889*7c478bd9Sstevel@tonic-gate #define	LDAP_DTMPL_OPT_ADDABLE		0x00000001L
890*7c478bd9Sstevel@tonic-gate 
891*7c478bd9Sstevel@tonic-gate /*
892*7c478bd9Sstevel@tonic-gate  * users should be allowed to do "modify RDN" operation of these entries
893*7c478bd9Sstevel@tonic-gate  */
894*7c478bd9Sstevel@tonic-gate #define	LDAP_DTMPL_OPT_ALLOWMODRDN	0x00000002L
895*7c478bd9Sstevel@tonic-gate 
896*7c478bd9Sstevel@tonic-gate /*
897*7c478bd9Sstevel@tonic-gate  * this template is an alternate view, not a primary view
898*7c478bd9Sstevel@tonic-gate  */
899*7c478bd9Sstevel@tonic-gate #define	LDAP_DTMPL_OPT_ALTVIEW	0x00000004L
900*7c478bd9Sstevel@tonic-gate 
901*7c478bd9Sstevel@tonic-gate 
902*7c478bd9Sstevel@tonic-gate /*
903*7c478bd9Sstevel@tonic-gate  * display template structure
904*7c478bd9Sstevel@tonic-gate  */
905*7c478bd9Sstevel@tonic-gate struct ldap_disptmpl {
906*7c478bd9Sstevel@tonic-gate     char			*dt_name;
907*7c478bd9Sstevel@tonic-gate     char			*dt_pluralname;
908*7c478bd9Sstevel@tonic-gate     char			*dt_iconname;
909*7c478bd9Sstevel@tonic-gate     unsigned long		dt_options;
910*7c478bd9Sstevel@tonic-gate     char			*dt_authattrname;
911*7c478bd9Sstevel@tonic-gate     char			*dt_defrdnattrname;
912*7c478bd9Sstevel@tonic-gate     char			*dt_defaddlocation;
913*7c478bd9Sstevel@tonic-gate     struct ldap_oclist		*dt_oclist;
914*7c478bd9Sstevel@tonic-gate     struct ldap_adddeflist	*dt_adddeflist;
915*7c478bd9Sstevel@tonic-gate     struct ldap_tmplitem	*dt_items;
916*7c478bd9Sstevel@tonic-gate     void			*dt_appdata;
917*7c478bd9Sstevel@tonic-gate     struct ldap_disptmpl	*dt_next;
918*7c478bd9Sstevel@tonic-gate };
919*7c478bd9Sstevel@tonic-gate 
920*7c478bd9Sstevel@tonic-gate #define	NULLDISPTMPL	((struct ldap_disptmpl *)0)
921*7c478bd9Sstevel@tonic-gate 
922*7c478bd9Sstevel@tonic-gate #define	LDAP_SET_DISPTMPL_APPDATA(dt, datap)  \
923*7c478bd9Sstevel@tonic-gate 	(dt)->dt_appdata = (void *)(datap)
924*7c478bd9Sstevel@tonic-gate 
925*7c478bd9Sstevel@tonic-gate #define	LDAP_GET_DISPTMPL_APPDATA(dt, type)   \
926*7c478bd9Sstevel@tonic-gate 	(type)((dt)->dt_appdata)
927*7c478bd9Sstevel@tonic-gate 
928*7c478bd9Sstevel@tonic-gate #define	LDAP_IS_DISPTMPL_OPTION_SET(dt, option)       \
929*7c478bd9Sstevel@tonic-gate 	(((dt)->dt_options & option) != 0)
930*7c478bd9Sstevel@tonic-gate 
931*7c478bd9Sstevel@tonic-gate #define	LDAP_TMPL_ERR_VERSION   1
932*7c478bd9Sstevel@tonic-gate #define	LDAP_TMPL_ERR_MEM	2
933*7c478bd9Sstevel@tonic-gate #define	LDAP_TMPL_ERR_SYNTAX    3
934*7c478bd9Sstevel@tonic-gate #define	LDAP_TMPL_ERR_FILE	4
935*7c478bd9Sstevel@tonic-gate 
936*7c478bd9Sstevel@tonic-gate /*
937*7c478bd9Sstevel@tonic-gate  * buffer size needed for entry2text and vals2text
938*7c478bd9Sstevel@tonic-gate  */
939*7c478bd9Sstevel@tonic-gate #define	LDAP_DTMPL_BUFSIZ	8192
940*7c478bd9Sstevel@tonic-gate 
941*7c478bd9Sstevel@tonic-gate typedef int (*writeptype)(void *writeparm, char *p, int len);
942*7c478bd9Sstevel@tonic-gate 
943*7c478bd9Sstevel@tonic-gate LDAP_API(int)
944*7c478bd9Sstevel@tonic-gate LDAP_CALL
945*7c478bd9Sstevel@tonic-gate ldap_init_templates(char *file, struct ldap_disptmpl **tmpllistp);
946*7c478bd9Sstevel@tonic-gate 
947*7c478bd9Sstevel@tonic-gate LDAP_API(int)
948*7c478bd9Sstevel@tonic-gate LDAP_CALL
949*7c478bd9Sstevel@tonic-gate ldap_init_templates_buf(char *buf, long buflen,
950*7c478bd9Sstevel@tonic-gate 	struct ldap_disptmpl **tmpllistp);
951*7c478bd9Sstevel@tonic-gate 
952*7c478bd9Sstevel@tonic-gate LDAP_API(void)
953*7c478bd9Sstevel@tonic-gate LDAP_CALL
954*7c478bd9Sstevel@tonic-gate ldap_free_templates(struct ldap_disptmpl *tmpllist);
955*7c478bd9Sstevel@tonic-gate 
956*7c478bd9Sstevel@tonic-gate LDAP_API(struct ldap_disptmpl *)
957*7c478bd9Sstevel@tonic-gate LDAP_CALL
958*7c478bd9Sstevel@tonic-gate ldap_first_disptmpl(struct ldap_disptmpl *tmpllist);
959*7c478bd9Sstevel@tonic-gate 
960*7c478bd9Sstevel@tonic-gate LDAP_API(struct ldap_disptmpl *)
961*7c478bd9Sstevel@tonic-gate LDAP_CALL
962*7c478bd9Sstevel@tonic-gate ldap_next_disptmpl(struct ldap_disptmpl *tmpllist,
963*7c478bd9Sstevel@tonic-gate 	struct ldap_disptmpl *tmpl);
964*7c478bd9Sstevel@tonic-gate 
965*7c478bd9Sstevel@tonic-gate LDAP_API(struct ldap_disptmpl *)
966*7c478bd9Sstevel@tonic-gate LDAP_CALL
967*7c478bd9Sstevel@tonic-gate ldap_name2template(char *name, struct ldap_disptmpl *tmpllist);
968*7c478bd9Sstevel@tonic-gate 
969*7c478bd9Sstevel@tonic-gate LDAP_API(struct ldap_disptmpl *)
970*7c478bd9Sstevel@tonic-gate LDAP_CALL
971*7c478bd9Sstevel@tonic-gate ldap_oc2template(char **oclist, struct ldap_disptmpl *tmpllist);
972*7c478bd9Sstevel@tonic-gate 
973*7c478bd9Sstevel@tonic-gate LDAP_API(char **)
974*7c478bd9Sstevel@tonic-gate LDAP_CALL
975*7c478bd9Sstevel@tonic-gate ldap_tmplattrs(struct ldap_disptmpl *tmpl, char **includeattrs, int exclude,
976*7c478bd9Sstevel@tonic-gate 	unsigned long syntaxmask);
977*7c478bd9Sstevel@tonic-gate 
978*7c478bd9Sstevel@tonic-gate LDAP_API(struct ldap_tmplitem *)
979*7c478bd9Sstevel@tonic-gate LDAP_CALL
980*7c478bd9Sstevel@tonic-gate ldap_first_tmplrow(struct ldap_disptmpl *tmpl);
981*7c478bd9Sstevel@tonic-gate 
982*7c478bd9Sstevel@tonic-gate LDAP_API(struct ldap_tmplitem *)
983*7c478bd9Sstevel@tonic-gate LDAP_CALL
984*7c478bd9Sstevel@tonic-gate ldap_next_tmplrow(struct ldap_disptmpl *tmpl, struct ldap_tmplitem *row);
985*7c478bd9Sstevel@tonic-gate 
986*7c478bd9Sstevel@tonic-gate LDAP_API(struct ldap_tmplitem *)
987*7c478bd9Sstevel@tonic-gate LDAP_CALL
988*7c478bd9Sstevel@tonic-gate ldap_first_tmplcol(struct ldap_disptmpl *tmpl, struct ldap_tmplitem *row);
989*7c478bd9Sstevel@tonic-gate 
990*7c478bd9Sstevel@tonic-gate LDAP_API(struct ldap_tmplitem *)
991*7c478bd9Sstevel@tonic-gate LDAP_CALL
992*7c478bd9Sstevel@tonic-gate ldap_next_tmplcol(struct ldap_disptmpl *tmpl, struct ldap_tmplitem *row,
993*7c478bd9Sstevel@tonic-gate 	struct ldap_tmplitem *col);
994*7c478bd9Sstevel@tonic-gate 
995*7c478bd9Sstevel@tonic-gate LDAP_API(int)
996*7c478bd9Sstevel@tonic-gate LDAP_CALL
997*7c478bd9Sstevel@tonic-gate ldap_entry2text(LDAP *ld, char *buf, LDAPMessage *entry,
998*7c478bd9Sstevel@tonic-gate 	struct ldap_disptmpl *tmpl, char **defattrs, char ***defvals,
999*7c478bd9Sstevel@tonic-gate 	writeptype writeproc, void *writeparm, char *eol, int rdncount,
1000*7c478bd9Sstevel@tonic-gate 	unsigned long opts);
1001*7c478bd9Sstevel@tonic-gate 
1002*7c478bd9Sstevel@tonic-gate LDAP_API(int)
1003*7c478bd9Sstevel@tonic-gate LDAP_CALL
1004*7c478bd9Sstevel@tonic-gate ldap_vals2text(LDAP *ld, char *buf, char **vals, char *label, int labelwidth,
1005*7c478bd9Sstevel@tonic-gate 	unsigned long syntaxid, writeptype writeproc, void *writeparm,
1006*7c478bd9Sstevel@tonic-gate 	char *eol, int rdncount);
1007*7c478bd9Sstevel@tonic-gate 
1008*7c478bd9Sstevel@tonic-gate LDAP_API(int)
1009*7c478bd9Sstevel@tonic-gate LDAP_CALL
1010*7c478bd9Sstevel@tonic-gate ldap_entry2text_search(LDAP *ld, char *dn, char *base, LDAPMessage *entry,
1011*7c478bd9Sstevel@tonic-gate 	struct ldap_disptmpl *tmpllist, char **defattrs, char ***defvals,
1012*7c478bd9Sstevel@tonic-gate 	writeptype writeproc, void *writeparm, char *eol, int rdncount,
1013*7c478bd9Sstevel@tonic-gate 	unsigned long opts);
1014*7c478bd9Sstevel@tonic-gate 
1015*7c478bd9Sstevel@tonic-gate LDAP_API(int)
1016*7c478bd9Sstevel@tonic-gate LDAP_CALL
1017*7c478bd9Sstevel@tonic-gate ldap_entry2html(LDAP *ld, char *buf, LDAPMessage *entry,
1018*7c478bd9Sstevel@tonic-gate 	struct ldap_disptmpl *tmpl, char **defattrs, char ***defvals,
1019*7c478bd9Sstevel@tonic-gate 	writeptype writeproc, void *writeparm, char *eol, int rdncount,
1020*7c478bd9Sstevel@tonic-gate 	unsigned long opts, char *urlprefix, char *base);
1021*7c478bd9Sstevel@tonic-gate 
1022*7c478bd9Sstevel@tonic-gate LDAP_API(int)
1023*7c478bd9Sstevel@tonic-gate LDAP_CALL
1024*7c478bd9Sstevel@tonic-gate ldap_vals2html(LDAP *ld, char *buf, char **vals, char *label, int labelwidth,
1025*7c478bd9Sstevel@tonic-gate 	unsigned long syntaxid, writeptype writeproc, void *writeparm,
1026*7c478bd9Sstevel@tonic-gate 	char *eol, int rdncount, char *urlprefix);
1027*7c478bd9Sstevel@tonic-gate 
1028*7c478bd9Sstevel@tonic-gate LDAP_API(int)
1029*7c478bd9Sstevel@tonic-gate LDAP_CALL
1030*7c478bd9Sstevel@tonic-gate ldap_entry2html_search(LDAP *ld, char *dn, char *base, LDAPMessage *entry,
1031*7c478bd9Sstevel@tonic-gate 	struct ldap_disptmpl *tmpllist, char **defattrs, char ***defvals,
1032*7c478bd9Sstevel@tonic-gate 	writeptype writeproc, void *writeparm, char *eol, int rdncount,
1033*7c478bd9Sstevel@tonic-gate 	unsigned long opts, char *urlprefix);
1034*7c478bd9Sstevel@tonic-gate 
1035*7c478bd9Sstevel@tonic-gate /*
1036*7c478bd9Sstevel@tonic-gate  * Search Preference Definitions
1037*7c478bd9Sstevel@tonic-gate  */
1038*7c478bd9Sstevel@tonic-gate 
1039*7c478bd9Sstevel@tonic-gate struct ldap_searchattr {
1040*7c478bd9Sstevel@tonic-gate 	char				*sa_attrlabel;
1041*7c478bd9Sstevel@tonic-gate 	char				*sa_attr;
1042*7c478bd9Sstevel@tonic-gate 					/* max 32 matchtypes for now */
1043*7c478bd9Sstevel@tonic-gate 	unsigned long			sa_matchtypebitmap;
1044*7c478bd9Sstevel@tonic-gate 	char				*sa_selectattr;
1045*7c478bd9Sstevel@tonic-gate 	char				*sa_selecttext;
1046*7c478bd9Sstevel@tonic-gate 	struct ldap_searchattr		*sa_next;
1047*7c478bd9Sstevel@tonic-gate };
1048*7c478bd9Sstevel@tonic-gate 
1049*7c478bd9Sstevel@tonic-gate struct ldap_searchmatch {
1050*7c478bd9Sstevel@tonic-gate 	char				*sm_matchprompt;
1051*7c478bd9Sstevel@tonic-gate 	char				*sm_filter;
1052*7c478bd9Sstevel@tonic-gate 	struct ldap_searchmatch		*sm_next;
1053*7c478bd9Sstevel@tonic-gate };
1054*7c478bd9Sstevel@tonic-gate 
1055*7c478bd9Sstevel@tonic-gate struct ldap_searchobj {
1056*7c478bd9Sstevel@tonic-gate 	char				*so_objtypeprompt;
1057*7c478bd9Sstevel@tonic-gate 	unsigned long			so_options;
1058*7c478bd9Sstevel@tonic-gate 	char				*so_prompt;
1059*7c478bd9Sstevel@tonic-gate 	short				so_defaultscope;
1060*7c478bd9Sstevel@tonic-gate 	char				*so_filterprefix;
1061*7c478bd9Sstevel@tonic-gate 	char				*so_filtertag;
1062*7c478bd9Sstevel@tonic-gate 	char				*so_defaultselectattr;
1063*7c478bd9Sstevel@tonic-gate 	char				*so_defaultselecttext;
1064*7c478bd9Sstevel@tonic-gate 	struct ldap_searchattr		*so_salist;
1065*7c478bd9Sstevel@tonic-gate 	struct ldap_searchmatch		*so_smlist;
1066*7c478bd9Sstevel@tonic-gate 	struct ldap_searchobj		*so_next;
1067*7c478bd9Sstevel@tonic-gate };
1068*7c478bd9Sstevel@tonic-gate 
1069*7c478bd9Sstevel@tonic-gate #define	NULLSEARCHOBJ			((struct ldap_searchobj *)0)
1070*7c478bd9Sstevel@tonic-gate 
1071*7c478bd9Sstevel@tonic-gate /*
1072*7c478bd9Sstevel@tonic-gate  * global search object options
1073*7c478bd9Sstevel@tonic-gate  */
1074*7c478bd9Sstevel@tonic-gate #define	LDAP_SEARCHOBJ_OPT_INTERNAL	0x00000001
1075*7c478bd9Sstevel@tonic-gate 
1076*7c478bd9Sstevel@tonic-gate #define	LDAP_IS_SEARCHOBJ_OPTION_SET(so, option)      \
1077*7c478bd9Sstevel@tonic-gate 	(((so)->so_options & option) != 0)
1078*7c478bd9Sstevel@tonic-gate 
1079*7c478bd9Sstevel@tonic-gate #define	LDAP_SEARCHPREF_VERSION_ZERO    0
1080*7c478bd9Sstevel@tonic-gate #define	LDAP_SEARCHPREF_VERSION		1
1081*7c478bd9Sstevel@tonic-gate 
1082*7c478bd9Sstevel@tonic-gate #define	LDAP_SEARCHPREF_ERR_VERSION	1
1083*7c478bd9Sstevel@tonic-gate #define	LDAP_SEARCHPREF_ERR_MEM		2
1084*7c478bd9Sstevel@tonic-gate #define	LDAP_SEARCHPREF_ERR_SYNTAX	3
1085*7c478bd9Sstevel@tonic-gate #define	LDAP_SEARCHPREF_ERR_FILE	4
1086*7c478bd9Sstevel@tonic-gate 
1087*7c478bd9Sstevel@tonic-gate LDAP_API(int)
1088*7c478bd9Sstevel@tonic-gate LDAP_CALL
1089*7c478bd9Sstevel@tonic-gate ldap_init_searchprefs(char *file, struct ldap_searchobj **solistp);
1090*7c478bd9Sstevel@tonic-gate 
1091*7c478bd9Sstevel@tonic-gate LDAP_API(int)
1092*7c478bd9Sstevel@tonic-gate LDAP_CALL
1093*7c478bd9Sstevel@tonic-gate ldap_init_searchprefs_buf(char *buf, long buflen,
1094*7c478bd9Sstevel@tonic-gate 	struct ldap_searchobj **solistp);
1095*7c478bd9Sstevel@tonic-gate 
1096*7c478bd9Sstevel@tonic-gate LDAP_API(void)
1097*7c478bd9Sstevel@tonic-gate LDAP_CALL
1098*7c478bd9Sstevel@tonic-gate ldap_free_searchprefs(struct ldap_searchobj *solist);
1099*7c478bd9Sstevel@tonic-gate 
1100*7c478bd9Sstevel@tonic-gate LDAP_API(struct ldap_searchobj *)
1101*7c478bd9Sstevel@tonic-gate LDAP_CALL
1102*7c478bd9Sstevel@tonic-gate ldap_first_searchobj(struct ldap_searchobj *solist);
1103*7c478bd9Sstevel@tonic-gate 
1104*7c478bd9Sstevel@tonic-gate LDAP_API(struct ldap_searchobj *)
1105*7c478bd9Sstevel@tonic-gate LDAP_CALL
1106*7c478bd9Sstevel@tonic-gate ldap_next_searchobj(struct ldap_searchobj *sollist,
1107*7c478bd9Sstevel@tonic-gate struct ldap_searchobj *so);
1108*7c478bd9Sstevel@tonic-gate 
1109*7c478bd9Sstevel@tonic-gate /*
1110*7c478bd9Sstevel@tonic-gate  * specific LDAP instantiations of BER types we know about
1111*7c478bd9Sstevel@tonic-gate  */
1112*7c478bd9Sstevel@tonic-gate 
1113*7c478bd9Sstevel@tonic-gate /* general stuff */
1114*7c478bd9Sstevel@tonic-gate #define	LDAP_TAG_MESSAGE	0x30   /* tag is 16 + constructed bit */
1115*7c478bd9Sstevel@tonic-gate #define	LDAP_TAG_MSGID		0x02   /* INTEGER */
1116*7c478bd9Sstevel@tonic-gate #define	LDAP_TAG_CONTROLS	0xa0   /* context specific + constructed + 0 */
1117*7c478bd9Sstevel@tonic-gate #define	LDAP_TAG_REFERRAL	0xa3   /* context specific + constructed + 3 */
1118*7c478bd9Sstevel@tonic-gate #define	LDAP_TAG_NEWSUPERIOR    0x80   /* context specific + primitive + 0 */
1119*7c478bd9Sstevel@tonic-gate #define	LDAP_TAG_SASL_RES_CREDS 0x87   /* context specific + primitive + 7 */
1120*7c478bd9Sstevel@tonic-gate #define	LDAP_TAG_VLV_BY_INDEX   0xa0   /* context specific + constructed + 0 */
1121*7c478bd9Sstevel@tonic-gate #define	LDAP_TAG_VLV_BY_VALUE   0x81   /* context specific + primitive + 1 */
1122*7c478bd9Sstevel@tonic-gate /* tag for sort control */
1123*7c478bd9Sstevel@tonic-gate #define	LDAP_TAG_SK_MATCHRULE   0x80L   /* context specific + primitive + 0 */
1124*7c478bd9Sstevel@tonic-gate #define	LDAP_TAG_SK_REVERSE	0x81L   /* context specific + primitive + 1 */
1125*7c478bd9Sstevel@tonic-gate #define	LDAP_TAG_SR_ATTRTYPE    0x80L   /* context specific + primitive + 0 */
1126*7c478bd9Sstevel@tonic-gate 
1127*7c478bd9Sstevel@tonic-gate /* possible operations a client can invoke */
1128*7c478bd9Sstevel@tonic-gate #define	LDAP_REQ_BIND	0x60   /* application + constructed + 0 */
1129*7c478bd9Sstevel@tonic-gate #define	LDAP_REQ_UNBIND		0x42   /* application + primitive   + 2 */
1130*7c478bd9Sstevel@tonic-gate #define	LDAP_REQ_SEARCH		0x63   /* application + constructed + 3 */
1131*7c478bd9Sstevel@tonic-gate #define	LDAP_REQ_MODIFY		0x66   /* application + constructed + 6 */
1132*7c478bd9Sstevel@tonic-gate #define	LDAP_REQ_ADD		0x68   /* application + constructed + 8 */
1133*7c478bd9Sstevel@tonic-gate #define	LDAP_REQ_DELETE		0x4a   /* application + primitive   + 10 */
1134*7c478bd9Sstevel@tonic-gate #define	LDAP_REQ_MODRDN		0x6c   /* application + constructed + 12 */
1135*7c478bd9Sstevel@tonic-gate #define	LDAP_REQ_MODDN		0x6c   /* application + constructed + 12 */
1136*7c478bd9Sstevel@tonic-gate #define	LDAP_REQ_RENAME		0x6c   /* application + constructed + 12 */
1137*7c478bd9Sstevel@tonic-gate #define	LDAP_REQ_COMPARE	0x6e   /* application + constructed + 14 */
1138*7c478bd9Sstevel@tonic-gate #define	LDAP_REQ_ABANDON	0x50   /* application + primitive   + 16 */
1139*7c478bd9Sstevel@tonic-gate #define	LDAP_REQ_EXTENDED	0x77   /* application + constructed + 23 */
1140*7c478bd9Sstevel@tonic-gate 
1141*7c478bd9Sstevel@tonic-gate /* U-M LDAP release 3.0 compatibility stuff */
1142*7c478bd9Sstevel@tonic-gate #define	LDAP_REQ_UNBIND_30	0x62
1143*7c478bd9Sstevel@tonic-gate #define	LDAP_REQ_DELETE_30	0x6a
1144*7c478bd9Sstevel@tonic-gate #define	LDAP_REQ_ABANDON_30	0x70
1145*7c478bd9Sstevel@tonic-gate 
1146*7c478bd9Sstevel@tonic-gate /* U-M LDAP 3.0 compatibility auth methods */
1147*7c478bd9Sstevel@tonic-gate #define	LDAP_AUTH_SIMPLE_30	0xa0   /* context specific + constructed */
1148*7c478bd9Sstevel@tonic-gate #define	LDAP_AUTH_KRBV41_30	0xa1   /* context specific + constructed */
1149*7c478bd9Sstevel@tonic-gate #define	LDAP_AUTH_KRBV42_30	0xa2   /* context specific + constructed */
1150*7c478bd9Sstevel@tonic-gate 
1151*7c478bd9Sstevel@tonic-gate /* filter types */
1152*7c478bd9Sstevel@tonic-gate #define	LDAP_FILTER_AND		0xa0   /* context specific + constructed + 0 */
1153*7c478bd9Sstevel@tonic-gate #define	LDAP_FILTER_OR		0xa1   /* context specific + constructed + 1 */
1154*7c478bd9Sstevel@tonic-gate #define	LDAP_FILTER_NOT		0xa2   /* context specific + constructed + 2 */
1155*7c478bd9Sstevel@tonic-gate #define	LDAP_FILTER_EQUALITY	0xa3   /* context specific + constructed + 3 */
1156*7c478bd9Sstevel@tonic-gate #define	LDAP_FILTER_SUBSTRINGS	0xa4   /* context specific + constructed + 4 */
1157*7c478bd9Sstevel@tonic-gate #define	LDAP_FILTER_GE		0xa5   /* context specific + constructed + 5 */
1158*7c478bd9Sstevel@tonic-gate #define	LDAP_FILTER_LE		0xa6   /* context specific + constructed + 6 */
1159*7c478bd9Sstevel@tonic-gate #define	LDAP_FILTER_PRESENT	0x87   /* context specific + primitive   + 7 */
1160*7c478bd9Sstevel@tonic-gate #define	LDAP_FILTER_APPROX	0xa8   /* context specific + constructed + 8 */
1161*7c478bd9Sstevel@tonic-gate #define	LDAP_FILTER_EXTENDED	0xa9   /* context specific + constructed + 0 */
1162*7c478bd9Sstevel@tonic-gate 
1163*7c478bd9Sstevel@tonic-gate /* U-M LDAP 3.0 compatibility filter types */
1164*7c478bd9Sstevel@tonic-gate #define	LDAP_FILTER_PRESENT_30	0xa7   /* context specific + constructed */
1165*7c478bd9Sstevel@tonic-gate 
1166*7c478bd9Sstevel@tonic-gate /* substring filter component types */
1167*7c478bd9Sstevel@tonic-gate #define	LDAP_SUBSTRING_INITIAL	0x80   /* context specific + primitive + 0 */
1168*7c478bd9Sstevel@tonic-gate #define	LDAP_SUBSTRING_ANY	0x81   /* context specific + primitive + 1 */
1169*7c478bd9Sstevel@tonic-gate #define	LDAP_SUBSTRING_FINAL    0x82   /* context specific + primitive + 2 */
1170*7c478bd9Sstevel@tonic-gate 
1171*7c478bd9Sstevel@tonic-gate /* U-M LDAP 3.0 compatibility substring filter component types */
1172*7c478bd9Sstevel@tonic-gate #define	LDAP_SUBSTRING_INITIAL_30	0xa0   /* context specific */
1173*7c478bd9Sstevel@tonic-gate #define	LDAP_SUBSTRING_ANY_30		0xa1   /* context specific */
1174*7c478bd9Sstevel@tonic-gate #define	LDAP_SUBSTRING_FINAL_30		0xa2   /* context specific */
1175*7c478bd9Sstevel@tonic-gate 
1176*7c478bd9Sstevel@tonic-gate #endif	/* _SOLARIS_SDK */
1177*7c478bd9Sstevel@tonic-gate 
1178*7c478bd9Sstevel@tonic-gate /*
1179*7c478bd9Sstevel@tonic-gate  * Function to dispose of an array of LDAPMod structures (an API extension).
1180*7c478bd9Sstevel@tonic-gate  * Warning: don't use this unless the mods array was allocated using the
1181*7c478bd9Sstevel@tonic-gate  * same memory allocator as is being used by libldap.
1182*7c478bd9Sstevel@tonic-gate  */
1183*7c478bd9Sstevel@tonic-gate LDAP_API(void) LDAP_CALL ldap_mods_free(LDAPMod **mods, int freemods);
1184*7c478bd9Sstevel@tonic-gate 
1185*7c478bd9Sstevel@tonic-gate /*
1186*7c478bd9Sstevel@tonic-gate  * Preferred language and get_lang_values (an API extension --
1187*7c478bd9Sstevel@tonic-gate  * LDAP_API_FEATURE_X_GETLANGVALUES)
1188*7c478bd9Sstevel@tonic-gate  *
1189*7c478bd9Sstevel@tonic-gate  * The following two APIs are deprecated
1190*7c478bd9Sstevel@tonic-gate  */
1191*7c478bd9Sstevel@tonic-gate 
1192*7c478bd9Sstevel@tonic-gate char **LDAP_CALL ldap_get_lang_values(LDAP *ld, LDAPMessage *entry,
1193*7c478bd9Sstevel@tonic-gate 	const char *target, char **type);
1194*7c478bd9Sstevel@tonic-gate struct berval **LDAP_CALL ldap_get_lang_values_len(LDAP *ld,
1195*7c478bd9Sstevel@tonic-gate 	LDAPMessage *entry, const char *target, char **type);
1196*7c478bd9Sstevel@tonic-gate 
1197*7c478bd9Sstevel@tonic-gate 
1198*7c478bd9Sstevel@tonic-gate /*
1199*7c478bd9Sstevel@tonic-gate  * Rebind callback function (an API extension)
1200*7c478bd9Sstevel@tonic-gate  */
1201*7c478bd9Sstevel@tonic-gate #define	LDAP_OPT_REBIND_FN		0x06	/* 6 - API extension */
1202*7c478bd9Sstevel@tonic-gate #define	LDAP_OPT_REBIND_ARG		0x07	/* 7 - API extension */
1203*7c478bd9Sstevel@tonic-gate typedef int (LDAP_CALL LDAP_CALLBACK LDAP_REBINDPROC_CALLBACK)(LDAP *ld,
1204*7c478bd9Sstevel@tonic-gate 	char **dnp, char **passwdp, int *authmethodp, int freeit, void *arg);
1205*7c478bd9Sstevel@tonic-gate LDAP_API(void) LDAP_CALL ldap_set_rebind_proc(LDAP *ld,
1206*7c478bd9Sstevel@tonic-gate 	LDAP_REBINDPROC_CALLBACK *rebindproc, void *arg);
1207*7c478bd9Sstevel@tonic-gate 
1208*7c478bd9Sstevel@tonic-gate /*
1209*7c478bd9Sstevel@tonic-gate  * Thread function callbacks (an API extension --
1210*7c478bd9Sstevel@tonic-gate  * LDAP_API_FEATURE_X_THREAD_FUNCTIONS).
1211*7c478bd9Sstevel@tonic-gate  */
1212*7c478bd9Sstevel@tonic-gate #define	LDAP_OPT_THREAD_FN_PTRS		0x05	/* 5 - API extension */
1213*7c478bd9Sstevel@tonic-gate 
1214*7c478bd9Sstevel@tonic-gate /*
1215*7c478bd9Sstevel@tonic-gate  * Thread callback functions:
1216*7c478bd9Sstevel@tonic-gate  */
1217*7c478bd9Sstevel@tonic-gate typedef void *(LDAP_C LDAP_CALLBACK LDAP_TF_MUTEX_ALLOC_CALLBACK)(void);
1218*7c478bd9Sstevel@tonic-gate typedef void (LDAP_C LDAP_CALLBACK LDAP_TF_MUTEX_FREE_CALLBACK)(void *m);
1219*7c478bd9Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_TF_MUTEX_LOCK_CALLBACK)(void *m);
1220*7c478bd9Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_TF_MUTEX_UNLOCK_CALLBACK)(void *m);
1221*7c478bd9Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_TF_GET_ERRNO_CALLBACK)(void);
1222*7c478bd9Sstevel@tonic-gate typedef void (LDAP_C LDAP_CALLBACK LDAP_TF_SET_ERRNO_CALLBACK)(int e);
1223*7c478bd9Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_TF_GET_LDERRNO_CALLBACK)(
1224*7c478bd9Sstevel@tonic-gate 	char **matchedp, char **errmsgp, void *arg);
1225*7c478bd9Sstevel@tonic-gate typedef void    (LDAP_C LDAP_CALLBACK LDAP_TF_SET_LDERRNO_CALLBACK)(int err,
1226*7c478bd9Sstevel@tonic-gate 	char *matched, char *errmsg, void *arg);
1227*7c478bd9Sstevel@tonic-gate 
1228*7c478bd9Sstevel@tonic-gate /*
1229*7c478bd9Sstevel@tonic-gate  * Structure to hold thread function pointers:
1230*7c478bd9Sstevel@tonic-gate  */
1231*7c478bd9Sstevel@tonic-gate struct ldap_thread_fns {
1232*7c478bd9Sstevel@tonic-gate 	LDAP_TF_MUTEX_ALLOC_CALLBACK *ltf_mutex_alloc;
1233*7c478bd9Sstevel@tonic-gate 	LDAP_TF_MUTEX_FREE_CALLBACK *ltf_mutex_free;
1234*7c478bd9Sstevel@tonic-gate 	LDAP_TF_MUTEX_LOCK_CALLBACK *ltf_mutex_lock;
1235*7c478bd9Sstevel@tonic-gate 	LDAP_TF_MUTEX_UNLOCK_CALLBACK *ltf_mutex_unlock;
1236*7c478bd9Sstevel@tonic-gate 	LDAP_TF_GET_ERRNO_CALLBACK *ltf_get_errno;
1237*7c478bd9Sstevel@tonic-gate 	LDAP_TF_SET_ERRNO_CALLBACK *ltf_set_errno;
1238*7c478bd9Sstevel@tonic-gate 	LDAP_TF_GET_LDERRNO_CALLBACK *ltf_get_lderrno;
1239*7c478bd9Sstevel@tonic-gate 	LDAP_TF_SET_LDERRNO_CALLBACK *ltf_set_lderrno;
1240*7c478bd9Sstevel@tonic-gate 	void    *ltf_lderrno_arg;
1241*7c478bd9Sstevel@tonic-gate };
1242*7c478bd9Sstevel@tonic-gate 
1243*7c478bd9Sstevel@tonic-gate /*
1244*7c478bd9Sstevel@tonic-gate  * Client side sorting of entries (an API extension --
1245*7c478bd9Sstevel@tonic-gate  * LDAP_API_FEATURE_X_CLIENT_SIDE_SORT)
1246*7c478bd9Sstevel@tonic-gate  */
1247*7c478bd9Sstevel@tonic-gate /*
1248*7c478bd9Sstevel@tonic-gate  * Client side sorting callback functions:
1249*7c478bd9Sstevel@tonic-gate  */
1250*7c478bd9Sstevel@tonic-gate typedef const struct berval *(LDAP_C LDAP_CALLBACK
1251*7c478bd9Sstevel@tonic-gate 	LDAP_KEYGEN_CALLBACK)(void *arg, LDAP *ld, LDAPMessage *entry);
1252*7c478bd9Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK
1253*7c478bd9Sstevel@tonic-gate 	LDAP_KEYCMP_CALLBACK)(void *arg, const struct berval *,
1254*7c478bd9Sstevel@tonic-gate 	const struct berval *);
1255*7c478bd9Sstevel@tonic-gate typedef void (LDAP_C LDAP_CALLBACK
1256*7c478bd9Sstevel@tonic-gate 	LDAP_KEYFREE_CALLBACK)(void *arg, const struct berval *);
1257*7c478bd9Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK
1258*7c478bd9Sstevel@tonic-gate 	LDAP_CMP_CALLBACK)(const char *val1, const char *val2);
1259*7c478bd9Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK
1260*7c478bd9Sstevel@tonic-gate 	LDAP_VALCMP_CALLBACK)(const char **val1p, const char **val2p);
1261*7c478bd9Sstevel@tonic-gate 
1262*7c478bd9Sstevel@tonic-gate /*
1263*7c478bd9Sstevel@tonic-gate  * Client side sorting functions:
1264*7c478bd9Sstevel@tonic-gate  */
1265*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_multisort_entries(LDAP *ld, LDAPMessage **chain,
1266*7c478bd9Sstevel@tonic-gate 	char **attr, LDAP_CMP_CALLBACK *cmp);
1267*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_sort_entries(LDAP *ld, LDAPMessage **chain,
1268*7c478bd9Sstevel@tonic-gate 	char *attr, LDAP_CMP_CALLBACK *cmp);
1269*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_sort_values(LDAP *ld, char **vals,
1270*7c478bd9Sstevel@tonic-gate 	LDAP_VALCMP_CALLBACK *cmp);
1271*7c478bd9Sstevel@tonic-gate int LDAP_C LDAP_CALLBACK ldap_sort_strcasecmp(const char **a,
1272*7c478bd9Sstevel@tonic-gate 	const char **b);
1273*7c478bd9Sstevel@tonic-gate 
1274*7c478bd9Sstevel@tonic-gate 
1275*7c478bd9Sstevel@tonic-gate /*
1276*7c478bd9Sstevel@tonic-gate  * Filter functions and definitions (an API extension --
1277*7c478bd9Sstevel@tonic-gate  * LDAP_API_FEATURE_X_FILTER_FUNCTIONS)
1278*7c478bd9Sstevel@tonic-gate  */
1279*7c478bd9Sstevel@tonic-gate /*
1280*7c478bd9Sstevel@tonic-gate  * Structures, constants, and types for filter utility routines:
1281*7c478bd9Sstevel@tonic-gate  */
1282*7c478bd9Sstevel@tonic-gate typedef struct ldap_filt_info {
1283*7c478bd9Sstevel@tonic-gate 	char			*lfi_filter;
1284*7c478bd9Sstevel@tonic-gate 	char			*lfi_desc;
1285*7c478bd9Sstevel@tonic-gate 	int			lfi_scope;	/* LDAP_SCOPE_BASE, etc */
1286*7c478bd9Sstevel@tonic-gate 	int			lfi_isexact;    /* exact match filter? */
1287*7c478bd9Sstevel@tonic-gate 	struct ldap_filt_info   *lfi_next;
1288*7c478bd9Sstevel@tonic-gate } LDAPFiltInfo;
1289*7c478bd9Sstevel@tonic-gate 
1290*7c478bd9Sstevel@tonic-gate #define	LDAP_FILT_MAXSIZ	1024
1291*7c478bd9Sstevel@tonic-gate 
1292*7c478bd9Sstevel@tonic-gate typedef struct ldap_filt_list LDAPFiltList; /* opaque filter list handle */
1293*7c478bd9Sstevel@tonic-gate typedef struct ldap_filt_desc LDAPFiltDesc; /* opaque filter desc handle */
1294*7c478bd9Sstevel@tonic-gate 
1295*7c478bd9Sstevel@tonic-gate /*
1296*7c478bd9Sstevel@tonic-gate  * Filter utility functions:
1297*7c478bd9Sstevel@tonic-gate  */
1298*7c478bd9Sstevel@tonic-gate LDAP_API(LDAPFiltDesc *) LDAP_CALL ldap_init_getfilter(char *fname);
1299*7c478bd9Sstevel@tonic-gate LDAP_API(LDAPFiltDesc *) LDAP_CALL ldap_init_getfilter_buf(char *buf,
1300*7c478bd9Sstevel@tonic-gate 	ssize_t buflen);
1301*7c478bd9Sstevel@tonic-gate LDAP_API(LDAPFiltInfo *) LDAP_CALL ldap_getfirstfilter(LDAPFiltDesc *lfdp,
1302*7c478bd9Sstevel@tonic-gate 	char *tagpat, char *value);
1303*7c478bd9Sstevel@tonic-gate LDAP_API(LDAPFiltInfo *) LDAP_CALL ldap_getnextfilter(LDAPFiltDesc *lfdp);
1304*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_set_filter_additions(LDAPFiltDesc *lfdp,
1305*7c478bd9Sstevel@tonic-gate 	char *prefix, char *suffix);
1306*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_create_filter(char *buf, unsigned long buflen,
1307*7c478bd9Sstevel@tonic-gate 	char *pattern, char *prefix, char *suffix, char *attr,
1308*7c478bd9Sstevel@tonic-gate 	char *value, char **valwords);
1309*7c478bd9Sstevel@tonic-gate LDAP_API(void) LDAP_CALL ldap_getfilter_free(LDAPFiltDesc *lfdp);
1310*7c478bd9Sstevel@tonic-gate 
1311*7c478bd9Sstevel@tonic-gate 
1312*7c478bd9Sstevel@tonic-gate /*
1313*7c478bd9Sstevel@tonic-gate  * Friendly mapping structure and routines (an API extension)
1314*7c478bd9Sstevel@tonic-gate  */
1315*7c478bd9Sstevel@tonic-gate typedef struct friendly {
1316*7c478bd9Sstevel@tonic-gate 	char    *f_unfriendly;
1317*7c478bd9Sstevel@tonic-gate 	char    *f_friendly;
1318*7c478bd9Sstevel@tonic-gate } *FriendlyMap;
1319*7c478bd9Sstevel@tonic-gate char *LDAP_CALL ldap_friendly_name(char *filename, char *name,
1320*7c478bd9Sstevel@tonic-gate 	FriendlyMap *map);
1321*7c478bd9Sstevel@tonic-gate LDAP_API(void) LDAP_CALL ldap_free_friendlymap(FriendlyMap *map);
1322*7c478bd9Sstevel@tonic-gate 
1323*7c478bd9Sstevel@tonic-gate 
1324*7c478bd9Sstevel@tonic-gate /*
1325*7c478bd9Sstevel@tonic-gate  * In Memory Cache (an API extension -- LDAP_API_FEATURE_X_MEMCACHE)
1326*7c478bd9Sstevel@tonic-gate  */
1327*7c478bd9Sstevel@tonic-gate typedef struct ldapmemcache  LDAPMemCache;  /* opaque in-memory cache handle */
1328*7c478bd9Sstevel@tonic-gate 
1329*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_memcache_init(unsigned long ttl,
1330*7c478bd9Sstevel@tonic-gate 	unsigned long size, char **baseDNs, struct ldap_thread_fns *thread_fns,
1331*7c478bd9Sstevel@tonic-gate 	LDAPMemCache **cachep);
1332*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_memcache_set(LDAP *ld, LDAPMemCache *cache);
1333*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_memcache_get(LDAP *ld, LDAPMemCache **cachep);
1334*7c478bd9Sstevel@tonic-gate LDAP_API(void) LDAP_CALL ldap_memcache_flush(LDAPMemCache *cache, char *dn,
1335*7c478bd9Sstevel@tonic-gate 	int scope);
1336*7c478bd9Sstevel@tonic-gate LDAP_API(void) LDAP_CALL ldap_memcache_destroy(LDAPMemCache *cache);
1337*7c478bd9Sstevel@tonic-gate LDAP_API(void) LDAP_CALL ldap_memcache_update(LDAPMemCache *cache);
1338*7c478bd9Sstevel@tonic-gate 
1339*7c478bd9Sstevel@tonic-gate /*
1340*7c478bd9Sstevel@tonic-gate  * Server reconnect (an API extension).
1341*7c478bd9Sstevel@tonic-gate  */
1342*7c478bd9Sstevel@tonic-gate #define	LDAP_OPT_RECONNECT		0x62    /* 98 - API extension */
1343*7c478bd9Sstevel@tonic-gate 
1344*7c478bd9Sstevel@tonic-gate /*
1345*7c478bd9Sstevel@tonic-gate  * Asynchronous I/O (an API extension).
1346*7c478bd9Sstevel@tonic-gate  */
1347*7c478bd9Sstevel@tonic-gate /*
1348*7c478bd9Sstevel@tonic-gate  * This option enables completely asynchronous IO.  It works by using ioctl()
1349*7c478bd9Sstevel@tonic-gate  * on the fd, (or tlook())
1350*7c478bd9Sstevel@tonic-gate  */
1351*7c478bd9Sstevel@tonic-gate #define	LDAP_OPT_ASYNC_CONNECT		0x63    /* 99 - API extension */
1352*7c478bd9Sstevel@tonic-gate 
1353*7c478bd9Sstevel@tonic-gate /*
1354*7c478bd9Sstevel@tonic-gate  * I/O function callbacks option (an API extension --
1355*7c478bd9Sstevel@tonic-gate  * LDAP_API_FEATURE_X_IO_FUNCTIONS).
1356*7c478bd9Sstevel@tonic-gate  * Use of the extended I/O functions instead is recommended; see above.
1357*7c478bd9Sstevel@tonic-gate  */
1358*7c478bd9Sstevel@tonic-gate #define	LDAP_OPT_IO_FN_PTRS		0x0B    /* 11 - API extension */
1359*7c478bd9Sstevel@tonic-gate 
1360*7c478bd9Sstevel@tonic-gate /*
1361*7c478bd9Sstevel@tonic-gate  * Extended I/O function callbacks option (an API extension --
1362*7c478bd9Sstevel@tonic-gate  * LDAP_API_FEATURE_X_EXTIO_FUNCTIONS).
1363*7c478bd9Sstevel@tonic-gate  */
1364*7c478bd9Sstevel@tonic-gate #define	LDAP_X_OPT_EXTIO_FN_PTRS   (LDAP_OPT_PRIVATE_EXTENSION_BASE + 0x0F00)
1365*7c478bd9Sstevel@tonic-gate 	/* 0x4000 + 0x0F00 = 0x4F00 = 20224 - API extension */
1366*7c478bd9Sstevel@tonic-gate 
1367*7c478bd9Sstevel@tonic-gate 
1368*7c478bd9Sstevel@tonic-gate 
1369*7c478bd9Sstevel@tonic-gate /*
1370*7c478bd9Sstevel@tonic-gate  * generalized bind
1371*7c478bd9Sstevel@tonic-gate  */
1372*7c478bd9Sstevel@tonic-gate /*
1373*7c478bd9Sstevel@tonic-gate  * Authentication methods:
1374*7c478bd9Sstevel@tonic-gate  */
1375*7c478bd9Sstevel@tonic-gate #define	LDAP_AUTH_NONE		0x00
1376*7c478bd9Sstevel@tonic-gate #define	LDAP_AUTH_SIMPLE	0x80
1377*7c478bd9Sstevel@tonic-gate #define	LDAP_AUTH_SASL		0xa3
1378*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_bind(LDAP *ld, const char *who,
1379*7c478bd9Sstevel@tonic-gate 	const char *passwd, int authmethod);
1380*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_bind_s(LDAP *ld, const char *who,
1381*7c478bd9Sstevel@tonic-gate 	const char *cred, int method);
1382*7c478bd9Sstevel@tonic-gate 
1383*7c478bd9Sstevel@tonic-gate /*
1384*7c478bd9Sstevel@tonic-gate  * experimental DN format support
1385*7c478bd9Sstevel@tonic-gate  */
1386*7c478bd9Sstevel@tonic-gate char **LDAP_CALL ldap_explode_dns(const char *dn);
1387*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_is_dns_dn(const char *dn);
1388*7c478bd9Sstevel@tonic-gate 
1389*7c478bd9Sstevel@tonic-gate #ifdef	_SOLARIS_SDK
1390*7c478bd9Sstevel@tonic-gate char *ldap_dns_to_dn(char *dns_name, int *nameparts);
1391*7c478bd9Sstevel@tonic-gate #endif
1392*7c478bd9Sstevel@tonic-gate 
1393*7c478bd9Sstevel@tonic-gate 
1394*7c478bd9Sstevel@tonic-gate /*
1395*7c478bd9Sstevel@tonic-gate  * user friendly naming/searching routines
1396*7c478bd9Sstevel@tonic-gate  */
1397*7c478bd9Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_CANCELPROC_CALLBACK)(void *cl);
1398*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_ufn_search_c(LDAP *ld, char *ufn,
1399*7c478bd9Sstevel@tonic-gate 	char **attrs, int attrsonly, LDAPMessage **res,
1400*7c478bd9Sstevel@tonic-gate 	LDAP_CANCELPROC_CALLBACK *cancelproc, void *cancelparm);
1401*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_ufn_search_ct(LDAP *ld, char *ufn,
1402*7c478bd9Sstevel@tonic-gate 	char **attrs, int attrsonly, LDAPMessage **res,
1403*7c478bd9Sstevel@tonic-gate 	LDAP_CANCELPROC_CALLBACK *cancelproc, void *cancelparm,
1404*7c478bd9Sstevel@tonic-gate 	char *tag1, char *tag2, char *tag3);
1405*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_ufn_search_s(LDAP *ld, char *ufn,
1406*7c478bd9Sstevel@tonic-gate 	char **attrs, int attrsonly, LDAPMessage **res);
1407*7c478bd9Sstevel@tonic-gate LDAP_API(LDAPFiltDesc *) LDAP_CALL ldap_ufn_setfilter(LDAP *ld, char *fname);
1408*7c478bd9Sstevel@tonic-gate LDAP_API(void) LDAP_CALL ldap_ufn_setprefix(LDAP *ld, char *prefix);
1409*7c478bd9Sstevel@tonic-gate int LDAP_C ldap_ufn_timeout(void *tvparam);
1410*7c478bd9Sstevel@tonic-gate 
1411*7c478bd9Sstevel@tonic-gate /*
1412*7c478bd9Sstevel@tonic-gate  * functions and definitions that have been replaced by new improved ones
1413*7c478bd9Sstevel@tonic-gate  */
1414*7c478bd9Sstevel@tonic-gate /*
1415*7c478bd9Sstevel@tonic-gate  * Use ldap_get_option() with LDAP_OPT_API_INFO and an LDAPAPIInfo structure
1416*7c478bd9Sstevel@tonic-gate  * instead of ldap_version(). The use of this API is deprecated.
1417*7c478bd9Sstevel@tonic-gate  */
1418*7c478bd9Sstevel@tonic-gate typedef struct _LDAPVersion {
1419*7c478bd9Sstevel@tonic-gate 	int sdk_version;	/* Version of the SDK, * 100 */
1420*7c478bd9Sstevel@tonic-gate 	int protocol_version;	/* Highest protocol version supported, * 100 */
1421*7c478bd9Sstevel@tonic-gate 	int SSL_version;	/* SSL version if this SDK supports it, * 100 */
1422*7c478bd9Sstevel@tonic-gate 	int security_level;	/* highest level available */
1423*7c478bd9Sstevel@tonic-gate 	int reserved[4];
1424*7c478bd9Sstevel@tonic-gate } LDAPVersion;
1425*7c478bd9Sstevel@tonic-gate #define	LDAP_SECURITY_NONE	0
1426*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_version(LDAPVersion *ver);
1427*7c478bd9Sstevel@tonic-gate 
1428*7c478bd9Sstevel@tonic-gate /* use ldap_create_filter() instead of ldap_build_filter() */
1429*7c478bd9Sstevel@tonic-gate LDAP_API(void) LDAP_CALL ldap_build_filter(char *buf, size_t buflen,
1430*7c478bd9Sstevel@tonic-gate 	char *pattern, char *prefix, char *suffix, char *attr,
1431*7c478bd9Sstevel@tonic-gate 	char *value, char **valwords);
1432*7c478bd9Sstevel@tonic-gate /* use ldap_set_filter_additions() instead of ldap_setfilteraffixes() */
1433*7c478bd9Sstevel@tonic-gate LDAP_API(void) LDAP_CALL ldap_setfilteraffixes(LDAPFiltDesc *lfdp,
1434*7c478bd9Sstevel@tonic-gate 	char *prefix, char *suffix);
1435*7c478bd9Sstevel@tonic-gate 
1436*7c478bd9Sstevel@tonic-gate /* older result types a server can return -- use LDAP_RES_MODDN instead */
1437*7c478bd9Sstevel@tonic-gate #define	LDAP_RES_MODRDN			LDAP_RES_MODDN
1438*7c478bd9Sstevel@tonic-gate #define	LDAP_RES_RENAME			LDAP_RES_MODDN
1439*7c478bd9Sstevel@tonic-gate 
1440*7c478bd9Sstevel@tonic-gate /* older error messages */
1441*7c478bd9Sstevel@tonic-gate #define	LDAP_AUTH_METHOD_NOT_SUPPORTED  LDAP_STRONG_AUTH_NOT_SUPPORTED
1442*7c478bd9Sstevel@tonic-gate 
1443*7c478bd9Sstevel@tonic-gate /* end of unsupported functions */
1444*7c478bd9Sstevel@tonic-gate 
1445*7c478bd9Sstevel@tonic-gate #ifdef	_SOLARIS_SDK
1446*7c478bd9Sstevel@tonic-gate 
1447*7c478bd9Sstevel@tonic-gate /* SSL Functions */
1448*7c478bd9Sstevel@tonic-gate 
1449*7c478bd9Sstevel@tonic-gate /*
1450*7c478bd9Sstevel@tonic-gate  * these three defines resolve the SSL strength
1451*7c478bd9Sstevel@tonic-gate  * setting auth weak, diables all cert checking
1452*7c478bd9Sstevel@tonic-gate  * the CNCHECK tests for the man in the middle hack
1453*7c478bd9Sstevel@tonic-gate  */
1454*7c478bd9Sstevel@tonic-gate #define	LDAPSSL_AUTH_WEAK	0
1455*7c478bd9Sstevel@tonic-gate #define	LDAPSSL_AUTH_CERT	1
1456*7c478bd9Sstevel@tonic-gate #define	LDAPSSL_AUTH_CNCHECK    2
1457*7c478bd9Sstevel@tonic-gate 
1458*7c478bd9Sstevel@tonic-gate /*
1459*7c478bd9Sstevel@tonic-gate  * Initialize LDAP library for SSL
1460*7c478bd9Sstevel@tonic-gate  */
1461*7c478bd9Sstevel@tonic-gate LDAP * LDAP_CALL ldapssl_init(const char *defhost, int defport,
1462*7c478bd9Sstevel@tonic-gate 	int defsecure);
1463*7c478bd9Sstevel@tonic-gate 
1464*7c478bd9Sstevel@tonic-gate /*
1465*7c478bd9Sstevel@tonic-gate  * Install I/O routines to make SSL over LDAP possible.
1466*7c478bd9Sstevel@tonic-gate  * Use this after ldap_init() or just use ldapssl_init() instead.
1467*7c478bd9Sstevel@tonic-gate  */
1468*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldapssl_install_routines(LDAP *ld);
1469*7c478bd9Sstevel@tonic-gate 
1470*7c478bd9Sstevel@tonic-gate 
1471*7c478bd9Sstevel@tonic-gate /*
1472*7c478bd9Sstevel@tonic-gate  * The next three functions initialize the security code for SSL
1473*7c478bd9Sstevel@tonic-gate  * The first one ldapssl_client_init() does initialization for SSL only
1474*7c478bd9Sstevel@tonic-gate  * The next one supports ldapssl_clientauth_init() intializes security
1475*7c478bd9Sstevel@tonic-gate  * for SSL for client authentication. The third function initializes
1476*7c478bd9Sstevel@tonic-gate  * security for doing SSL with client authentication, and PKCS, that is,
1477*7c478bd9Sstevel@tonic-gate  * the third function initializes the security module database(secmod.db).
1478*7c478bd9Sstevel@tonic-gate  * The parameters are as follows:
1479*7c478bd9Sstevel@tonic-gate  * const char *certdbpath - path to the cert file.  This can be a shortcut
1480*7c478bd9Sstevel@tonic-gate  * to the directory name, if so cert7.db will be postfixed to the string.
1481*7c478bd9Sstevel@tonic-gate  * void *certdbhandle - Normally this is NULL.  This memory will need
1482*7c478bd9Sstevel@tonic-gate  * to be freed.
1483*7c478bd9Sstevel@tonic-gate  * int needkeydb - boolean.  Must be ! = 0 if client Authentification
1484*7c478bd9Sstevel@tonic-gate  * is required
1485*7c478bd9Sstevel@tonic-gate  * char *keydbpath - path to the key database.  This can be a shortcut
1486*7c478bd9Sstevel@tonic-gate  * to the directory name, if so key3.db will be postfixed to the string.
1487*7c478bd9Sstevel@tonic-gate  * void *keydbhandle - Normally this is NULL, This memory will need
1488*7c478bd9Sstevel@tonic-gate  * to be freed
1489*7c478bd9Sstevel@tonic-gate  * int needsecmoddb - boolean.  Must be ! = 0 to assure that the correct
1490*7c478bd9Sstevel@tonic-gate  * security module is loaded into memory
1491*7c478bd9Sstevel@tonic-gate  * char *secmodpath - path to the secmod.  This can be a shortcut to the
1492*7c478bd9Sstevel@tonic-gate  * directory name, if so secmod.db will be postfixed to the string.
1493*7c478bd9Sstevel@tonic-gate  *
1494*7c478bd9Sstevel@tonic-gate  * These three functions are mutually exclusive.  You can only call
1495*7c478bd9Sstevel@tonic-gate  * one.  This means that, for a given process, you must call the
1496*7c478bd9Sstevel@tonic-gate  * appropriate initialization function for the life of the process.
1497*7c478bd9Sstevel@tonic-gate  */
1498*7c478bd9Sstevel@tonic-gate 
1499*7c478bd9Sstevel@tonic-gate 
1500*7c478bd9Sstevel@tonic-gate /*
1501*7c478bd9Sstevel@tonic-gate  * Initialize the secure parts (Security and SSL) of the runtime for use
1502*7c478bd9Sstevel@tonic-gate  * by a client application.  This is only called once.
1503*7c478bd9Sstevel@tonic-gate  */
1504*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldapssl_client_init(
1505*7c478bd9Sstevel@tonic-gate     const char *certdbpath, void *certdbhandle);
1506*7c478bd9Sstevel@tonic-gate 
1507*7c478bd9Sstevel@tonic-gate /*
1508*7c478bd9Sstevel@tonic-gate  * Initialize the secure parts (Security and SSL) of the runtime for use
1509*7c478bd9Sstevel@tonic-gate  * by a client application that may want to do SSL client authentication.
1510*7c478bd9Sstevel@tonic-gate  */
1511*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldapssl_clientauth_init(
1512*7c478bd9Sstevel@tonic-gate     const char *certdbpath, void *certdbhandle,
1513*7c478bd9Sstevel@tonic-gate     const int needkeydb, const char *keydbpath, void *keydbhandle);
1514*7c478bd9Sstevel@tonic-gate 
1515*7c478bd9Sstevel@tonic-gate /*
1516*7c478bd9Sstevel@tonic-gate  * Initialize the secure parts (Security and SSL) of the runtime for use
1517*7c478bd9Sstevel@tonic-gate  * by a client application that may want to do SSL client authentication.
1518*7c478bd9Sstevel@tonic-gate  */
1519*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldapssl_advclientauth_init(
1520*7c478bd9Sstevel@tonic-gate     const char *certdbpath, void *certdbhandle,
1521*7c478bd9Sstevel@tonic-gate     const int needkeydb, const char *keydbpath, void *keydbhandle,
1522*7c478bd9Sstevel@tonic-gate     const int needsecmoddb, const char *secmoddbpath,
1523*7c478bd9Sstevel@tonic-gate     const int sslstrength);
1524*7c478bd9Sstevel@tonic-gate 
1525*7c478bd9Sstevel@tonic-gate /*
1526*7c478bd9Sstevel@tonic-gate  * get a meaningful error string back from the security library
1527*7c478bd9Sstevel@tonic-gate  * this function should be called, if ldap_err2string doesn't
1528*7c478bd9Sstevel@tonic-gate  * identify the error code.
1529*7c478bd9Sstevel@tonic-gate  */
1530*7c478bd9Sstevel@tonic-gate const char *LDAP_CALL ldapssl_err2string(const int prerrno);
1531*7c478bd9Sstevel@tonic-gate 
1532*7c478bd9Sstevel@tonic-gate /*
1533*7c478bd9Sstevel@tonic-gate  * Enable SSL client authentication on the given ld.
1534*7c478bd9Sstevel@tonic-gate  */
1535*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldapssl_enable_clientauth(LDAP *ld, char *keynickname,
1536*7c478bd9Sstevel@tonic-gate 	char *keypasswd, char *certnickname);
1537*7c478bd9Sstevel@tonic-gate 
1538*7c478bd9Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_PKCS_GET_TOKEN_CALLBACK)
1539*7c478bd9Sstevel@tonic-gate 	(void *context, char **tokenname);
1540*7c478bd9Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_PKCS_GET_PIN_CALLBACK)
1541*7c478bd9Sstevel@tonic-gate 	(void *context, const char *tokenname, char **tokenpin);
1542*7c478bd9Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_PKCS_GET_CERTPATH_CALLBACK)
1543*7c478bd9Sstevel@tonic-gate 	(void *context, char **certpath);
1544*7c478bd9Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_PKCS_GET_KEYPATH_CALLBACK)
1545*7c478bd9Sstevel@tonic-gate 	(void *context, char **keypath);
1546*7c478bd9Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_PKCS_GET_MODPATH_CALLBACK)
1547*7c478bd9Sstevel@tonic-gate 	(void *context, char **modulepath);
1548*7c478bd9Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_PKCS_GET_CERTNAME_CALLBACK)
1549*7c478bd9Sstevel@tonic-gate 	(void *context, char **certname);
1550*7c478bd9Sstevel@tonic-gate typedef int (LDAP_C LDAP_CALLBACK LDAP_PKCS_GET_DONGLEFILENAME_CALLBACK)
1551*7c478bd9Sstevel@tonic-gate 	(void *context, char **filename);
1552*7c478bd9Sstevel@tonic-gate 
1553*7c478bd9Sstevel@tonic-gate #define	PKCS_STRUCTURE_ID 1
1554*7c478bd9Sstevel@tonic-gate struct ldapssl_pkcs_fns {
1555*7c478bd9Sstevel@tonic-gate     int local_structure_id;
1556*7c478bd9Sstevel@tonic-gate     void *local_data;
1557*7c478bd9Sstevel@tonic-gate     LDAP_PKCS_GET_CERTPATH_CALLBACK *pkcs_getcertpath;
1558*7c478bd9Sstevel@tonic-gate     LDAP_PKCS_GET_CERTNAME_CALLBACK *pkcs_getcertname;
1559*7c478bd9Sstevel@tonic-gate     LDAP_PKCS_GET_KEYPATH_CALLBACK *pkcs_getkeypath;
1560*7c478bd9Sstevel@tonic-gate     LDAP_PKCS_GET_MODPATH_CALLBACK *pkcs_getmodpath;
1561*7c478bd9Sstevel@tonic-gate     LDAP_PKCS_GET_PIN_CALLBACK *pkcs_getpin;
1562*7c478bd9Sstevel@tonic-gate     LDAP_PKCS_GET_TOKEN_CALLBACK *pkcs_gettokenname;
1563*7c478bd9Sstevel@tonic-gate     LDAP_PKCS_GET_DONGLEFILENAME_CALLBACK *pkcs_getdonglefilename;
1564*7c478bd9Sstevel@tonic-gate 
1565*7c478bd9Sstevel@tonic-gate };
1566*7c478bd9Sstevel@tonic-gate 
1567*7c478bd9Sstevel@tonic-gate 
1568*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldapssl_pkcs_init(const struct ldapssl_pkcs_fns *pfns);
1569*7c478bd9Sstevel@tonic-gate 
1570*7c478bd9Sstevel@tonic-gate /* end of SSL functions */
1571*7c478bd9Sstevel@tonic-gate #endif	/* _SOLARIS_SDK */
1572*7c478bd9Sstevel@tonic-gate 
1573*7c478bd9Sstevel@tonic-gate /* SASL options */
1574*7c478bd9Sstevel@tonic-gate #define	LDAP_OPT_X_SASL_MECH		0x6100
1575*7c478bd9Sstevel@tonic-gate #define	LDAP_OPT_X_SASL_REALM		0x6101
1576*7c478bd9Sstevel@tonic-gate #define	LDAP_OPT_X_SASL_AUTHCID		0x6102
1577*7c478bd9Sstevel@tonic-gate #define	LDAP_OPT_X_SASL_AUTHZID		0x6103
1578*7c478bd9Sstevel@tonic-gate #define	LDAP_OPT_X_SASL_SSF		0x6104 /* read-only */
1579*7c478bd9Sstevel@tonic-gate #define	LDAP_OPT_X_SASL_SSF_EXTERNAL	0x6105 /* write-only */
1580*7c478bd9Sstevel@tonic-gate #define	LDAP_OPT_X_SASL_SECPROPS	0x6106 /* write-only */
1581*7c478bd9Sstevel@tonic-gate #define	LDAP_OPT_X_SASL_SSF_MIN		0x6107
1582*7c478bd9Sstevel@tonic-gate #define	LDAP_OPT_X_SASL_SSF_MAX		0x6108
1583*7c478bd9Sstevel@tonic-gate #define	LDAP_OPT_X_SASL_MAXBUFSIZE	0x6109
1584*7c478bd9Sstevel@tonic-gate 
1585*7c478bd9Sstevel@tonic-gate /*
1586*7c478bd9Sstevel@tonic-gate  * ldap_interactive_bind_s Interaction flags
1587*7c478bd9Sstevel@tonic-gate  *  Interactive: prompt always - REQUIRED
1588*7c478bd9Sstevel@tonic-gate  */
1589*7c478bd9Sstevel@tonic-gate #define	LDAP_SASL_INTERACTIVE		1U
1590*7c478bd9Sstevel@tonic-gate 
1591*7c478bd9Sstevel@tonic-gate /*
1592*7c478bd9Sstevel@tonic-gate  * V3 SASL Interaction Function Callback Prototype
1593*7c478bd9Sstevel@tonic-gate  *      when using SASL, interact is pointer to sasl_interact_t
1594*7c478bd9Sstevel@tonic-gate  *  should likely passed in a control (and provided controls)
1595*7c478bd9Sstevel@tonic-gate  */
1596*7c478bd9Sstevel@tonic-gate typedef int (LDAP_SASL_INTERACT_PROC)
1597*7c478bd9Sstevel@tonic-gate 	(LDAP *ld, unsigned flags, void* defaults, void *interact);
1598*7c478bd9Sstevel@tonic-gate 
1599*7c478bd9Sstevel@tonic-gate int LDAP_CALL ldap_sasl_interactive_bind_s(LDAP *ld, const char *dn,
1600*7c478bd9Sstevel@tonic-gate 	const char *saslMechanism, LDAPControl **serverControls,
1601*7c478bd9Sstevel@tonic-gate 	LDAPControl **clientControls, unsigned flags,
1602*7c478bd9Sstevel@tonic-gate 	LDAP_SASL_INTERACT_PROC *proc, void *defaults);
1603*7c478bd9Sstevel@tonic-gate 
1604*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1605*7c478bd9Sstevel@tonic-gate }
1606*7c478bd9Sstevel@tonic-gate #endif
1607*7c478bd9Sstevel@tonic-gate 
1608*7c478bd9Sstevel@tonic-gate #endif	/* _LDAP_H */
1609