xref: /onnv-gate/usr/src/lib/libldap4/include/ldap.h (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * Copyright (c) 2001 by Sun Microsystems, Inc.
3*0Sstevel@tonic-gate  * All rights reserved.
4*0Sstevel@tonic-gate  */
5*0Sstevel@tonic-gate 
6*0Sstevel@tonic-gate /*
7*0Sstevel@tonic-gate  * Copyright (c) 1990 Regents of the University of Michigan.
8*0Sstevel@tonic-gate  * All rights reserved.
9*0Sstevel@tonic-gate  *
10*0Sstevel@tonic-gate  * Redistribution and use in source and binary forms are permitted
11*0Sstevel@tonic-gate  * provided that this notice is preserved and that due credit is given
12*0Sstevel@tonic-gate  * to the University of Michigan at Ann Arbor. The name of the University
13*0Sstevel@tonic-gate  * may not be used to endorse or promote products derived from this
14*0Sstevel@tonic-gate  * software without specific prior written permission. This software
15*0Sstevel@tonic-gate  * is provided ``as is'' without express or implied warranty.
16*0Sstevel@tonic-gate  */
17*0Sstevel@tonic-gate 
18*0Sstevel@tonic-gate #ifndef _LDAP_H
19*0Sstevel@tonic-gate #define	_LDAP_H
20*0Sstevel@tonic-gate 
21*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
22*0Sstevel@tonic-gate 
23*0Sstevel@tonic-gate #ifdef __cplusplus
24*0Sstevel@tonic-gate extern "C" {
25*0Sstevel@tonic-gate #endif
26*0Sstevel@tonic-gate 
27*0Sstevel@tonic-gate #ifdef LDAP_SSL
28*0Sstevel@tonic-gate #include <security/ssl.h>
29*0Sstevel@tonic-gate #endif /* LDAP_SSL */
30*0Sstevel@tonic-gate 
31*0Sstevel@tonic-gate 
32*0Sstevel@tonic-gate #include <pthread.h>
33*0Sstevel@tonic-gate 
34*0Sstevel@tonic-gate #ifdef LDAP_SSL
35*0Sstevel@tonic-gate #define	SSL_LDAP_PORT 636
36*0Sstevel@tonic-gate #endif
37*0Sstevel@tonic-gate 
38*0Sstevel@tonic-gate #if !defined(NEEDPROTOS) && defined(__STDC__)
39*0Sstevel@tonic-gate #define	NEEDPROTOS	1
40*0Sstevel@tonic-gate #endif
41*0Sstevel@tonic-gate 
42*0Sstevel@tonic-gate #define	LDAP_API_VERSION	2004
43*0Sstevel@tonic-gate #define	LDAP_VERSION_MIN	2
44*0Sstevel@tonic-gate #define	LDAP_VERSION_MAX	3
45*0Sstevel@tonic-gate #define	LDAP_VENDOR_NAME	"Sun Microsystems Inc."
46*0Sstevel@tonic-gate #define	LDAP_VENDOR_VERSION	400
47*0Sstevel@tonic-gate 
48*0Sstevel@tonic-gate #define	LDAP_PORT	389
49*0Sstevel@tonic-gate #define	LDAP_VERSION1	1
50*0Sstevel@tonic-gate #define	LDAP_VERSION2	2
51*0Sstevel@tonic-gate #define	LDAP_VERSION3	3
52*0Sstevel@tonic-gate #define	LDAP_VERSION	LDAP_VERSION2
53*0Sstevel@tonic-gate 
54*0Sstevel@tonic-gate /* OPTIONS to use with ldap_set_option and ldap_get_option */
55*0Sstevel@tonic-gate #define	LDAP_OPT_API_INFO	0x00
56*0Sstevel@tonic-gate #define	LDAP_OPT_DESC	0x01	/* Use of this option is depricated */
57*0Sstevel@tonic-gate /* int, control how aliases are handled during search */
58*0Sstevel@tonic-gate #define	LDAP_OPT_DEREF	0x02
59*0Sstevel@tonic-gate /* Deref values */
60*0Sstevel@tonic-gate #define	LDAP_DEREF_NEVER	0x00
61*0Sstevel@tonic-gate #define	LDAP_DEREF_SEARCHING	0x01
62*0Sstevel@tonic-gate #define	LDAP_DEREF_FINDING	0x02
63*0Sstevel@tonic-gate #define	LDAP_DEREF_ALWAYS	0x03
64*0Sstevel@tonic-gate 
65*0Sstevel@tonic-gate #define	LDAP_OPT_SIZELIMIT	0x03	/* int, size limit of a search */
66*0Sstevel@tonic-gate #define	LDAP_OPT_TIMELIMIT	0x04	/* int, time limit of a search */
67*0Sstevel@tonic-gate #define	LDAP_OPT_REBIND_FN	0x06	/* Use of this options is depricated */
68*0Sstevel@tonic-gate #define	LDAP_OPT_REBIND_ARG	0x07	/* Use of this options is depricated */
69*0Sstevel@tonic-gate #define	LDAP_OPT_REFERRALS	0x08	/* ON/OFF, chase referrals */
70*0Sstevel@tonic-gate #define	LDAP_OPT_RESTART	0x09	/* ON/OFF, restart if EINTR occurs */
71*0Sstevel@tonic-gate /* int, protocol version, default 2 */
72*0Sstevel@tonic-gate #define	LDAP_OPT_PROTOCOL_VERSION	0x11
73*0Sstevel@tonic-gate /* List of ldap controls to be sent with each request */
74*0Sstevel@tonic-gate #define	LDAP_OPT_SERVER_CONTROLS	0x12
75*0Sstevel@tonic-gate /* List of ldap controls that affect the session */
76*0Sstevel@tonic-gate #define	LDAP_OPT_CLIENT_CONTROLS	0x13
77*0Sstevel@tonic-gate #define	LDAP_OPT_API_FEATURE_INFO	0x15
78*0Sstevel@tonic-gate /* The hostname of the default ldap server */
79*0Sstevel@tonic-gate #define	LDAP_OPT_HOST_NAME	0x30
80*0Sstevel@tonic-gate /* The code of the most recent ldap error that occured for this session */
81*0Sstevel@tonic-gate #define	LDAP_OPT_ERROR_NUMBER	0x31
82*0Sstevel@tonic-gate /* The message returned with the most recent ldap error */
83*0Sstevel@tonic-gate #define	LDAP_OPT_ERROR_STRING	0x32
84*0Sstevel@tonic-gate /* The Matching DN in case of a naming error */
85*0Sstevel@tonic-gate #define	LDAP_OPT_MATCHED_DN	0x33
86*0Sstevel@tonic-gate #define	LDAP_OPT_ERROR_MATCHED	0x33	/* Use of this options is depricated */
87*0Sstevel@tonic-gate 
88*0Sstevel@tonic-gate /* The timeout while trying to connect to a server */
89*0Sstevel@tonic-gate #define	LDAP_X_OPT_CONNECT_TIMEOUT	0x4F01
90*0Sstevel@tonic-gate #define	LDAP_X_IO_TIMEOUT_NO_WAIT	0
91*0Sstevel@tonic-gate #define	LDAP_X_IO_TIMEOUT_NO_TIMEOUT	-1
92*0Sstevel@tonic-gate 
93*0Sstevel@tonic-gate /* The Filter List Desc used by UFN functions */
94*0Sstevel@tonic-gate /* #define LDAP_OPT_FILTERDESC 0x80	 */
95*0Sstevel@tonic-gate /* For on/off options */
96*0Sstevel@tonic-gate #define	LDAP_OPT_ON		((void *)1)
97*0Sstevel@tonic-gate #define	LDAP_OPT_OFF	((void *)0)
98*0Sstevel@tonic-gate 
99*0Sstevel@tonic-gate /* Used for NO limitation is TIMELIMIT or SIZELIMIT */
100*0Sstevel@tonic-gate #define	LDAP_NO_LIMIT		0
101*0Sstevel@tonic-gate 
102*0Sstevel@tonic-gate #define	LDAP_MAX_ATTR_LEN	100
103*0Sstevel@tonic-gate #define	LDAP_RETURN_NO_ATTR "1.1"
104*0Sstevel@tonic-gate #define	LDAP_RETURN_ALL_ATTR ""
105*0Sstevel@tonic-gate #define	LDAP_RETURN_ALL_ATTR_OPS "*"
106*0Sstevel@tonic-gate 
107*0Sstevel@tonic-gate /* Begin LDAP Display Template Definitions */
108*0Sstevel@tonic-gate #define	LDAP_TEMPLATE_VERSION   1
109*0Sstevel@tonic-gate 
110*0Sstevel@tonic-gate /*
111*0Sstevel@tonic-gate  * general types of items (confined to most significant byte)
112*0Sstevel@tonic-gate  */
113*0Sstevel@tonic-gate #define	LDAP_SYN_TYPE_TEXT	0x01000000
114*0Sstevel@tonic-gate #define	LDAP_SYN_TYPE_IMAGE	0x02000000
115*0Sstevel@tonic-gate #define	LDAP_SYN_TYPE_BOOLEAN	0x04000000
116*0Sstevel@tonic-gate #define	LDAP_SYN_TYPE_BUTTON	0x08000000
117*0Sstevel@tonic-gate #define	LDAP_SYN_TYPE_ACTION	0x10000000
118*0Sstevel@tonic-gate 
119*0Sstevel@tonic-gate /*
120*0Sstevel@tonic-gate  * syntax options (confined to second most significant byte)
121*0Sstevel@tonic-gate  */
122*0Sstevel@tonic-gate #define	LDAP_SYN_OPT_DEFER	0x00010000
123*0Sstevel@tonic-gate 
124*0Sstevel@tonic-gate 
125*0Sstevel@tonic-gate /*
126*0Sstevel@tonic-gate  * display template item syntax ids (defined by common agreement)
127*0Sstevel@tonic-gate  * these are the valid values for the ti_syntaxid of the tmplitem
128*0Sstevel@tonic-gate  * struct (defined below).  A general type is encoded in the
129*0Sstevel@tonic-gate  * most-significant 8 bits, and some options are encoded in the next
130*0Sstevel@tonic-gate  * 8 bits.  The lower 16 bits are reserved for the distinct types.
131*0Sstevel@tonic-gate  */
132*0Sstevel@tonic-gate #define	LDAP_SYN_CASEIGNORESTR	(1 | LDAP_SYN_TYPE_TEXT)
133*0Sstevel@tonic-gate #define	LDAP_SYN_MULTILINESTR	(2 | LDAP_SYN_TYPE_TEXT)
134*0Sstevel@tonic-gate #define	LDAP_SYN_DN		(3 | LDAP_SYN_TYPE_TEXT)
135*0Sstevel@tonic-gate #define	LDAP_SYN_BOOLEAN	(4 | LDAP_SYN_TYPE_BOOLEAN)
136*0Sstevel@tonic-gate #define	LDAP_SYN_JPEGIMAGE	(5 | LDAP_SYN_TYPE_IMAGE)
137*0Sstevel@tonic-gate #define	LDAP_SYN_JPEGBUTTON	(6 | LDAP_SYN_TYPE_BUTTON | \
138*0Sstevel@tonic-gate 				LDAP_SYN_OPT_DEFER)
139*0Sstevel@tonic-gate #define	LDAP_SYN_FAXIMAGE	(7 | LDAP_SYN_TYPE_IMAGE)
140*0Sstevel@tonic-gate #define	LDAP_SYN_FAXBUTTON	(8 | LDAP_SYN_TYPE_BUTTON | \
141*0Sstevel@tonic-gate 				LDAP_SYN_OPT_DEFER)
142*0Sstevel@tonic-gate #define	LDAP_SYN_AUDIOBUTTON	(9 | LDAP_SYN_TYPE_BUTTON | \
143*0Sstevel@tonic-gate 				LDAP_SYN_OPT_DEFER)
144*0Sstevel@tonic-gate #define	LDAP_SYN_TIME		(10 | LDAP_SYN_TYPE_TEXT)
145*0Sstevel@tonic-gate #define	LDAP_SYN_DATE		(11 | LDAP_SYN_TYPE_TEXT)
146*0Sstevel@tonic-gate #define	LDAP_SYN_LABELEDURL	(12 | LDAP_SYN_TYPE_TEXT)
147*0Sstevel@tonic-gate #define	LDAP_SYN_SEARCHACTION	(13 | LDAP_SYN_TYPE_ACTION)
148*0Sstevel@tonic-gate #define	LDAP_SYN_LINKACTION	(14 | LDAP_SYN_TYPE_ACTION)
149*0Sstevel@tonic-gate #define	LDAP_SYN_ADDDNACTION	(15 | LDAP_SYN_TYPE_ACTION)
150*0Sstevel@tonic-gate #define	LDAP_SYN_VERIFYDNACTION	(16 | LDAP_SYN_TYPE_ACTION)
151*0Sstevel@tonic-gate #define	LDAP_SYN_RFC822ADDR	(17 | LDAP_SYN_TYPE_TEXT)
152*0Sstevel@tonic-gate #ifdef	SUN
153*0Sstevel@tonic-gate #define	LDAP_SYN_PROTECTED	(18 | LDAP_SYN_TYPE_TEXT)
154*0Sstevel@tonic-gate #endif
155*0Sstevel@tonic-gate 
156*0Sstevel@tonic-gate /*
157*0Sstevel@tonic-gate  * handy macros
158*0Sstevel@tonic-gate  */
159*0Sstevel@tonic-gate #define	LDAP_GET_SYN_TYPE(syid)		((syid) & 0xFF000000)
160*0Sstevel@tonic-gate #define	LDAP_GET_SYN_OPTIONS(syid)	((syid) & 0x00FF0000)
161*0Sstevel@tonic-gate 
162*0Sstevel@tonic-gate /*
163*0Sstevel@tonic-gate  * display options for output routines (used by entry2text and friends)
164*0Sstevel@tonic-gate  */
165*0Sstevel@tonic-gate /*
166*0Sstevel@tonic-gate  * use calculated label width (based on length of longest label in
167*0Sstevel@tonic-gate  * template) instead of contant width
168*0Sstevel@tonic-gate  */
169*0Sstevel@tonic-gate #define	LDAP_DISP_OPT_AUTOLABELWIDTH	0x00000001
170*0Sstevel@tonic-gate #define	LDAP_DISP_OPT_HTMLBODYONLY	0x00000002
171*0Sstevel@tonic-gate 
172*0Sstevel@tonic-gate /*
173*0Sstevel@tonic-gate  * perform search actions (applies to ldap_entry2text_search only)
174*0Sstevel@tonic-gate  */
175*0Sstevel@tonic-gate #define	LDAP_DISP_OPT_DOSEARCHACTIONS	0x00000002
176*0Sstevel@tonic-gate 
177*0Sstevel@tonic-gate /*
178*0Sstevel@tonic-gate  * include additional info. relevant to "non leaf" entries only
179*0Sstevel@tonic-gate  * used by ldap_entry2html and ldap_entry2html_search to include "Browse"
180*0Sstevel@tonic-gate  * and "Move Up" HREFs
181*0Sstevel@tonic-gate  */
182*0Sstevel@tonic-gate #define	LDAP_DISP_OPT_NONLEAF		0x00000004
183*0Sstevel@tonic-gate 
184*0Sstevel@tonic-gate 
185*0Sstevel@tonic-gate /*
186*0Sstevel@tonic-gate  * display template item options (may not apply to all types)
187*0Sstevel@tonic-gate  * if this bit is set in ti_options, it applies.
188*0Sstevel@tonic-gate  */
189*0Sstevel@tonic-gate #define	LDAP_DITEM_OPT_READONLY		0x00000001
190*0Sstevel@tonic-gate #define	LDAP_DITEM_OPT_SORTVALUES	0x00000002
191*0Sstevel@tonic-gate #define	LDAP_DITEM_OPT_SINGLEVALUED	0x00000004
192*0Sstevel@tonic-gate #define	LDAP_DITEM_OPT_HIDEIFEMPTY	0x00000008
193*0Sstevel@tonic-gate #define	LDAP_DITEM_OPT_VALUEREQUIRED	0x00000010
194*0Sstevel@tonic-gate #define	LDAP_DITEM_OPT_HIDEIFFALSE	0x00000020 /* booleans only */
195*0Sstevel@tonic-gate 
196*0Sstevel@tonic-gate 
197*0Sstevel@tonic-gate /*
198*0Sstevel@tonic-gate  * LDAP API Information structure
199*0Sstevel@tonic-gate  */
200*0Sstevel@tonic-gate typedef struct ldapapiinfo {
201*0Sstevel@tonic-gate 	int ldapai_info_version;	/* version of this struct (1) */
202*0Sstevel@tonic-gate 	int ldapai_api_version;		/* revision of API supported */
203*0Sstevel@tonic-gate 	int ldapai_protocol_version;	/* highest LDAP version supported */
204*0Sstevel@tonic-gate 	char **ldapai_extensions;	/* names of API extensions */
205*0Sstevel@tonic-gate 	char *ldapai_vendor_name;	/* name of supplier */
206*0Sstevel@tonic-gate 	int ldapai_vendor_version;	/* supplier-specific version * 100 */
207*0Sstevel@tonic-gate } LDAPAPIInfo;
208*0Sstevel@tonic-gate #define	LDAP_API_INFO_VERSION	1
209*0Sstevel@tonic-gate 
210*0Sstevel@tonic-gate 
211*0Sstevel@tonic-gate /*
212*0Sstevel@tonic-gate  * LDAP API Feature Information
213*0Sstevel@tonic-gate  */
214*0Sstevel@tonic-gate typedef struct ldap_apifeature_info {
215*0Sstevel@tonic-gate 	int  ldapaif_info_version;	/* version of this struct (1) */
216*0Sstevel@tonic-gate 	char *ldapaif_name;		/* name of supported feature */
217*0Sstevel@tonic-gate 	int  ldapaif_version;		/* revision of supported feature */
218*0Sstevel@tonic-gate } LDAPAPIFeatureInfo;
219*0Sstevel@tonic-gate #define	LDAP_FEATURE_INFO_VERSION	1
220*0Sstevel@tonic-gate 
221*0Sstevel@tonic-gate 
222*0Sstevel@tonic-gate /*
223*0Sstevel@tonic-gate  * display template item structure
224*0Sstevel@tonic-gate  */
225*0Sstevel@tonic-gate struct ldap_tmplitem {
226*0Sstevel@tonic-gate 	unsigned int		ti_syntaxid;
227*0Sstevel@tonic-gate 	unsigned int		ti_options;
228*0Sstevel@tonic-gate 	char			*ti_attrname;
229*0Sstevel@tonic-gate 	char			*ti_label;
230*0Sstevel@tonic-gate 	char			**ti_args;
231*0Sstevel@tonic-gate 	struct ldap_tmplitem	*ti_next_in_row;
232*0Sstevel@tonic-gate 	struct ldap_tmplitem	*ti_next_in_col;
233*0Sstevel@tonic-gate 	void			*ti_appdata;
234*0Sstevel@tonic-gate };
235*0Sstevel@tonic-gate 
236*0Sstevel@tonic-gate 
237*0Sstevel@tonic-gate #define	NULLTMPLITEM	((struct ldap_tmplitem *)0)
238*0Sstevel@tonic-gate 
239*0Sstevel@tonic-gate #define	LDAP_SET_TMPLITEM_APPDATA(ti, datap)  \
240*0Sstevel@tonic-gate 	(ti)->ti_appdata = (void *)(datap)
241*0Sstevel@tonic-gate 
242*0Sstevel@tonic-gate #define	LDAP_GET_TMPLITEM_APPDATA(ti, type)   \
243*0Sstevel@tonic-gate 	(type)((ti)->ti_appdata)
244*0Sstevel@tonic-gate 
245*0Sstevel@tonic-gate 
246*0Sstevel@tonic-gate #define	LDAP_IS_TMPLITEM_OPTION_SET(ti, option)       \
247*0Sstevel@tonic-gate 	(((ti)->ti_options & option) != 0)
248*0Sstevel@tonic-gate 
249*0Sstevel@tonic-gate 
250*0Sstevel@tonic-gate /*
251*0Sstevel@tonic-gate  * object class array structure
252*0Sstevel@tonic-gate  */
253*0Sstevel@tonic-gate struct ldap_oclist {
254*0Sstevel@tonic-gate 	char			**oc_objclasses;
255*0Sstevel@tonic-gate 	struct ldap_oclist	*oc_next;
256*0Sstevel@tonic-gate };
257*0Sstevel@tonic-gate 
258*0Sstevel@tonic-gate #define	NULLOCLIST	((struct ldap_oclist *)0)
259*0Sstevel@tonic-gate 
260*0Sstevel@tonic-gate 
261*0Sstevel@tonic-gate /*
262*0Sstevel@tonic-gate  * add defaults list
263*0Sstevel@tonic-gate  */
264*0Sstevel@tonic-gate struct ldap_adddeflist {
265*0Sstevel@tonic-gate 	int			ad_source;
266*0Sstevel@tonic-gate #define	LDAP_ADSRC_CONSTANTVALUE	1
267*0Sstevel@tonic-gate #define	LDAP_ADSRC_ADDERSDN		2
268*0Sstevel@tonic-gate 	char			*ad_attrname;
269*0Sstevel@tonic-gate 	char			*ad_value;
270*0Sstevel@tonic-gate 	struct ldap_adddeflist	*ad_next;
271*0Sstevel@tonic-gate };
272*0Sstevel@tonic-gate 
273*0Sstevel@tonic-gate #define	NULLADLIST		((struct ldap_adddeflist *)0)
274*0Sstevel@tonic-gate 
275*0Sstevel@tonic-gate 
276*0Sstevel@tonic-gate /*
277*0Sstevel@tonic-gate  * display template global options
278*0Sstevel@tonic-gate  * if this bit is set in dt_options, it applies.
279*0Sstevel@tonic-gate  */
280*0Sstevel@tonic-gate /*
281*0Sstevel@tonic-gate  * users should be allowed to try to add objects of these entries
282*0Sstevel@tonic-gate  */
283*0Sstevel@tonic-gate #define	LDAP_DTMPL_OPT_ADDABLE	0x00000001
284*0Sstevel@tonic-gate 
285*0Sstevel@tonic-gate /*
286*0Sstevel@tonic-gate  * users should be allowed to do "modify RDN" operation of these entries
287*0Sstevel@tonic-gate  */
288*0Sstevel@tonic-gate #define	LDAP_DTMPL_OPT_ALLOWMODRDN	0x00000002
289*0Sstevel@tonic-gate 
290*0Sstevel@tonic-gate /*
291*0Sstevel@tonic-gate  * this template is an alternate view, not a primary view
292*0Sstevel@tonic-gate  */
293*0Sstevel@tonic-gate #define	LDAP_DTMPL_OPT_ALTVIEW		0x00000004
294*0Sstevel@tonic-gate 
295*0Sstevel@tonic-gate 
296*0Sstevel@tonic-gate /*
297*0Sstevel@tonic-gate  * display template structure
298*0Sstevel@tonic-gate  */
299*0Sstevel@tonic-gate struct ldap_disptmpl {
300*0Sstevel@tonic-gate 	char				*dt_name;
301*0Sstevel@tonic-gate 	char				*dt_pluralname;
302*0Sstevel@tonic-gate 	char				*dt_iconname;
303*0Sstevel@tonic-gate 	unsigned int			dt_options;
304*0Sstevel@tonic-gate 	char				*dt_authattrname;
305*0Sstevel@tonic-gate 	char				*dt_defrdnattrname;
306*0Sstevel@tonic-gate 	char				*dt_defaddlocation;
307*0Sstevel@tonic-gate 	struct ldap_oclist		*dt_oclist;
308*0Sstevel@tonic-gate 	struct ldap_adddeflist		*dt_adddeflist;
309*0Sstevel@tonic-gate 	struct ldap_tmplitem		*dt_items;
310*0Sstevel@tonic-gate 	void				*dt_appdata;
311*0Sstevel@tonic-gate 	struct ldap_disptmpl		*dt_next;
312*0Sstevel@tonic-gate };
313*0Sstevel@tonic-gate 
314*0Sstevel@tonic-gate #define	NULLDISPTMPL	((struct ldap_disptmpl *)0)
315*0Sstevel@tonic-gate 
316*0Sstevel@tonic-gate #define	LDAP_SET_DISPTMPL_APPDATA(dt, datap)  \
317*0Sstevel@tonic-gate 	(dt)->dt_appdata = (void *)(datap)
318*0Sstevel@tonic-gate 
319*0Sstevel@tonic-gate #define	LDAP_GET_DISPTMPL_APPDATA(dt, type)   \
320*0Sstevel@tonic-gate 	(type)((dt)->dt_appdata)
321*0Sstevel@tonic-gate 
322*0Sstevel@tonic-gate #define	LDAP_IS_DISPTMPL_OPTION_SET(dt, option)       \
323*0Sstevel@tonic-gate 	(((dt)->dt_options & option) != 0)
324*0Sstevel@tonic-gate 
325*0Sstevel@tonic-gate #define	LDAP_TMPL_ERR_VERSION	1
326*0Sstevel@tonic-gate #define	LDAP_TMPL_ERR_MEM	2
327*0Sstevel@tonic-gate #define	LDAP_TMPL_ERR_SYNTAX	3
328*0Sstevel@tonic-gate #define	LDAP_TMPL_ERR_FILE	4
329*0Sstevel@tonic-gate 
330*0Sstevel@tonic-gate /*
331*0Sstevel@tonic-gate  * buffer size needed for entry2text and vals2text
332*0Sstevel@tonic-gate  */
333*0Sstevel@tonic-gate #define	LDAP_DTMPL_BUFSIZ	8192
334*0Sstevel@tonic-gate 
335*0Sstevel@tonic-gate /* END Display Template Definitions */
336*0Sstevel@tonic-gate 
337*0Sstevel@tonic-gate /* BEGIN Search Prefrences Definitions */
338*0Sstevel@tonic-gate 
339*0Sstevel@tonic-gate struct ldap_searchattr {
340*0Sstevel@tonic-gate 	char				*sa_attrlabel;
341*0Sstevel@tonic-gate 	char				*sa_attr;
342*0Sstevel@tonic-gate 					/* max 32 matchtypes for now */
343*0Sstevel@tonic-gate 	unsigned int			sa_matchtypebitmap;
344*0Sstevel@tonic-gate 	char				*sa_selectattr;
345*0Sstevel@tonic-gate 	char				*sa_selecttext;
346*0Sstevel@tonic-gate 	struct ldap_searchattr		*sa_next;
347*0Sstevel@tonic-gate };
348*0Sstevel@tonic-gate 
349*0Sstevel@tonic-gate struct ldap_searchmatch {
350*0Sstevel@tonic-gate 	char				*sm_matchprompt;
351*0Sstevel@tonic-gate 	char				*sm_filter;
352*0Sstevel@tonic-gate 	struct ldap_searchmatch		*sm_next;
353*0Sstevel@tonic-gate };
354*0Sstevel@tonic-gate 
355*0Sstevel@tonic-gate struct ldap_searchobj {
356*0Sstevel@tonic-gate 	char				*so_objtypeprompt;
357*0Sstevel@tonic-gate 	unsigned int			so_options;
358*0Sstevel@tonic-gate 	char				*so_prompt;
359*0Sstevel@tonic-gate 	short				so_defaultscope;
360*0Sstevel@tonic-gate 	char				*so_filterprefix;
361*0Sstevel@tonic-gate 	char				*so_filtertag;
362*0Sstevel@tonic-gate 	char				*so_defaultselectattr;
363*0Sstevel@tonic-gate 	char				*so_defaultselecttext;
364*0Sstevel@tonic-gate 	struct ldap_searchattr		*so_salist;
365*0Sstevel@tonic-gate 	struct ldap_searchmatch		*so_smlist;
366*0Sstevel@tonic-gate 	struct ldap_searchobj		*so_next;
367*0Sstevel@tonic-gate };
368*0Sstevel@tonic-gate 
369*0Sstevel@tonic-gate #define	NULLSEARCHOBJ			((struct ldap_searchobj *)0)
370*0Sstevel@tonic-gate 
371*0Sstevel@tonic-gate /*
372*0Sstevel@tonic-gate  * global search object options
373*0Sstevel@tonic-gate  */
374*0Sstevel@tonic-gate #define	LDAP_SEARCHOBJ_OPT_INTERNAL	0x00000001
375*0Sstevel@tonic-gate 
376*0Sstevel@tonic-gate #define	LDAP_IS_SEARCHOBJ_OPTION_SET(so, option)	\
377*0Sstevel@tonic-gate 	(((so)->so_options & option) != 0)
378*0Sstevel@tonic-gate 
379*0Sstevel@tonic-gate #define	LDAP_SEARCHPREF_VERSION_ZERO	0
380*0Sstevel@tonic-gate #define	LDAP_SEARCHPREF_VERSION		1
381*0Sstevel@tonic-gate 
382*0Sstevel@tonic-gate #define	LDAP_SEARCHPREF_ERR_VERSION	1
383*0Sstevel@tonic-gate #define	LDAP_SEARCHPREF_ERR_MEM		2
384*0Sstevel@tonic-gate #define	LDAP_SEARCHPREF_ERR_SYNTAX	3
385*0Sstevel@tonic-gate #define	LDAP_SEARCHPREF_ERR_FILE	4
386*0Sstevel@tonic-gate 
387*0Sstevel@tonic-gate 
388*0Sstevel@tonic-gate /* END Search Prefrences Definitions */
389*0Sstevel@tonic-gate 
390*0Sstevel@tonic-gate /*
391*0Sstevel@tonic-gate  * Structure for LDAP modifications
392*0Sstevel@tonic-gate  */
393*0Sstevel@tonic-gate typedef struct ldapmod {
394*0Sstevel@tonic-gate 	int		mod_op;
395*0Sstevel@tonic-gate #define	LDAP_MOD_ADD		0x00
396*0Sstevel@tonic-gate #define	LDAP_MOD_DELETE		0x01
397*0Sstevel@tonic-gate #define	LDAP_MOD_REPLACE	0x02
398*0Sstevel@tonic-gate #define	LDAP_MOD_BVALUES	0x80
399*0Sstevel@tonic-gate 	char		*mod_type;
400*0Sstevel@tonic-gate 	union {
401*0Sstevel@tonic-gate 		char		**modv_strvals;
402*0Sstevel@tonic-gate 		struct berval	**modv_bvals;
403*0Sstevel@tonic-gate 	} mod_vals;
404*0Sstevel@tonic-gate #define	mod_values	mod_vals.modv_strvals
405*0Sstevel@tonic-gate #define	mod_bvalues	mod_vals.modv_bvals
406*0Sstevel@tonic-gate /*
407*0Sstevel@tonic-gate  * The following field is commented out since no functions use it in
408*0Sstevel@tonic-gate  * the library and also not part of c-api draft.
409*0Sstevel@tonic-gate  */
410*0Sstevel@tonic-gate /*	struct ldapmod	*mod_next */
411*0Sstevel@tonic-gate } LDAPMod;
412*0Sstevel@tonic-gate 
413*0Sstevel@tonic-gate typedef struct ldap LDAP; /* Opaque LDAP connection handle */
414*0Sstevel@tonic-gate 
415*0Sstevel@tonic-gate typedef struct ldapmsg LDAPMessage; /* Opaque Result / Entry handle */
416*0Sstevel@tonic-gate 
417*0Sstevel@tonic-gate #define	NULLMSG	((LDAPMessage *) NULL)
418*0Sstevel@tonic-gate 
419*0Sstevel@tonic-gate /* Call back to get info needed for re-bind */
420*0Sstevel@tonic-gate typedef int (LDAP_REBIND_FUNCTION)(LDAP *ld, char **dn, char **passwd,
421*0Sstevel@tonic-gate 			int *authmethod, int freeit, void *extraArg);
422*0Sstevel@tonic-gate 
423*0Sstevel@tonic-gate /*
424*0Sstevel@tonic-gate  * structures for ldap getfilter routines
425*0Sstevel@tonic-gate  */
426*0Sstevel@tonic-gate 
427*0Sstevel@tonic-gate typedef struct ldap_filt_info {
428*0Sstevel@tonic-gate 	char			*lfi_filter;
429*0Sstevel@tonic-gate 	char			*lfi_desc;
430*0Sstevel@tonic-gate 	int			lfi_scope;	/* LDAP_SCOPE_BASE, etc */
431*0Sstevel@tonic-gate 	int			lfi_isexact;	/* exact match filter? */
432*0Sstevel@tonic-gate 	struct ldap_filt_info	*lfi_next;
433*0Sstevel@tonic-gate } LDAPFiltInfo;
434*0Sstevel@tonic-gate 
435*0Sstevel@tonic-gate 
436*0Sstevel@tonic-gate #define	LDAP_FILT_MAXSIZ	1024
437*0Sstevel@tonic-gate 
438*0Sstevel@tonic-gate typedef struct ldap_filt_list LDAPFiltList;
439*0Sstevel@tonic-gate typedef struct ldap_filt_desc LDAPFiltDesc;
440*0Sstevel@tonic-gate 
441*0Sstevel@tonic-gate 
442*0Sstevel@tonic-gate /*
443*0Sstevel@tonic-gate  * Simple Page control OID
444*0Sstevel@tonic-gate  */
445*0Sstevel@tonic-gate #define	LDAP_CONTROL_SIMPLE_PAGE		"1.2.840.113556.1.4.319"
446*0Sstevel@tonic-gate 
447*0Sstevel@tonic-gate /*
448*0Sstevel@tonic-gate  * Server Sort Control
449*0Sstevel@tonic-gate  */
450*0Sstevel@tonic-gate #define	LDAP_CONTROL_SORTREQUEST		"1.2.840.113556.1.4.473"
451*0Sstevel@tonic-gate #define	LDAP_CONTROL_SORTRESPONSE		"1.2.840.113556.1.4.474"
452*0Sstevel@tonic-gate /*
453*0Sstevel@tonic-gate  * structure for a sort-key
454*0Sstevel@tonic-gate  */
455*0Sstevel@tonic-gate typedef struct LDAPsortkey {
456*0Sstevel@tonic-gate 	char	*sk_attrtype;
457*0Sstevel@tonic-gate 	char	*sk_matchruleoid;
458*0Sstevel@tonic-gate 	int	sk_reverseorder;
459*0Sstevel@tonic-gate } LDAPsortkey;
460*0Sstevel@tonic-gate 
461*0Sstevel@tonic-gate /*
462*0Sstevel@tonic-gate  * Virtual List View (vlv) control
463*0Sstevel@tonic-gate  */
464*0Sstevel@tonic-gate #define	LDAP_CONTROL_VLVREQUEST			"2.16.840.1.113730.3.4.9"
465*0Sstevel@tonic-gate #define	LDAP_CONTROL_VLVRESPONSE		"2.16.840.1.113730.3.4.10"
466*0Sstevel@tonic-gate /*
467*0Sstevel@tonic-gate  * structure that describes a VirtualListViewRequest control.
468*0Sstevel@tonic-gate  * note that ldvlist_index and ldvlist_size are only relevant to
469*0Sstevel@tonic-gate  * ldap_create_virtuallist_control() if ldvlist_attrvalue is NULL.
470*0Sstevel@tonic-gate  */
471*0Sstevel@tonic-gate typedef struct ldapvirtuallist {
472*0Sstevel@tonic-gate 	unsigned long	ldvlist_before_count;	/* # entries before target */
473*0Sstevel@tonic-gate 	unsigned long	ldvlist_after_count;	/* # entries after target */
474*0Sstevel@tonic-gate 	char		*ldvlist_attrvalue;	/* jump to this value */
475*0Sstevel@tonic-gate 	unsigned long	ldvlist_index;		/* list offset */
476*0Sstevel@tonic-gate 	unsigned long	ldvlist_size;		/* number of items in vlist */
477*0Sstevel@tonic-gate 	void		*ldvlist_extradata;	/* for use by application */
478*0Sstevel@tonic-gate } LDAPVirtualList;
479*0Sstevel@tonic-gate 
480*0Sstevel@tonic-gate /*
481*0Sstevel@tonic-gate  * ldapv3 LDAPControl
482*0Sstevel@tonic-gate  */
483*0Sstevel@tonic-gate typedef struct ldapcontrol
484*0Sstevel@tonic-gate {
485*0Sstevel@tonic-gate 	char *ldctl_oid;
486*0Sstevel@tonic-gate /*
487*0Sstevel@tonic-gate  * the "ldctl_value" field of this structure used to be a pointer to
488*0Sstevel@tonic-gate  * struct berval.  To make this structure compliant to the latest c-api
489*0Sstevel@tonic-gate  * draft, it is changed to "struct berval ldctl_value"
490*0Sstevel@tonic-gate  */
491*0Sstevel@tonic-gate 	struct berval ldctl_value;
492*0Sstevel@tonic-gate 	char ldctl_iscritical;
493*0Sstevel@tonic-gate } LDAPControl, *PLDAPControl;
494*0Sstevel@tonic-gate 
495*0Sstevel@tonic-gate /*
496*0Sstevel@tonic-gate  * specific LDAP instantiations of BER types we know about
497*0Sstevel@tonic-gate  */
498*0Sstevel@tonic-gate 
499*0Sstevel@tonic-gate /* general stuff */
500*0Sstevel@tonic-gate #define	LDAP_TAG_MESSAGE	0x30	/* tag is 16 + constructed bit */
501*0Sstevel@tonic-gate #define	LDAP_TAG_MSGID		0x02
502*0Sstevel@tonic-gate #define	LDAP_TAG_CONTROL_LIST	0xA0	/* Context 0 + constructed */
503*0Sstevel@tonic-gate #define	LDAP_TAG_REFERRAL	0xA3	/* Context 3 + constructed */
504*0Sstevel@tonic-gate #define	LDAP_TAG_SASLCREDS	0x87	/* Context 7 + primitive */
505*0Sstevel@tonic-gate #define	LDAP_TAG_AUTH_SIMPLE 0x80	/* Context 0 + primitive */
506*0Sstevel@tonic-gate #define	LDAP_TAG_AUTH_SASL	0xA3	/* Context 3 + constructed */
507*0Sstevel@tonic-gate /* Tag for modrdn request */
508*0Sstevel@tonic-gate #define	LDAP_TAG_NEWPARENT	0x80	/* Context 0 + primitive */
509*0Sstevel@tonic-gate /* Tags for Extensible filter match */
510*0Sstevel@tonic-gate #define	LDAP_TAG_FEXT_RULE	0x81	/* Context 1 + primitive */
511*0Sstevel@tonic-gate #define	LDAP_TAG_FEXT_TYPE	0x82	/* Context 2 + primitive */
512*0Sstevel@tonic-gate #define	LDAP_TAG_FEXT_VAL	0x83	/* Context 3 + primitive */
513*0Sstevel@tonic-gate #define	LDAP_TAG_FEXT_DN	0x84	/* Context 4 + primitive */
514*0Sstevel@tonic-gate /* tags for EXTENDED OPERATIONS */
515*0Sstevel@tonic-gate #define	LDAP_TAG_EXT_NAME	0x80	/* Context 0 + primitive */
516*0Sstevel@tonic-gate #define	LDAP_TAG_EXT_VAL	0x81	/* Context 1 + primitive */
517*0Sstevel@tonic-gate #define	LDAP_TAG_EXT_RESPNAME	0x8a	/* Context 10 + primitive */
518*0Sstevel@tonic-gate #define	LDAP_TAG_EXT_RESPONSE	0x8b	/* Context 11 + primitive */
519*0Sstevel@tonic-gate /* tags for Virtual List View control */
520*0Sstevel@tonic-gate #define	LDAP_TAG_VLV_BY_INDEX	0xa0    /* context specific + constructed + 0 */
521*0Sstevel@tonic-gate #define	LDAP_TAG_VLV_BY_VALUE	0x81    /* context specific + primitive + 1 */
522*0Sstevel@tonic-gate /* tag for sort control */
523*0Sstevel@tonic-gate #define	LDAP_TAG_SK_MATCHRULE	0x80L   /* context specific + primitive */
524*0Sstevel@tonic-gate #define	LDAP_TAG_SK_REVERSE	0x81L   /* context specific + primitive */
525*0Sstevel@tonic-gate #define	LDAP_TAG_SR_ATTRTYPE	0x80L   /* context specific + primitive */
526*0Sstevel@tonic-gate 
527*0Sstevel@tonic-gate /* possible operations a client can invoke */
528*0Sstevel@tonic-gate #define	LDAP_REQ_BIND			0x60	/* application + constructed */
529*0Sstevel@tonic-gate #define	LDAP_REQ_UNBIND			0x42	/* application + primitive   */
530*0Sstevel@tonic-gate #define	LDAP_REQ_SEARCH			0x63	/* application + constructed */
531*0Sstevel@tonic-gate #define	LDAP_REQ_MODIFY			0x66	/* application + constructed */
532*0Sstevel@tonic-gate #define	LDAP_REQ_ADD			0x68	/* application + constructed */
533*0Sstevel@tonic-gate #define	LDAP_REQ_DELETE			0x4a	/* application + primitive   */
534*0Sstevel@tonic-gate #define	LDAP_REQ_MODRDN			0x6c	/* application + constructed */
535*0Sstevel@tonic-gate #define	LDAP_REQ_COMPARE		0x6e	/* application + constructed */
536*0Sstevel@tonic-gate #define	LDAP_REQ_ABANDON		0x50	/* application + primitive   */
537*0Sstevel@tonic-gate /* New in ldapv3 application + constructed */
538*0Sstevel@tonic-gate #define	LDAP_REQ_EXTENDED		0x77
539*0Sstevel@tonic-gate /* version 3.0 compatibility stuff */
540*0Sstevel@tonic-gate #define	LDAP_REQ_UNBIND_30		0x62
541*0Sstevel@tonic-gate #define	LDAP_REQ_DELETE_30		0x6a
542*0Sstevel@tonic-gate #define	LDAP_REQ_ABANDON_30		0x70
543*0Sstevel@tonic-gate 
544*0Sstevel@tonic-gate /* possible result types a server can return */
545*0Sstevel@tonic-gate #define	LDAP_RES_BIND			0x61	/* application + constructed */
546*0Sstevel@tonic-gate #define	LDAP_RES_SEARCH_ENTRY		0x64	/* application + constructed */
547*0Sstevel@tonic-gate /* new in ldapv3, application + constructed */
548*0Sstevel@tonic-gate #define	LDAP_RES_SEARCH_REFERENCE	0x73
549*0Sstevel@tonic-gate #define	LDAP_RES_SEARCH_RESULT		0x65	/* application + constructed */
550*0Sstevel@tonic-gate #define	LDAP_RES_MODIFY			0x67	/* application + constructed */
551*0Sstevel@tonic-gate #define	LDAP_RES_ADD			0x69	/* application + constructed */
552*0Sstevel@tonic-gate #define	LDAP_RES_DELETE			0x6b	/* application + constructed */
553*0Sstevel@tonic-gate #define	LDAP_RES_MODRDN			0x6d	/* application + constructed */
554*0Sstevel@tonic-gate #define	LDAP_RES_COMPARE		0x6f	/* application + constructed */
555*0Sstevel@tonic-gate /* new in ldapv3, application + constructed */
556*0Sstevel@tonic-gate #define	LDAP_RES_EXTENDED		0x78
557*0Sstevel@tonic-gate #define	LDAP_RES_ANY			(-1)
558*0Sstevel@tonic-gate 
559*0Sstevel@tonic-gate /* authentication methods available */
560*0Sstevel@tonic-gate #define	LDAP_AUTH_NONE		0x00	/* no authentication		  */
561*0Sstevel@tonic-gate #define	LDAP_AUTH_SIMPLE	0x80	/* context specific + primitive   */
562*0Sstevel@tonic-gate #define	LDAP_AUTH_KRBV4		0xff	/* means do both of the following */
563*0Sstevel@tonic-gate #define	LDAP_AUTH_KRBV41	0x81	/* context specific + primitive   */
564*0Sstevel@tonic-gate #define	LDAP_AUTH_KRBV42	0x82	/* context specific + primitive   */
565*0Sstevel@tonic-gate /* New with ldapv3 */
566*0Sstevel@tonic-gate #define	LDAP_AUTH_SASL		0xa3	/* context specific + constructed */
567*0Sstevel@tonic-gate 
568*0Sstevel@tonic-gate /* 3.0 compatibility auth methods */
569*0Sstevel@tonic-gate #define	LDAP_AUTH_SIMPLE_30	0xa0	/* context specific + constructed */
570*0Sstevel@tonic-gate #define	LDAP_AUTH_KRBV41_30	0xa1	/* context specific + constructed */
571*0Sstevel@tonic-gate #define	LDAP_AUTH_KRBV42_30	0xa2	/* context specific + constructed */
572*0Sstevel@tonic-gate 
573*0Sstevel@tonic-gate /* filter types */
574*0Sstevel@tonic-gate #define	LDAP_FILTER_AND		0xa0	/* context specific + constructed */
575*0Sstevel@tonic-gate #define	LDAP_FILTER_OR		0xa1	/* context specific + constructed */
576*0Sstevel@tonic-gate #define	LDAP_FILTER_NOT		0xa2	/* context specific + constructed */
577*0Sstevel@tonic-gate #define	LDAP_FILTER_EQUALITY	0xa3	/* context specific + constructed */
578*0Sstevel@tonic-gate #define	LDAP_FILTER_SUBSTRINGS	0xa4	/* context specific + constructed */
579*0Sstevel@tonic-gate #define	LDAP_FILTER_GE		0xa5	/* context specific + constructed */
580*0Sstevel@tonic-gate #define	LDAP_FILTER_LE		0xa6	/* context specific + constructed */
581*0Sstevel@tonic-gate #define	LDAP_FILTER_PRESENT	0x87	/* context specific + primitive   */
582*0Sstevel@tonic-gate #define	LDAP_FILTER_APPROX	0xa8	/* context specific + constructed */
583*0Sstevel@tonic-gate #define	LDAP_FILTER_EXTENSIBLE	0xa9	/* context specific + constructed */
584*0Sstevel@tonic-gate 
585*0Sstevel@tonic-gate /* 3.0 compatibility filter types */
586*0Sstevel@tonic-gate #define	LDAP_FILTER_PRESENT_30	0xa7	/* context specific + constructed */
587*0Sstevel@tonic-gate 
588*0Sstevel@tonic-gate /* substring filter component types */
589*0Sstevel@tonic-gate #define	LDAP_SUBSTRING_INITIAL	0x80	/* context specific */
590*0Sstevel@tonic-gate #define	LDAP_SUBSTRING_ANY	0x81	/* context specific */
591*0Sstevel@tonic-gate #define	LDAP_SUBSTRING_FINAL	0x82	/* context specific */
592*0Sstevel@tonic-gate 
593*0Sstevel@tonic-gate /* 3.0 compatibility substring filter component types */
594*0Sstevel@tonic-gate #define	LDAP_SUBSTRING_INITIAL_30	0xa0	/* context specific */
595*0Sstevel@tonic-gate #define	LDAP_SUBSTRING_ANY_30		0xa1	/* context specific */
596*0Sstevel@tonic-gate #define	LDAP_SUBSTRING_FINAL_30		0xa2	/* context specific */
597*0Sstevel@tonic-gate 
598*0Sstevel@tonic-gate /* search scopes */
599*0Sstevel@tonic-gate #define	LDAP_SCOPE_BASE		0x00
600*0Sstevel@tonic-gate #define	LDAP_SCOPE_ONELEVEL	0x01
601*0Sstevel@tonic-gate #define	LDAP_SCOPE_SUBTREE	0x02
602*0Sstevel@tonic-gate /* Used when parsing URL, if scope not found. *LDAP_SCOPE_BASE is to use then */
603*0Sstevel@tonic-gate #define	LDAP_SCOPE_UNKNOWN  0xFF
604*0Sstevel@tonic-gate 
605*0Sstevel@tonic-gate /* ldap_result number of messages that should be returned */
606*0Sstevel@tonic-gate #define	LDAP_MSG_ONE 0x00
607*0Sstevel@tonic-gate #define	LDAP_MSG_ALL 0x01
608*0Sstevel@tonic-gate #define	LDAP_MSG_RECEIVED 0x02
609*0Sstevel@tonic-gate 
610*0Sstevel@tonic-gate 
611*0Sstevel@tonic-gate /* default limit on nesting of referrals */
612*0Sstevel@tonic-gate #define	LDAP_DEFAULT_REFHOPLIMIT	5
613*0Sstevel@tonic-gate 
614*0Sstevel@tonic-gate 
615*0Sstevel@tonic-gate /* SASL mechanisms */
616*0Sstevel@tonic-gate #define	LDAP_SASL_SIMPLE ""
617*0Sstevel@tonic-gate #define	LDAP_SASL_CRAM_MD5 "CRAM-MD5"
618*0Sstevel@tonic-gate #define	LDAP_SASL_EXTERNAL "EXTERNAL"
619*0Sstevel@tonic-gate /* Next ones are not supported so far by SunDS 2.0 */
620*0Sstevel@tonic-gate #define	LDAP_SASL_X511_PROTECTED "X.511-Protected"
621*0Sstevel@tonic-gate #define	LDAP_SASL_X511_STRONG "X.511-Strong"
622*0Sstevel@tonic-gate #define	LDAP_SASL_KERBEROS_V4 "KERBEROS_V4"
623*0Sstevel@tonic-gate #define	LDAP_SASL_GSSAPI "GSSAPI"
624*0Sstevel@tonic-gate #define	LDAP_SASL_SKEY "SKEY"
625*0Sstevel@tonic-gate 
626*0Sstevel@tonic-gate /*
627*0Sstevel@tonic-gate  * structure for ldap friendly mapping routines
628*0Sstevel@tonic-gate  */
629*0Sstevel@tonic-gate 
630*0Sstevel@tonic-gate typedef struct friendly {
631*0Sstevel@tonic-gate 	char	*f_unfriendly;
632*0Sstevel@tonic-gate 	char	*f_friendly;
633*0Sstevel@tonic-gate } FriendlyMap;
634*0Sstevel@tonic-gate 
635*0Sstevel@tonic-gate 
636*0Sstevel@tonic-gate /*
637*0Sstevel@tonic-gate  * Structures for URL handling
638*0Sstevel@tonic-gate  */
639*0Sstevel@tonic-gate typedef struct ldap_url_extension {
640*0Sstevel@tonic-gate 	char *lue_type;
641*0Sstevel@tonic-gate 	char *lue_value;
642*0Sstevel@tonic-gate 	int lue_iscritical;
643*0Sstevel@tonic-gate } LDAPURLExt;
644*0Sstevel@tonic-gate 
645*0Sstevel@tonic-gate typedef struct ldap_url_desc {
646*0Sstevel@tonic-gate     char	*lud_host;
647*0Sstevel@tonic-gate     int		lud_port;
648*0Sstevel@tonic-gate     char	*lud_dn;
649*0Sstevel@tonic-gate     char	**lud_attrs;
650*0Sstevel@tonic-gate     int		lud_scope;
651*0Sstevel@tonic-gate     char	*lud_filter;
652*0Sstevel@tonic-gate 	LDAPURLExt **lud_extensions;
653*0Sstevel@tonic-gate     char	*lud_string;	/* for internal use only */
654*0Sstevel@tonic-gate } LDAPURLDesc;
655*0Sstevel@tonic-gate 
656*0Sstevel@tonic-gate #define	NULLLDAPURLDESC	((LDAPURLDesc *)NULL)
657*0Sstevel@tonic-gate 
658*0Sstevel@tonic-gate #define	LDAP_URL_ERR_NOTLDAP	1	/* URL doesn't begin with "ldap://" */
659*0Sstevel@tonic-gate #define	LDAP_URL_ERR_NODN	2	/* URL has no DN (required) */
660*0Sstevel@tonic-gate #define	LDAP_URL_ERR_BADSCOPE	3	/* URL scope string is invalid */
661*0Sstevel@tonic-gate #define	LDAP_URL_ERR_MEM	4	/* can't allocate memory space */
662*0Sstevel@tonic-gate 
663*0Sstevel@tonic-gate 
664*0Sstevel@tonic-gate /*
665*0Sstevel@tonic-gate  * possible error codes we can return
666*0Sstevel@tonic-gate  */
667*0Sstevel@tonic-gate 
668*0Sstevel@tonic-gate #define	LDAP_SUCCESS			0x00
669*0Sstevel@tonic-gate #define	LDAP_OPERATIONS_ERROR		0x01
670*0Sstevel@tonic-gate #define	LDAP_PROTOCOL_ERROR		0x02
671*0Sstevel@tonic-gate #define	LDAP_TIMELIMIT_EXCEEDED		0x03
672*0Sstevel@tonic-gate #define	LDAP_SIZELIMIT_EXCEEDED		0x04
673*0Sstevel@tonic-gate #define	LDAP_COMPARE_FALSE		0x05
674*0Sstevel@tonic-gate #define	LDAP_COMPARE_TRUE		0x06
675*0Sstevel@tonic-gate #define	LDAP_AUTH_METHOD_NOT_SUPPORTED	0x07
676*0Sstevel@tonic-gate #define	LDAP_STRONG_AUTH_REQUIRED	0x08
677*0Sstevel@tonic-gate /* Not used in ldapv3 */
678*0Sstevel@tonic-gate #define	LDAP_PARTIAL_RESULTS		0x09
679*0Sstevel@tonic-gate 
680*0Sstevel@tonic-gate /* New in ldapv3 */
681*0Sstevel@tonic-gate #define	LDAP_REFERRAL		0x0a
682*0Sstevel@tonic-gate #define	LDAP_ADMINLIMIT_EXCEEDED	0x0b
683*0Sstevel@tonic-gate #define	LDAP_UNAVAILABLE_CRITICAL_EXTENSION	0x0c
684*0Sstevel@tonic-gate #define	LDAP_CONFIDENTIALITY_REQUIRED	0x0d
685*0Sstevel@tonic-gate #define	LDAP_SASL_BIND_INPROGRESS	0x0e
686*0Sstevel@tonic-gate /* End of new */
687*0Sstevel@tonic-gate 
688*0Sstevel@tonic-gate #define	LDAP_NO_SUCH_ATTRIBUTE		0x10
689*0Sstevel@tonic-gate #define	LDAP_UNDEFINED_TYPE		0x11
690*0Sstevel@tonic-gate #define	LDAP_INAPPROPRIATE_MATCHING	0x12
691*0Sstevel@tonic-gate #define	LDAP_CONSTRAINT_VIOLATION	0x13
692*0Sstevel@tonic-gate #define	LDAP_TYPE_OR_VALUE_EXISTS	0x14
693*0Sstevel@tonic-gate #define	LDAP_INVALID_SYNTAX		0x15
694*0Sstevel@tonic-gate 
695*0Sstevel@tonic-gate #define	ATTRIBUTE_ERROR(n) ((n & 0xf0) == 0x10)
696*0Sstevel@tonic-gate 
697*0Sstevel@tonic-gate #define	LDAP_NO_SUCH_OBJECT		0x20
698*0Sstevel@tonic-gate #define	LDAP_ALIAS_PROBLEM		0x21
699*0Sstevel@tonic-gate #define	LDAP_INVALID_DN_SYNTAX		0x22
700*0Sstevel@tonic-gate /* Following in not used in ldapv3 */
701*0Sstevel@tonic-gate #define	LDAP_IS_LEAF			0x23
702*0Sstevel@tonic-gate #define	LDAP_ALIAS_DEREF_PROBLEM	0x24
703*0Sstevel@tonic-gate 
704*0Sstevel@tonic-gate #define	NAME_ERROR(n)	((n & 0xf0) == 0x20)
705*0Sstevel@tonic-gate 
706*0Sstevel@tonic-gate #define	LDAP_INAPPROPRIATE_AUTH		0x30
707*0Sstevel@tonic-gate #define	LDAP_INVALID_CREDENTIALS	0x31
708*0Sstevel@tonic-gate #define	LDAP_INSUFFICIENT_ACCESS	0x32
709*0Sstevel@tonic-gate #define	LDAP_BUSY			0x33
710*0Sstevel@tonic-gate #define	LDAP_UNAVAILABLE		0x34
711*0Sstevel@tonic-gate #define	LDAP_UNWILLING_TO_PERFORM	0x35
712*0Sstevel@tonic-gate #define	LDAP_LOOP_DETECT		0x36
713*0Sstevel@tonic-gate 
714*0Sstevel@tonic-gate #define	LDAP_SORT_CONTROL_MISSING	0x3C	/* 60 */
715*0Sstevel@tonic-gate #define	LDAP_INDEX_RANGE_ERROR		0x3D	/* 61 */
716*0Sstevel@tonic-gate 
717*0Sstevel@tonic-gate #define	LDAP_NAMING_VIOLATION		0x40
718*0Sstevel@tonic-gate #define	LDAP_OBJECT_CLASS_VIOLATION	0x41
719*0Sstevel@tonic-gate #define	LDAP_NOT_ALLOWED_ON_NONLEAF	0x42
720*0Sstevel@tonic-gate #define	LDAP_NOT_ALLOWED_ON_RDN		0x43
721*0Sstevel@tonic-gate #define	LDAP_ALREADY_EXISTS		0x44
722*0Sstevel@tonic-gate #define	LDAP_NO_OBJECT_CLASS_MODS	0x45
723*0Sstevel@tonic-gate #define	LDAP_RESULTS_TOO_LARGE		0x46
724*0Sstevel@tonic-gate /* Following is new in ldapv3 */
725*0Sstevel@tonic-gate #define	LDAP_AFFECTS_MULTIPLE_DSAS	0x47
726*0Sstevel@tonic-gate #define	LDAP_OTHER			0x50
727*0Sstevel@tonic-gate 
728*0Sstevel@tonic-gate /* Reserved for API */
729*0Sstevel@tonic-gate #define	LDAP_SERVER_DOWN		0x51
730*0Sstevel@tonic-gate #define	LDAP_LOCAL_ERROR		0x52
731*0Sstevel@tonic-gate #define	LDAP_ENCODING_ERROR		0x53
732*0Sstevel@tonic-gate #define	LDAP_DECODING_ERROR		0x54
733*0Sstevel@tonic-gate #define	LDAP_TIMEOUT			0x55
734*0Sstevel@tonic-gate #define	LDAP_AUTH_UNKNOWN		0x56
735*0Sstevel@tonic-gate #define	LDAP_FILTER_ERROR		0x57
736*0Sstevel@tonic-gate #define	LDAP_USER_CANCELLED		0x58
737*0Sstevel@tonic-gate #define	LDAP_PARAM_ERROR		0x59
738*0Sstevel@tonic-gate #define	LDAP_NO_MEMORY			0x5a
739*0Sstevel@tonic-gate 
740*0Sstevel@tonic-gate /* New code with ldapv3 ? */
741*0Sstevel@tonic-gate #define	LDAP_CONNECT_ERROR 		0x5b
742*0Sstevel@tonic-gate #define	LDAP_NOT_SUPPORTED		0x5c
743*0Sstevel@tonic-gate #define	LDAP_CONTROL_NOT_FOUND	0x5d
744*0Sstevel@tonic-gate #define	LDAP_NO_RESULTS_RETURNED	0x5e
745*0Sstevel@tonic-gate #define	LDAP_MORE_RESULTS_TO_RETURN	0x5f
746*0Sstevel@tonic-gate #define	LDAP_CLIENT_LOOP	0x60
747*0Sstevel@tonic-gate #define	LDAP_REFERRAL_LIMIT_EXCEEDED	0x61
748*0Sstevel@tonic-gate 
749*0Sstevel@tonic-gate /* debugging stuff */
750*0Sstevel@tonic-gate #ifdef LDAP_DEBUG
751*0Sstevel@tonic-gate extern int	ldap_debug;
752*0Sstevel@tonic-gate #ifdef LDAP_SYSLOG
753*0Sstevel@tonic-gate extern int	ldap_syslog;
754*0Sstevel@tonic-gate extern int	ldap_syslog_level;
755*0Sstevel@tonic-gate #endif
756*0Sstevel@tonic-gate #define	LDAP_DEBUG_TRACE	0x001
757*0Sstevel@tonic-gate #define	LDAP_DEBUG_PACKETS	0x002
758*0Sstevel@tonic-gate #define	LDAP_DEBUG_ARGS		0x004
759*0Sstevel@tonic-gate #define	LDAP_DEBUG_CONNS	0x008
760*0Sstevel@tonic-gate #define	LDAP_DEBUG_BER		0x010
761*0Sstevel@tonic-gate #define	LDAP_DEBUG_FILTER	0x020
762*0Sstevel@tonic-gate #define	LDAP_DEBUG_CONFIG	0x040
763*0Sstevel@tonic-gate #define	LDAP_DEBUG_ACL		0x080
764*0Sstevel@tonic-gate #define	LDAP_DEBUG_STATS	0x100
765*0Sstevel@tonic-gate #define	LDAP_DEBUG_STATS2	0x200
766*0Sstevel@tonic-gate #define	LDAP_DEBUG_SHELL	0x400
767*0Sstevel@tonic-gate #define	LDAP_DEBUG_PARSE	0x800
768*0Sstevel@tonic-gate /* More values for http gateway */
769*0Sstevel@tonic-gate #define	LDAP_DEBUG_GWAY		0x1000
770*0Sstevel@tonic-gate #define	LDAP_DEBUG_GWAYMORE 	0x2000
771*0Sstevel@tonic-gate 
772*0Sstevel@tonic-gate #define	LDAP_DEBUG_ANY		0xffff
773*0Sstevel@tonic-gate 
774*0Sstevel@tonic-gate #ifdef LDAP_SYSLOG
775*0Sstevel@tonic-gate /* ldaplog is a general logging function that is defined in liblber/i18n.c */
776*0Sstevel@tonic-gate #define	Debug(level, fmt, arg1, arg2, arg3)	\
777*0Sstevel@tonic-gate 	{ \
778*0Sstevel@tonic-gate 		if (ldap_debug & level) \
779*0Sstevel@tonic-gate 			fprintf(stderr, fmt, arg1, arg2, arg3); \
780*0Sstevel@tonic-gate 		if (ldap_syslog & level) \
781*0Sstevel@tonic-gate 			ldaplog(level, fmt, arg1, arg2, arg3); \
782*0Sstevel@tonic-gate 	}
783*0Sstevel@tonic-gate #else /* LDAP_SYSLOG */
784*0Sstevel@tonic-gate #ifndef WINSOCK
785*0Sstevel@tonic-gate #define	Debug(level, fmt, arg1, arg2, arg3) \
786*0Sstevel@tonic-gate 		if (ldap_debug & level) \
787*0Sstevel@tonic-gate 			fprintf(stderr, fmt, arg1, arg2, arg3);
788*0Sstevel@tonic-gate #else /* !WINSOCK */
789*0Sstevel@tonic-gate extern void Debug(int level, char *fmt, ...);
790*0Sstevel@tonic-gate #endif /* !WINSOCK */
791*0Sstevel@tonic-gate #endif /* LDAP_SYSLOG */
792*0Sstevel@tonic-gate #else /* LDAP_DEBUG */
793*0Sstevel@tonic-gate #define	Debug(level, fmt, arg1, arg2, arg3)
794*0Sstevel@tonic-gate #endif /* LDAP_DEBUG */
795*0Sstevel@tonic-gate 
796*0Sstevel@tonic-gate 
797*0Sstevel@tonic-gate #ifndef NEEDPROTOS
798*0Sstevel@tonic-gate extern LDAP *ldap_open();
799*0Sstevel@tonic-gate #ifdef LDAP_SSL
800*0Sstevel@tonic-gate extern LDAP *ldap_ssl_open();
801*0Sstevel@tonic-gate #endif /* LDAP_SSL */
802*0Sstevel@tonic-gate extern LDAP *ldap_init();
803*0Sstevel@tonic-gate #ifdef STR_TRANSLATION
804*0Sstevel@tonic-gate extern void ldap_set_string_translators();
805*0Sstevel@tonic-gate #ifdef LDAP_CHARSET_8859
806*0Sstevel@tonic-gate extern int ldap_t61_to_8859();
807*0Sstevel@tonic-gate extern int ldap_8859_to_t61();
808*0Sstevel@tonic-gate #endif /* LDAP_CHARSET_8859 */
809*0Sstevel@tonic-gate #endif /* STR_TRANSLATION */
810*0Sstevel@tonic-gate extern LDAPMessage *ldap_first_entry();
811*0Sstevel@tonic-gate extern LDAPMessage *ldap_next_entry();
812*0Sstevel@tonic-gate extern char *ldap_get_dn();
813*0Sstevel@tonic-gate extern char *ldap_dn2ufn();
814*0Sstevel@tonic-gate extern char **ldap_explode_dn();
815*0Sstevel@tonic-gate extern char *ldap_first_attribute();
816*0Sstevel@tonic-gate extern char *ldap_next_attribute();
817*0Sstevel@tonic-gate extern char **ldap_get_values();
818*0Sstevel@tonic-gate extern struct berval **ldap_get_values_len();
819*0Sstevel@tonic-gate extern void ldap_value_free();
820*0Sstevel@tonic-gate extern void ldap_value_free_len();
821*0Sstevel@tonic-gate extern int ldap_count_values();
822*0Sstevel@tonic-gate extern int ldap_count_values_len();
823*0Sstevel@tonic-gate extern char *ldap_err2string();
824*0Sstevel@tonic-gate extern void ldap_getfilter_free();
825*0Sstevel@tonic-gate extern LDAPFiltDesc *ldap_init_getfilter();
826*0Sstevel@tonic-gate extern LDAPFiltDesc *ldap_init_getfilter_buf();
827*0Sstevel@tonic-gate extern LDAPFiltInfo *ldap_getfirstfilter();
828*0Sstevel@tonic-gate extern LDAPFiltInfo *ldap_getnextfilter();
829*0Sstevel@tonic-gate extern void ldap_setfilteraffixes();
830*0Sstevel@tonic-gate extern void ldap_build_filter();
831*0Sstevel@tonic-gate extern void ldap_flush_cache();
832*0Sstevel@tonic-gate extern void ldap_set_cache_options();
833*0Sstevel@tonic-gate extern void ldap_uncache_entry();
834*0Sstevel@tonic-gate extern void ldap_uncache_request();
835*0Sstevel@tonic-gate extern char *ldap_friendly_name();
836*0Sstevel@tonic-gate extern void ldap_free_friendlymap();
837*0Sstevel@tonic-gate extern LDAP *cldap_open();
838*0Sstevel@tonic-gate extern void cldap_setretryinfo();
839*0Sstevel@tonic-gate extern void cldap_close();
840*0Sstevel@tonic-gate extern LDAPFiltDesc *ldap_ufn_setfilter();
841*0Sstevel@tonic-gate extern int ldap_ufn_timeout();
842*0Sstevel@tonic-gate extern int ldap_sort_entries();
843*0Sstevel@tonic-gate extern int ldap_sort_values();
844*0Sstevel@tonic-gate extern int ldap_sort_strcasecmp();
845*0Sstevel@tonic-gate void ldap_free_urldesc();
846*0Sstevel@tonic-gate void ldap_free_urlexts();
847*0Sstevel@tonic-gate void ldap_set_rebind_proc();
848*0Sstevel@tonic-gate void ldap_enable_translation();
849*0Sstevel@tonic-gate /* Begin Display Template Prototypes */
850*0Sstevel@tonic-gate typedef int (*writeptype)();
851*0Sstevel@tonic-gate 
852*0Sstevel@tonic-gate int ldap_init_templates();
853*0Sstevel@tonic-gate int ldap_init_templates_buf();
854*0Sstevel@tonic-gate void ldap_free_templates();
855*0Sstevel@tonic-gate struct ldap_disptmpl *ldap_first_disptmpl();
856*0Sstevel@tonic-gate struct ldap_disptmpl *ldap_next_disptmpl();
857*0Sstevel@tonic-gate struct ldap_disptmpl *ldap_name2template();
858*0Sstevel@tonic-gate struct ldap_disptmpl *ldap_oc2template();
859*0Sstevel@tonic-gate char **ldap_tmplattrs();
860*0Sstevel@tonic-gate struct ldap_tmplitem *ldap_first_tmplrow();
861*0Sstevel@tonic-gate struct ldap_tmplitem *ldap_next_tmplrow();
862*0Sstevel@tonic-gate struct ldap_tmplitem *ldap_first_tmplcol();
863*0Sstevel@tonic-gate struct ldap_tmplitem *ldap_next_tmplcol();
864*0Sstevel@tonic-gate int ldap_entry2text_search();
865*0Sstevel@tonic-gate int ldap_entry2text();
866*0Sstevel@tonic-gate int ldap_vals2text();
867*0Sstevel@tonic-gate int ldap_entry2html_search();
868*0Sstevel@tonic-gate int ldap_entry2html();
869*0Sstevel@tonic-gate int ldap_vals2html();
870*0Sstevel@tonic-gate 
871*0Sstevel@tonic-gate int ldap_init_searchprefs();
872*0Sstevel@tonic-gate int ldap_init_searchprefs_buf();
873*0Sstevel@tonic-gate void ldap_free_searchprefs();
874*0Sstevel@tonic-gate struct ldap_searchobj	*ldap_first_searchobj();
875*0Sstevel@tonic-gate struct ldap_searchobj	*ldap_next_searchobj();
876*0Sstevel@tonic-gate 
877*0Sstevel@tonic-gate #else /* NEEDPROTOS */
878*0Sstevel@tonic-gate #if !defined(MACOS) && !defined(DOS) && !defined(_WIN32) && !defined(WINSOCK)
879*0Sstevel@tonic-gate #include <sys/time.h>
880*0Sstevel@tonic-gate #endif
881*0Sstevel@tonic-gate 
882*0Sstevel@tonic-gate 
883*0Sstevel@tonic-gate /*
884*0Sstevel@tonic-gate  * Abandon functions
885*0Sstevel@tonic-gate  */
886*0Sstevel@tonic-gate int ldap_abandon_ext(LDAP *ld, int msgid, LDAPControl **serverctrls,
887*0Sstevel@tonic-gate 	LDAPControl ** clientctrls);
888*0Sstevel@tonic-gate int ldap_abandon(LDAP *ld, int msgid);
889*0Sstevel@tonic-gate 
890*0Sstevel@tonic-gate /*
891*0Sstevel@tonic-gate  * Add functions
892*0Sstevel@tonic-gate  */
893*0Sstevel@tonic-gate int ldap_add_ext(LDAP *ld, char *dn, LDAPMod **attrs,
894*0Sstevel@tonic-gate 	LDAPControl ** serverctrls, LDAPControl **clientctrls, int *msgidp);
895*0Sstevel@tonic-gate int ldap_add_ext_s(LDAP *ld, char *dn, LDAPMod **attrs,
896*0Sstevel@tonic-gate 	LDAPControl ** serverctrls, LDAPControl **clientctrls);
897*0Sstevel@tonic-gate int ldap_add(LDAP *ld, char *dn, LDAPMod **attrs);
898*0Sstevel@tonic-gate int ldap_add_s(LDAP *ld, char *dn, LDAPMod **attrs);
899*0Sstevel@tonic-gate 
900*0Sstevel@tonic-gate /*
901*0Sstevel@tonic-gate  * Bind functions
902*0Sstevel@tonic-gate  */
903*0Sstevel@tonic-gate /* DEPRECATED */
904*0Sstevel@tonic-gate int ldap_bind(LDAP *ld, char *who, char *passwd, int authmethod);
905*0Sstevel@tonic-gate /* DEPRECATED */
906*0Sstevel@tonic-gate int ldap_bind_s(LDAP *ld, char *who, char *cred, int method);
907*0Sstevel@tonic-gate #ifdef LDAP_REFERRALS
908*0Sstevel@tonic-gate /* DEPRECATED */
909*0Sstevel@tonic-gate void ldap_set_rebind_proc(LDAP *ld, LDAP_REBIND_FUNCTION *rebindproc,
910*0Sstevel@tonic-gate 	void *extra_arg);
911*0Sstevel@tonic-gate #endif /* LDAP_REFERRALS */
912*0Sstevel@tonic-gate 
913*0Sstevel@tonic-gate /*
914*0Sstevel@tonic-gate  * Simple bind functions
915*0Sstevel@tonic-gate  */
916*0Sstevel@tonic-gate int ldap_simple_bind(LDAP *ld, char *who, char *passwd);
917*0Sstevel@tonic-gate int ldap_simple_bind_s(LDAP *ld, char *who, char *passwd);
918*0Sstevel@tonic-gate 
919*0Sstevel@tonic-gate /*
920*0Sstevel@tonic-gate  * SASL functions
921*0Sstevel@tonic-gate  */
922*0Sstevel@tonic-gate int ldap_sasl_bind(LDAP *ld, char *dn, char *mechanism, struct berval *cred,
923*0Sstevel@tonic-gate 	LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp);
924*0Sstevel@tonic-gate int ldap_sasl_bind_s(LDAP *ld, char *dn, char *mechanism, struct berval *cred,
925*0Sstevel@tonic-gate 	LDAPControl **serverctrls, LDAPControl **clientctrls,
926*0Sstevel@tonic-gate 	struct berval **servercredp);
927*0Sstevel@tonic-gate 
928*0Sstevel@tonic-gate /*
929*0Sstevel@tonic-gate  * Kerberos functions
930*0Sstevel@tonic-gate  */
931*0Sstevel@tonic-gate /* DEPRECATED */
932*0Sstevel@tonic-gate int ldap_kerberos_bind_s(LDAP *ld, char *who);
933*0Sstevel@tonic-gate /* DEPRECATED */
934*0Sstevel@tonic-gate int ldap_kerberos_bind1(LDAP *ld, char *who);
935*0Sstevel@tonic-gate /* DEPRECATED */
936*0Sstevel@tonic-gate int ldap_kerberos_bind1_s(LDAP *ld, char *who);
937*0Sstevel@tonic-gate /* DEPRECATED */
938*0Sstevel@tonic-gate int ldap_kerberos_bind2(LDAP *ld, char *who);
939*0Sstevel@tonic-gate /* DEPRECATED */
940*0Sstevel@tonic-gate int ldap_kerberos_bind2_s(LDAP *ld, char *who);
941*0Sstevel@tonic-gate 
942*0Sstevel@tonic-gate #ifndef NO_CACHE
943*0Sstevel@tonic-gate /*
944*0Sstevel@tonic-gate  * Cache functions
945*0Sstevel@tonic-gate  */
946*0Sstevel@tonic-gate int ldap_enable_cache(LDAP *ld, time_t timeout, ssize_t maxmem);
947*0Sstevel@tonic-gate void ldap_disable_cache(LDAP *ld);
948*0Sstevel@tonic-gate void ldap_set_cache_options(LDAP *ld, unsigned int opts);
949*0Sstevel@tonic-gate void ldap_destroy_cache(LDAP *ld);
950*0Sstevel@tonic-gate void ldap_flush_cache(LDAP *ld);
951*0Sstevel@tonic-gate void ldap_uncache_entry(LDAP *ld, char *dn);
952*0Sstevel@tonic-gate void ldap_uncache_request(LDAP *ld, int msgid);
953*0Sstevel@tonic-gate #endif /* !NO_CACHE */
954*0Sstevel@tonic-gate 
955*0Sstevel@tonic-gate /*
956*0Sstevel@tonic-gate  * Compare functions
957*0Sstevel@tonic-gate  */
958*0Sstevel@tonic-gate int ldap_compare_ext(LDAP *ld, char *dn, char *attr, struct berval *bvalue,
959*0Sstevel@tonic-gate 	LDAPControl ** serverctrls, LDAPControl **clientctrls, int *msgidp);
960*0Sstevel@tonic-gate int ldap_compare_ext_s(LDAP *ld, char *dn, char *attr, struct berval *bvalue,
961*0Sstevel@tonic-gate 	LDAPControl ** serverctrls, LDAPControl **clientctrls);
962*0Sstevel@tonic-gate int ldap_compare(LDAP *ld, char *dn, char *attr, char *value);
963*0Sstevel@tonic-gate int ldap_compare_s(LDAP *ld, char *dn, char *attr, char *value);
964*0Sstevel@tonic-gate 
965*0Sstevel@tonic-gate /*
966*0Sstevel@tonic-gate  * Delete functions
967*0Sstevel@tonic-gate  */
968*0Sstevel@tonic-gate int ldap_delete_ext(LDAP *ld, char *dn, LDAPControl **serverctrls,
969*0Sstevel@tonic-gate 	LDAPControl **clientctrls, int *msgidp);
970*0Sstevel@tonic-gate int ldap_delete_ext_s(LDAP *ld, char *dn, LDAPControl **serverctrls,
971*0Sstevel@tonic-gate 	LDAPControl **clientctrls);
972*0Sstevel@tonic-gate int ldap_delete(LDAP *ld, char *dn);
973*0Sstevel@tonic-gate int ldap_delete_s(LDAP *ld, char *dn);
974*0Sstevel@tonic-gate 
975*0Sstevel@tonic-gate /*
976*0Sstevel@tonic-gate  * Error functions
977*0Sstevel@tonic-gate  */
978*0Sstevel@tonic-gate char *ldap_err2string(int err);
979*0Sstevel@tonic-gate 
980*0Sstevel@tonic-gate /* DEPRECATED */
981*0Sstevel@tonic-gate int ldap_result2error(LDAP *ld, LDAPMessage *r, int freeit);
982*0Sstevel@tonic-gate /* DEPRECATED */
983*0Sstevel@tonic-gate void ldap_perror(LDAP *ld, char *s);
984*0Sstevel@tonic-gate 
985*0Sstevel@tonic-gate /*
986*0Sstevel@tonic-gate  * Modify functions
987*0Sstevel@tonic-gate  */
988*0Sstevel@tonic-gate int ldap_modify_ext(LDAP *ld, char *dn, LDAPMod **mods,
989*0Sstevel@tonic-gate 	LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp);
990*0Sstevel@tonic-gate int ldap_modify_ext_s(LDAP *ld, char *dn, LDAPMod **mods,
991*0Sstevel@tonic-gate 	LDAPControl **serverctrls, LDAPControl **clientctrls);
992*0Sstevel@tonic-gate int ldap_modify(LDAP *ld, char *dn, LDAPMod **mods);
993*0Sstevel@tonic-gate int ldap_modify_s(LDAP *ld, char *dn, LDAPMod **mods);
994*0Sstevel@tonic-gate 
995*0Sstevel@tonic-gate /*
996*0Sstevel@tonic-gate  * Modrdn functions
997*0Sstevel@tonic-gate  */
998*0Sstevel@tonic-gate 
999*0Sstevel@tonic-gate /* DEPRECATED : use ldap_rename instead */
1000*0Sstevel@tonic-gate int ldap_modrdn0(LDAP *ld, char *dn, char *newrdn);
1001*0Sstevel@tonic-gate /* DEPRECATED : use ldap_rename_s instead */
1002*0Sstevel@tonic-gate int ldap_modrdn0_s(LDAP *ld, char *dn, char *newrdn);
1003*0Sstevel@tonic-gate /* DEPRECATED : use ldap_rename instead */
1004*0Sstevel@tonic-gate int ldap_modrdn(LDAP *ld, char *dn, char *newrdn,
1005*0Sstevel@tonic-gate 	int deleteoldrdn);
1006*0Sstevel@tonic-gate /* DEPRECATED : use ldap_rename_s instead */
1007*0Sstevel@tonic-gate int ldap_modrdn_s(LDAP *ld, char *dn, char *newrdn,
1008*0Sstevel@tonic-gate 	int deleteoldrdn);
1009*0Sstevel@tonic-gate 
1010*0Sstevel@tonic-gate /*
1011*0Sstevel@tonic-gate  * Rename functions
1012*0Sstevel@tonic-gate  */
1013*0Sstevel@tonic-gate int ldap_rename(LDAP *ld, char *dn, char *newrdn, char *newparent,
1014*0Sstevel@tonic-gate 	int deleteoldrdn, LDAPControl ** serverctrls,
1015*0Sstevel@tonic-gate 	LDAPControl **clientctrls, int *msgidp);
1016*0Sstevel@tonic-gate int ldap_rename_s(LDAP *ld, char *dn, char *newrdn, char *newparent,
1017*0Sstevel@tonic-gate 	int deleteoldrdn, LDAPControl ** serverctrls,
1018*0Sstevel@tonic-gate 	LDAPControl **clientctrls);
1019*0Sstevel@tonic-gate 
1020*0Sstevel@tonic-gate /*
1021*0Sstevel@tonic-gate  * Init/Open functions
1022*0Sstevel@tonic-gate  */
1023*0Sstevel@tonic-gate LDAP *ldap_init(char *defhost, int defport);
1024*0Sstevel@tonic-gate 
1025*0Sstevel@tonic-gate /* DEPRECATED : use ldap_init instead */
1026*0Sstevel@tonic-gate LDAP *ldap_open(char *host, int port);
1027*0Sstevel@tonic-gate 
1028*0Sstevel@tonic-gate #ifdef LDAP_SSL
1029*0Sstevel@tonic-gate LDAP *ldap_ssl_init(char *defhost, int defport, char *keyname);
1030*0Sstevel@tonic-gate 
1031*0Sstevel@tonic-gate /* DEPRECATED : use ldap_ssl_init instead */
1032*0Sstevel@tonic-gate LDAP *ldap_ssl_open(char *host, int port, char *keyname);
1033*0Sstevel@tonic-gate #endif
1034*0Sstevel@tonic-gate 
1035*0Sstevel@tonic-gate /*
1036*0Sstevel@tonic-gate  * Entry functions
1037*0Sstevel@tonic-gate  */
1038*0Sstevel@tonic-gate LDAPMessage *ldap_first_entry(LDAP *ld, LDAPMessage *res);
1039*0Sstevel@tonic-gate LDAPMessage *ldap_next_entry(LDAP *ld, LDAPMessage *entry);
1040*0Sstevel@tonic-gate int ldap_count_entries(LDAP *ld, LDAPMessage *res);
1041*0Sstevel@tonic-gate 
1042*0Sstevel@tonic-gate /*
1043*0Sstevel@tonic-gate  * Message functions
1044*0Sstevel@tonic-gate  */
1045*0Sstevel@tonic-gate LDAPMessage *ldap_first_message(LDAP *ld, LDAPMessage *res);
1046*0Sstevel@tonic-gate LDAPMessage *ldap_next_message(LDAP *ld, LDAPMessage *msg);
1047*0Sstevel@tonic-gate int ldap_count_messages(LDAP *ld, LDAPMessage *res);
1048*0Sstevel@tonic-gate 
1049*0Sstevel@tonic-gate /*
1050*0Sstevel@tonic-gate  * Reference functions
1051*0Sstevel@tonic-gate  */
1052*0Sstevel@tonic-gate LDAPMessage *ldap_first_reference(LDAP *ld, LDAPMessage *res);
1053*0Sstevel@tonic-gate LDAPMessage *ldap_next_reference(LDAP *ld, LDAPMessage *msg);
1054*0Sstevel@tonic-gate int ldap_count_references(LDAP *ld, LDAPMessage *res);
1055*0Sstevel@tonic-gate char ** ldap_get_reference_urls(LDAP *ld, LDAPMessage *res);
1056*0Sstevel@tonic-gate 
1057*0Sstevel@tonic-gate /*
1058*0Sstevel@tonic-gate  * Entry functions
1059*0Sstevel@tonic-gate  */
1060*0Sstevel@tonic-gate LDAPMessage *ldap_delete_result_entry(LDAPMessage **list,
1061*0Sstevel@tonic-gate 	LDAPMessage *e);
1062*0Sstevel@tonic-gate void ldap_add_result_entry(LDAPMessage **list, LDAPMessage *e);
1063*0Sstevel@tonic-gate 
1064*0Sstevel@tonic-gate /*
1065*0Sstevel@tonic-gate  * DN functions
1066*0Sstevel@tonic-gate  */
1067*0Sstevel@tonic-gate char *ldap_get_dn(LDAP *ld, LDAPMessage *entry);
1068*0Sstevel@tonic-gate char **ldap_explode_dn(char *dn, int notypes);
1069*0Sstevel@tonic-gate char ** ldap_explode_rdn(char *rdn, int notypes);
1070*0Sstevel@tonic-gate char *ldap_dn2ufn(char *dn);
1071*0Sstevel@tonic-gate 
1072*0Sstevel@tonic-gate char **ldap_explode_dns(char *dn);
1073*0Sstevel@tonic-gate int ldap_is_dns_dn(char *dn);
1074*0Sstevel@tonic-gate char *ldap_dns_to_dn(char *dns_name, int *nameparts);
1075*0Sstevel@tonic-gate 
1076*0Sstevel@tonic-gate /*
1077*0Sstevel@tonic-gate  * Attribute parsing functions
1078*0Sstevel@tonic-gate  */
1079*0Sstevel@tonic-gate char *ldap_first_attribute(LDAP *ld, LDAPMessage *entry,
1080*0Sstevel@tonic-gate 	BerElement **ber);
1081*0Sstevel@tonic-gate char *ldap_next_attribute(LDAP *ld, LDAPMessage *entry,
1082*0Sstevel@tonic-gate 	BerElement *ber);
1083*0Sstevel@tonic-gate void ldap_memfree(char *mem);
1084*0Sstevel@tonic-gate 
1085*0Sstevel@tonic-gate /*
1086*0Sstevel@tonic-gate  * Attribute Value functions
1087*0Sstevel@tonic-gate  */
1088*0Sstevel@tonic-gate char **ldap_get_values(LDAP *ld, LDAPMessage *entry, char *target);
1089*0Sstevel@tonic-gate struct berval **ldap_get_values_len(LDAP *ld, LDAPMessage *entry,
1090*0Sstevel@tonic-gate 	char *target);
1091*0Sstevel@tonic-gate int ldap_count_values(char **vals);
1092*0Sstevel@tonic-gate int ldap_count_values_len(struct berval **vals);
1093*0Sstevel@tonic-gate void ldap_value_free(char **vals);
1094*0Sstevel@tonic-gate void ldap_value_free_len(struct berval **vals);
1095*0Sstevel@tonic-gate 
1096*0Sstevel@tonic-gate /*
1097*0Sstevel@tonic-gate  * Result functions
1098*0Sstevel@tonic-gate  */
1099*0Sstevel@tonic-gate int ldap_result(LDAP *ld, int msgid, int all,
1100*0Sstevel@tonic-gate 	struct timeval *timeout, LDAPMessage **result);
1101*0Sstevel@tonic-gate int ldap_msgdelete(LDAP *ld, int msgid);
1102*0Sstevel@tonic-gate int ldap_msgfree(LDAPMessage *lm);
1103*0Sstevel@tonic-gate int ldap_msgtype(LDAPMessage *res);
1104*0Sstevel@tonic-gate int ldap_msgid(LDAPMessage *res);
1105*0Sstevel@tonic-gate int ldap_parse_result(LDAP *ld, LDAPMessage *res, int *errcodep,
1106*0Sstevel@tonic-gate 	char **matcheddnp, char **errmsgp, char ***referralsp,
1107*0Sstevel@tonic-gate 	LDAPControl ***serverctrlsp, int freeit);
1108*0Sstevel@tonic-gate int ldap_parse_sasl_bind_result(LDAP *ld, LDAPMessage *res,
1109*0Sstevel@tonic-gate 	struct berval **servercredp, int freeit);
1110*0Sstevel@tonic-gate int ldap_parse_extended_result(LDAP *ld, LDAPMessage *res,
1111*0Sstevel@tonic-gate 	char **resultoidp, struct berval **resultdata, int freeit);
1112*0Sstevel@tonic-gate int cldap_getmsg(LDAP *ld, struct timeval *timeout, BerElement *ber);
1113*0Sstevel@tonic-gate 
1114*0Sstevel@tonic-gate 
1115*0Sstevel@tonic-gate /*
1116*0Sstevel@tonic-gate  * Search functions
1117*0Sstevel@tonic-gate  */
1118*0Sstevel@tonic-gate int ldap_search_ext(LDAP *ld, char *base, int scope, char *filter,
1119*0Sstevel@tonic-gate 	char **attrs, int attrsonly, LDAPControl **serverctrls,
1120*0Sstevel@tonic-gate 	LDAPControl **clientctrls, struct timeval *timeoutp,
1121*0Sstevel@tonic-gate 	int sizelimit, int *msgidp);
1122*0Sstevel@tonic-gate int ldap_search_ext_s(LDAP *ld, char *base, int scope, char *filter,
1123*0Sstevel@tonic-gate 	char **attrs, int attrsonly, LDAPControl **serverctrls,
1124*0Sstevel@tonic-gate 	LDAPControl **clientctrls, struct timeval *timeoutp, int sizelimit,
1125*0Sstevel@tonic-gate 	LDAPMessage **res);
1126*0Sstevel@tonic-gate 
1127*0Sstevel@tonic-gate int ldap_search(LDAP *ld, char *base, int scope, char *filter,
1128*0Sstevel@tonic-gate 	char **attrs, int attrsonly);
1129*0Sstevel@tonic-gate int ldap_search_s(LDAP *ld, char *base, int scope, char *filter,
1130*0Sstevel@tonic-gate 	char **attrs, int attrsonly, LDAPMessage **res);
1131*0Sstevel@tonic-gate int ldap_search_st(LDAP *ld, char *base, int scope, char *filter,
1132*0Sstevel@tonic-gate     char **attrs, int attrsonly, struct timeval *timeout, LDAPMessage **res);
1133*0Sstevel@tonic-gate 
1134*0Sstevel@tonic-gate /*
1135*0Sstevel@tonic-gate  * UFN functions
1136*0Sstevel@tonic-gate  */
1137*0Sstevel@tonic-gate int ldap_ufn_search_c(LDAP *ld, char *ufn, char **attrs,
1138*0Sstevel@tonic-gate 	int attrsonly, LDAPMessage **res, int (*cancelproc)(void *cl),
1139*0Sstevel@tonic-gate 	void *cancelparm);
1140*0Sstevel@tonic-gate int ldap_ufn_search_ct(LDAP *ld, char *ufn, char **attrs,
1141*0Sstevel@tonic-gate 	int attrsonly, LDAPMessage **res, int (*cancelproc)(void *cl),
1142*0Sstevel@tonic-gate 	void *cancelparm, char *tag1, char *tag2, char *tag3);
1143*0Sstevel@tonic-gate int ldap_ufn_search_s(LDAP *ld, char *ufn, char **attrs,
1144*0Sstevel@tonic-gate 	int attrsonly, LDAPMessage **res);
1145*0Sstevel@tonic-gate LDAPFiltDesc *ldap_ufn_setfilter(LDAP *ld, char *fname);
1146*0Sstevel@tonic-gate void ldap_ufn_setprefix(LDAP *ld, char *prefix);
1147*0Sstevel@tonic-gate int ldap_ufn_timeout(void *tvparam);
1148*0Sstevel@tonic-gate 
1149*0Sstevel@tonic-gate 
1150*0Sstevel@tonic-gate /*
1151*0Sstevel@tonic-gate  * Unbind functions
1152*0Sstevel@tonic-gate  */
1153*0Sstevel@tonic-gate int ldap_unbind(LDAP *ld);
1154*0Sstevel@tonic-gate int ldap_unbind_s(LDAP *ld);
1155*0Sstevel@tonic-gate 
1156*0Sstevel@tonic-gate 
1157*0Sstevel@tonic-gate /*
1158*0Sstevel@tonic-gate  * Filter functions
1159*0Sstevel@tonic-gate  */
1160*0Sstevel@tonic-gate LDAPFiltDesc *ldap_init_getfilter(char *fname);
1161*0Sstevel@tonic-gate LDAPFiltDesc *ldap_init_getfilter_buf(char *buf, ssize_t buflen);
1162*0Sstevel@tonic-gate LDAPFiltInfo *ldap_getfirstfilter(LDAPFiltDesc *lfdp, char *tagpat,
1163*0Sstevel@tonic-gate 	char *value);
1164*0Sstevel@tonic-gate LDAPFiltInfo *ldap_getnextfilter(LDAPFiltDesc *lfdp);
1165*0Sstevel@tonic-gate void ldap_setfilteraffixes(LDAPFiltDesc *lfdp, char *prefix, char *suffix);
1166*0Sstevel@tonic-gate void ldap_build_filter(char *buf, size_t buflen,
1167*0Sstevel@tonic-gate 	char *pattern, char *prefix, char *suffix, char *attr,
1168*0Sstevel@tonic-gate 	char *value, char **valwords);
1169*0Sstevel@tonic-gate 
1170*0Sstevel@tonic-gate /*
1171*0Sstevel@tonic-gate  *  Functions to free LDAPFiltDesc and LDAPmod
1172*0Sstevel@tonic-gate  */
1173*0Sstevel@tonic-gate void ldap_getfilter_free(LDAPFiltDesc *lfdp);
1174*0Sstevel@tonic-gate void ldap_mods_free(LDAPMod **mods, int freemods);
1175*0Sstevel@tonic-gate 
1176*0Sstevel@tonic-gate /*
1177*0Sstevel@tonic-gate  * Friendly name functions
1178*0Sstevel@tonic-gate  */
1179*0Sstevel@tonic-gate char *ldap_friendly_name(char *filename, char *uname,
1180*0Sstevel@tonic-gate 	FriendlyMap **map);
1181*0Sstevel@tonic-gate void ldap_free_friendlymap(FriendlyMap **map);
1182*0Sstevel@tonic-gate 
1183*0Sstevel@tonic-gate 
1184*0Sstevel@tonic-gate /*
1185*0Sstevel@tonic-gate  * Connectionless LDAP functions
1186*0Sstevel@tonic-gate  */
1187*0Sstevel@tonic-gate LDAP *cldap_open(char *host, int port);
1188*0Sstevel@tonic-gate void cldap_close(LDAP *ld);
1189*0Sstevel@tonic-gate int cldap_search_s(LDAP *ld, char *base, int scope, char *filter,
1190*0Sstevel@tonic-gate 	char **attrs, int attrsonly, LDAPMessage **res, char *logdn);
1191*0Sstevel@tonic-gate void cldap_setretryinfo(LDAP *ld, int tries, time_t timeout);
1192*0Sstevel@tonic-gate 
1193*0Sstevel@tonic-gate 
1194*0Sstevel@tonic-gate /*
1195*0Sstevel@tonic-gate  * Sort functions
1196*0Sstevel@tonic-gate  */
1197*0Sstevel@tonic-gate int ldap_sort_entries(LDAP *ld, LDAPMessage **chain, char *attr,
1198*0Sstevel@tonic-gate 	int (*cmp)());
1199*0Sstevel@tonic-gate int ldap_sort_values(LDAP *ld, char **vals, int (*cmp)());
1200*0Sstevel@tonic-gate int ldap_sort_strcasecmp(char **a, char **b);
1201*0Sstevel@tonic-gate 
1202*0Sstevel@tonic-gate 
1203*0Sstevel@tonic-gate /*
1204*0Sstevel@tonic-gate  * URL functions
1205*0Sstevel@tonic-gate  */
1206*0Sstevel@tonic-gate int ldap_is_ldap_url(char *url);
1207*0Sstevel@tonic-gate int ldap_url_parse(char *url, LDAPURLDesc **ludpp);
1208*0Sstevel@tonic-gate void ldap_free_urlexts(LDAPURLExt **lues);
1209*0Sstevel@tonic-gate void ldap_free_urldesc(LDAPURLDesc *ludp);
1210*0Sstevel@tonic-gate int ldap_url_search(LDAP *ld, char *url, int attrsonly);
1211*0Sstevel@tonic-gate int ldap_url_search_s(LDAP *ld, char *url, int attrsonly,
1212*0Sstevel@tonic-gate 	LDAPMessage **res);
1213*0Sstevel@tonic-gate int ldap_url_search_st(LDAP *ld, char *url, int attrsonly,
1214*0Sstevel@tonic-gate 	struct timeval *timeout, LDAPMessage **res);
1215*0Sstevel@tonic-gate char *ldap_dns_to_url(LDAP *ld, char *dns_name, char *attrs,
1216*0Sstevel@tonic-gate char *scope, char *filter);
1217*0Sstevel@tonic-gate char *ldap_dn_to_url(LDAP *ld, char *dn, int nameparts);
1218*0Sstevel@tonic-gate 
1219*0Sstevel@tonic-gate 
1220*0Sstevel@tonic-gate /*
1221*0Sstevel@tonic-gate  * in Character Set functions
1222*0Sstevel@tonic-gate  */
1223*0Sstevel@tonic-gate #ifdef STR_TRANSLATION
1224*0Sstevel@tonic-gate void ldap_set_string_translators(LDAP *ld,
1225*0Sstevel@tonic-gate 	BERTranslateProc encode_proc, BERTranslateProc decode_proc);
1226*0Sstevel@tonic-gate int ldap_translate_from_t61(LDAP *ld, char **bufp,
1227*0Sstevel@tonic-gate 	unsigned int *lenp, int free_input);
1228*0Sstevel@tonic-gate int ldap_translate_to_t61(LDAP *ld, char **bufp,
1229*0Sstevel@tonic-gate 	unsigned int *lenp, int free_input);
1230*0Sstevel@tonic-gate void ldap_enable_translation(LDAP *ld, LDAPMessage *entry,
1231*0Sstevel@tonic-gate 	int enable);
1232*0Sstevel@tonic-gate 
1233*0Sstevel@tonic-gate #ifdef LDAP_CHARSET_8859
1234*0Sstevel@tonic-gate int ldap_t61_to_8859(char **bufp, unsigned int *buflenp,
1235*0Sstevel@tonic-gate 	int free_input);
1236*0Sstevel@tonic-gate int ldap_8859_to_t61(char **bufp, unsigned int *buflenp,
1237*0Sstevel@tonic-gate 	int free_input);
1238*0Sstevel@tonic-gate #endif /* LDAP_CHARSET_8859 */
1239*0Sstevel@tonic-gate #endif /* STR_TRANSLATION */
1240*0Sstevel@tonic-gate 
1241*0Sstevel@tonic-gate /*
1242*0Sstevel@tonic-gate  * Diplay Template functions
1243*0Sstevel@tonic-gate  */
1244*0Sstevel@tonic-gate typedef int (*writeptype)(void *writeparm, char *p, int len);
1245*0Sstevel@tonic-gate 
1246*0Sstevel@tonic-gate int ldap_init_templates(char *file,
1247*0Sstevel@tonic-gate 	struct ldap_disptmpl **tmpllistp);
1248*0Sstevel@tonic-gate 
1249*0Sstevel@tonic-gate int ldap_init_templates_buf(char *buf, ssize_t buflen,
1250*0Sstevel@tonic-gate 	struct ldap_disptmpl **tmpllistp);
1251*0Sstevel@tonic-gate 
1252*0Sstevel@tonic-gate void ldap_free_templates(struct ldap_disptmpl *tmpllist);
1253*0Sstevel@tonic-gate 
1254*0Sstevel@tonic-gate struct ldap_disptmpl *ldap_first_disptmpl(
1255*0Sstevel@tonic-gate 	struct ldap_disptmpl *tmpllist);
1256*0Sstevel@tonic-gate 
1257*0Sstevel@tonic-gate struct ldap_disptmpl *ldap_next_disptmpl(
1258*0Sstevel@tonic-gate 	struct ldap_disptmpl *tmpllist, struct ldap_disptmpl *tmpl);
1259*0Sstevel@tonic-gate 
1260*0Sstevel@tonic-gate struct ldap_disptmpl *ldap_name2template(char *name,
1261*0Sstevel@tonic-gate 	struct ldap_disptmpl *tmpllist);
1262*0Sstevel@tonic-gate 
1263*0Sstevel@tonic-gate struct ldap_disptmpl *ldap_oc2template(char **oclist,
1264*0Sstevel@tonic-gate 	struct ldap_disptmpl *tmpllist);
1265*0Sstevel@tonic-gate 
1266*0Sstevel@tonic-gate char **ldap_tmplattrs(struct ldap_disptmpl *tmpl,
1267*0Sstevel@tonic-gate 	char **includeattrs, int exclude, unsigned int syntaxmask);
1268*0Sstevel@tonic-gate 
1269*0Sstevel@tonic-gate struct ldap_tmplitem *ldap_first_tmplrow(struct ldap_disptmpl *tmpl);
1270*0Sstevel@tonic-gate 
1271*0Sstevel@tonic-gate struct ldap_tmplitem *ldap_next_tmplrow(struct ldap_disptmpl *tmpl,
1272*0Sstevel@tonic-gate 	struct ldap_tmplitem *row);
1273*0Sstevel@tonic-gate 
1274*0Sstevel@tonic-gate struct ldap_tmplitem *ldap_first_tmplcol(struct ldap_disptmpl *tmpl,
1275*0Sstevel@tonic-gate 	struct ldap_tmplitem *row);
1276*0Sstevel@tonic-gate 
1277*0Sstevel@tonic-gate struct ldap_tmplitem *ldap_next_tmplcol(struct ldap_disptmpl *tmpl,
1278*0Sstevel@tonic-gate 	struct ldap_tmplitem *row, struct ldap_tmplitem *col);
1279*0Sstevel@tonic-gate 
1280*0Sstevel@tonic-gate int ldap_entry2text(LDAP *ld, char *buf, LDAPMessage *entry,
1281*0Sstevel@tonic-gate 	struct ldap_disptmpl *tmpl, char **defattrs, char ***defvals,
1282*0Sstevel@tonic-gate 	writeptype writeproc, void *writeparm, char *eol,
1283*0Sstevel@tonic-gate 	int rdncount, unsigned int opts);
1284*0Sstevel@tonic-gate 
1285*0Sstevel@tonic-gate int ldap_vals2text(LDAP *ld, char *buf, char **vals, char *label,
1286*0Sstevel@tonic-gate 	int labelwidth, unsigned int syntaxid, writeptype writeproc,
1287*0Sstevel@tonic-gate 	void *writeparm, char *eol, int rdncount);
1288*0Sstevel@tonic-gate 
1289*0Sstevel@tonic-gate int ldap_entry2text_search(LDAP *ld, char *dn, char *base,
1290*0Sstevel@tonic-gate 	LDAPMessage *entry, struct ldap_disptmpl *tmpllist,
1291*0Sstevel@tonic-gate 	char **defattrs, char ***defvals, writeptype writeproc,
1292*0Sstevel@tonic-gate 	void *writeparm, char *eol, int rdncount, unsigned int opts);
1293*0Sstevel@tonic-gate 
1294*0Sstevel@tonic-gate int ldap_entry2html(LDAP *ld, char *buf, LDAPMessage *entry,
1295*0Sstevel@tonic-gate 	struct ldap_disptmpl *tmpl, char **defattrs, char ***defvals,
1296*0Sstevel@tonic-gate 	writeptype writeproc, void *writeparm, char *eol,
1297*0Sstevel@tonic-gate 	int rdncount, unsigned int opts, char *urlprefix, char *base);
1298*0Sstevel@tonic-gate 
1299*0Sstevel@tonic-gate int ldap_vals2html(LDAP *ld, char *buf, char **vals, char *label,
1300*0Sstevel@tonic-gate 	int labelwidth, unsigned int syntaxid, writeptype writeproc,
1301*0Sstevel@tonic-gate 	void *writeparm, char *eol, int rdncount, char *urlprefix);
1302*0Sstevel@tonic-gate 
1303*0Sstevel@tonic-gate int ldap_entry2html_search(LDAP *ld, char *dn, char *base,
1304*0Sstevel@tonic-gate 	LDAPMessage *entry, struct ldap_disptmpl *tmpllist,
1305*0Sstevel@tonic-gate 	char **defattrs, char ***defvals, writeptype writeproc,
1306*0Sstevel@tonic-gate 	void *writeparm, char *eol, int rdncount, unsigned int opts,
1307*0Sstevel@tonic-gate 	char *urlprefix);
1308*0Sstevel@tonic-gate 
1309*0Sstevel@tonic-gate 
1310*0Sstevel@tonic-gate /*
1311*0Sstevel@tonic-gate  * Search Preferences functions
1312*0Sstevel@tonic-gate  */
1313*0Sstevel@tonic-gate int ldap_init_searchprefs(char *file,
1314*0Sstevel@tonic-gate 	struct ldap_searchobj **solistp);
1315*0Sstevel@tonic-gate 
1316*0Sstevel@tonic-gate int ldap_init_searchprefs_buf(char *buf, ssize_t buflen,
1317*0Sstevel@tonic-gate 	struct ldap_searchobj **solistp);
1318*0Sstevel@tonic-gate 
1319*0Sstevel@tonic-gate void ldap_free_searchprefs(struct ldap_searchobj *solist);
1320*0Sstevel@tonic-gate 
1321*0Sstevel@tonic-gate struct ldap_searchobj *ldap_first_searchobj(
1322*0Sstevel@tonic-gate 	struct ldap_searchobj *solist);
1323*0Sstevel@tonic-gate 
1324*0Sstevel@tonic-gate struct ldap_searchobj *ldap_next_searchobj(
1325*0Sstevel@tonic-gate 	struct ldap_searchobj *sollist, struct ldap_searchobj *so);
1326*0Sstevel@tonic-gate 
1327*0Sstevel@tonic-gate 
1328*0Sstevel@tonic-gate /*
1329*0Sstevel@tonic-gate  * Option functions
1330*0Sstevel@tonic-gate  */
1331*0Sstevel@tonic-gate int ldap_get_option(LDAP *ld, int option, void *outvalue);
1332*0Sstevel@tonic-gate int ldap_set_option(LDAP *ld, int option, void *invalue);
1333*0Sstevel@tonic-gate 
1334*0Sstevel@tonic-gate 
1335*0Sstevel@tonic-gate /*
1336*0Sstevel@tonic-gate  * Control functions
1337*0Sstevel@tonic-gate  */
1338*0Sstevel@tonic-gate void ldap_control_free(LDAPControl *ctrl);
1339*0Sstevel@tonic-gate void ldap_controls_free(LDAPControl **ctrls);
1340*0Sstevel@tonic-gate 
1341*0Sstevel@tonic-gate 
1342*0Sstevel@tonic-gate /*
1343*0Sstevel@tonic-gate  * Simple Page Control functions
1344*0Sstevel@tonic-gate  */
1345*0Sstevel@tonic-gate int ldap_create_page_control(LDAP *ld, unsigned int pagesize,
1346*0Sstevel@tonic-gate 	struct berval *cookie, char isCritical, LDAPControl **output);
1347*0Sstevel@tonic-gate int ldap_parse_page_control(LDAP *ld, LDAPControl **controls,
1348*0Sstevel@tonic-gate 	unsigned int *totalcount, struct berval **cookie);
1349*0Sstevel@tonic-gate 
1350*0Sstevel@tonic-gate /*
1351*0Sstevel@tonic-gate  * Server Side Sort control functions
1352*0Sstevel@tonic-gate  */
1353*0Sstevel@tonic-gate int ldap_create_sort_control(LDAP *ld, LDAPsortkey **sortKeyList,
1354*0Sstevel@tonic-gate 	const char ctl_iscritical, LDAPControl **ctrlp);
1355*0Sstevel@tonic-gate int ldap_parse_sort_control(LDAP *ld, LDAPControl **ctrlp,
1356*0Sstevel@tonic-gate 	unsigned long *result, char **attribute);
1357*0Sstevel@tonic-gate int ldap_create_sort_keylist(LDAPsortkey ***sortKeyList, char *string_rep);
1358*0Sstevel@tonic-gate void ldap_free_sort_keylist(LDAPsortkey **sortKeyList);
1359*0Sstevel@tonic-gate 
1360*0Sstevel@tonic-gate /*
1361*0Sstevel@tonic-gate  * Virtual List View control functions
1362*0Sstevel@tonic-gate  */
1363*0Sstevel@tonic-gate int ldap_create_virtuallist_control(LDAP *ld, LDAPVirtualList *ldvlistp,
1364*0Sstevel@tonic-gate 	LDAPControl **ctrlp);
1365*0Sstevel@tonic-gate int ldap_parse_virtuallist_control(LDAP *ld, LDAPControl **ctrls,
1366*0Sstevel@tonic-gate 	unsigned long *target_posp, unsigned long *list_sizep,
1367*0Sstevel@tonic-gate 	int *errcodep);
1368*0Sstevel@tonic-gate 
1369*0Sstevel@tonic-gate #endif /* NEEDPROTOS */
1370*0Sstevel@tonic-gate 
1371*0Sstevel@tonic-gate #ifdef __cplusplus
1372*0Sstevel@tonic-gate }
1373*0Sstevel@tonic-gate #endif
1374*0Sstevel@tonic-gate 
1375*0Sstevel@tonic-gate #endif /* _LDAP_H */
1376