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