xref: /titanic_41/usr/src/lib/libldap5/sources/ldap/common/llib-lldap (revision 2b24ab6b3865caeede9eeb9db6b83e1d89dcd1ea)
1/* LINTLIBRARY */
2/* PROTOLIB1 */
3
4/*
5 * Copyright 2001, 2003 Sun Microsystems, Inc.  All rights reserved.
6 * Use is subject to license terms.
7 */
8
9#pragma ident	"%Z%%M%	%I%	%E% SMI"
10
11#include <stdio.h>
12#include <sys/types.h>
13#include <lber.h>
14#include <ldap.h>
15
16
17/*
18 * in abandon.c:
19 */
20int ldap_abandon_ext(LDAP *ld, int msgid, LDAPControl **serverctrls, LDAPControl ** clientctrls);
21
22int ldap_abandon( LDAP *ld, int msgid );
23
24/*
25 * in add.c:
26 */
27int ldap_add_ext( LDAP *ld, const char *dn, LDAPMod **attrs, LDAPControl ** serverctrls, LDAPControl **clientctrls, int *msgidp);
28
29int ldap_add_ext_s( LDAP *ld, const char *dn, LDAPMod **attrs, LDAPControl ** serverctrls, LDAPControl **clientctrls);
30
31int ldap_add( LDAP *ld, const char *dn, LDAPMod **attrs );
32int ldap_add_s( LDAP *ld, const char *dn, LDAPMod **attrs );
33
34/*
35 * in bind.c:
36 */
37int ldap_bind(LDAP *ld, const char *dn, const char *passwd, int authmethod);
38int ldap_bind_s(LDAP *ld, const char *dn, const char *passwd, int authmethod);
39void ldap_set_rebind_proc(LDAP *ld, LDAP_REBINDPROC_CALLBACK *rebindproc, void *arg);
40
41/*
42 * in sbind.c:
43 */
44int ldap_simple_bind( LDAP *ld, const char *dn, const char *passwd );
45int ldap_simple_bind_s( LDAP *ld, const char *dn, const char *passwd );
46
47/*
48 * in saslbind.c:
49 */
50int ldap_sasl_bind(LDAP *ld, const char *dn, const char *mechanism, const struct berval *cred, LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp);
51
52int ldap_sasl_bind_s(LDAP *ld, const char *dn, const char *mechanism, const struct berval *cred, LDAPControl **serverctrls, LDAPControl **clientctrls, struct berval **servercredp);
53
54/*
55 * in kbind.c:
56 */
57
58/*
59 * in cache.c
60 */
61
62/*
63 * in compare.c:
64 */
65int ldap_compare_ext(LDAP *ld, const char *dn, const char *attr, const struct berval *bvalue, LDAPControl ** serverctrls, LDAPControl **clientctrls, int *msgidp);
66
67int ldap_compare_ext_s(LDAP *ld, const char *dn, const char *attr, const struct berval *bvalue, LDAPControl ** serverctrls, LDAPControl **clientctrls) ;
68
69int ldap_compare( LDAP *ld, const char *dn, const char *attr, const char *value );
70
71int ldap_compare_s( LDAP *ld, const char *dn, const char *attr, const char *value );
72
73/*
74 * in delete.c:
75 */
76int ldap_delete_ext(LDAP *ld, const char *dn, LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp);
77
78int ldap_delete_ext_s(LDAP *ld, const char *dn, LDAPControl **serverctrls, LDAPControl **clientctrls);
79
80int ldap_delete( LDAP *ld, const char *dn );
81int ldap_delete_s( LDAP *ld, const char *dn );
82
83/*
84 * in error.c:
85 */
86char *ldap_err2string( int err );
87void ldap_perror(LDAP *ld, const char *s);
88int ldap_result2error(LDAP *ld, LDAPMessage *r, int freeit);
89int ldap_get_lderrno(LDAP *ld, char **m, char **s);
90int ldap_set_lderrno(LDAP *ld, int e, char *m, char *s);
91
92/*
93 * in modify.c:
94 */
95int ldap_modify_ext(LDAP *ld, const char *dn, LDAPMod **mods, LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp);
96
97int ldap_modify_ext_s(LDAP *ld, const char *dn, LDAPMod **mods, LDAPControl **serverctrls, LDAPControl **clientctrls) ;
98
99int ldap_modify( LDAP *ld, const char *dn, LDAPMod **mods );
100int ldtap_modify_s( LDAP *ld, const char *dn, LDAPMod **mods );
101
102/*
103 * in modrdn.c:
104 */
105
106/*
107 * in rename.c:
108 */
109int ldap_rename(LDAP *ld, const char *dn, const char *newrdn, const char *newparent, int deleteoldrdn, LDAPControl ** serverctrls, LDAPControl **clientctrls, int *msgidp);
110
111int ldap_rename_s(LDAP *ld, const char *dn, const char *newrdn, const char *newparent, int deleteoldrdn, LDAPControl ** serverctrls, LDAPControl **clientctrls);
112
113int ldap_modrdn(LDAP *ld, const char *dn, const char *newrdn);
114int ldap_modrdn_s(LDAP *ld, const char *dn, const char *newrdn);
115int ldap_modrdn2(LDAP *ld, const char *dn, const char *newrdn, int deleteoldrdn);
116
117int ldap_modrdn2_s(LDAP *ld, const char *dn, const char *newrdn, int deleteoldrdn);
118
119/*
120 * in open.c:
121 */
122LDAP *ldap_init( const char *defhost, int defport );
123LDAP *ldap_open(const char *host, int port);
124int ldap_version(LDAPVersion *ver);
125
126/*
127 * in getentry.c:
128 */
129LDAPMessage *ldap_first_entry( LDAP *ld, LDAPMessage *res );
130LDAPMessage *ldap_next_entry( LDAP *ld, LDAPMessage *entry );
131int ldap_count_entries( LDAP *ld, LDAPMessage *res );
132int ldap_get_entry_controls(LDAP *ld, LDAPMessage *entry, LDAPControl ***serverctrlsp);
133
134/*
135 * in getmsg.c:
136 */
137LDAPMessage *ldap_first_message( LDAP *ld, LDAPMessage *res );
138LDAPMessage *ldap_next_message( LDAP *ld, LDAPMessage *msg );
139int ldap_count_messages( LDAP *ld, LDAPMessage *res );
140
141/*
142 * in getref.c:
143 */
144LDAPMessage *ldap_first_reference( LDAP *ld, LDAPMessage *res );
145LDAPMessage *ldap_next_reference( LDAP *ld, LDAPMessage *entry );
146int ldap_count_references( LDAP *ld, LDAPMessage *res );
147
148/*
149 * in getdn.c
150 */
151char *ldap_get_dn( LDAP *ld, LDAPMessage *entry );
152char **ldap_explode_dn( const char *dn, const int notypes );
153char ** ldap_explode_rdn( const char *rdn, const int notypes );
154char *ldap_dn2ufn( const char *dn );
155char **ldap_explode_dns( const char *dn );
156int ldap_is_dns_dn( const char *dn );
157char *ldap_dns_to_dn(char *dns_name, int *nameparts);
158
159/*
160 * in getattr.c
161 */
162char *ldap_first_attribute( LDAP *ld, LDAPMessage *entry,
163	BerElement **ber );
164
165char *ldap_next_attribute( LDAP *ld, LDAPMessage *entry,
166	BerElement *ber );
167
168void ldap_memfree(void *p);
169
170/*
171 * in getvalues.c
172 */
173char **ldap_get_values( LDAP *ld, LDAPMessage *entry, const char *target );
174int ldap_count_values( char **vals );
175int ldap_count_values_len( struct berval **vals );
176void ldap_value_free( char **vals );
177void ldap_value_free_len( struct berval **vals );
178
179struct berval **ldap_get_values_len(LDAP *ld, LDAPMessage *entry, const char *target);
180
181char **ldap_get_lang_values(LDAP *ld, LDAPMessage *entry, const char *target, char **type);
182
183struct berval **ldap_get_lang_values_len(LDAP *ld, LDAPMessage *entry, const char *target, char **type);
184
185/*
186 * in referral.c:
187 */
188int ldap_parse_reference(LDAP *ld, LDAPMessage *ref,
189        char ***referralsp, LDAPControl ***serverctrlsp, int freeit);
190char ** ldap_get_reference_urls(LDAP *ld, LDAPMessage *res);
191
192/*
193 * in result.c:
194 */
195int ldap_result( LDAP *ld, int msgid, int all,
196	struct timeval *timeout, LDAPMessage **result );
197
198int ldap_msgfree( LDAPMessage *lm );
199int ldap_msgtype( LDAPMessage *res );
200int ldap_msgid( LDAPMessage *res );
201int ldap_parse_result(LDAP *ld, LDAPMessage *res, int *errcodep, char **matcheddnp, char **errmsgp, char ***referralsp, LDAPControl ***serverctrlsp, int freeit) ;
202
203int ldap_parse_sasl_bind_result(LDAP *ld, LDAPMessage *res, struct berval **servercredp, int freeit);
204
205int ldap_parse_extended_result(LDAP *ld, LDAPMessage *res, char **resultoidp, struct berval **resultdata, int freeit);
206
207/*
208 * in search.c:
209 */
210int ldap_search_ext(LDAP *ld, const char *base, int scope, const char *filter, char **attrs, int attrsonly, LDAPControl **serverctrls, LDAPControl **clientctrls, struct timeval *timeoutp, int sizelimit, int *msgidp);
211
212int ldap_search_ext_s(LDAP *ld, const char *base, int scope, const char *filter, char **attrs, int attrsonly, LDAPControl **serverctrls, LDAPControl **clientctrls, struct timeval *timeoutp, int sizelimit, LDAPMessage **res);
213
214int ldap_search( LDAP *ld, const char *base, int scope, const char *filter,
215	char **attrs, int attrsonly );
216
217int ldap_search_s( LDAP *ld, const char *base, int scope, const char *filter,
218	char **attrs, int attrsonly, LDAPMessage **res );
219
220int ldap_search_st( LDAP *ld, const char *base, int scope, const char *filter,
221    char **attrs, int attrsonly, struct timeval *timeout, LDAPMessage **res );
222
223/*
224 * in ufn.c
225 */
226int ldap_ufn_search_c( LDAP *ld, char *ufn, char **attrs,
227	int attrsonly, LDAPMessage **res, LDAP_CANCELPROC_CALLBACK cancelproc,
228	void *cancelparm );
229
230int ldap_ufn_search_ct( LDAP *ld, char *ufn, char **attrs,
231	int attrsonly, LDAPMessage **res, LDAP_CANCELPROC_CALLBACK cancelproc,
232	void *cancelparm, char *tag1, char *tag2, char *tag3 );
233
234int ldap_ufn_search_s( LDAP *ld, char *ufn, char **attrs,
235	int attrsonly, LDAPMessage **res );
236
237LDAPFiltDesc *ldap_ufn_setfilter( LDAP *ld, char *fname );
238void ldap_ufn_setprefix( LDAP *ld, char *prefix );
239int ldap_ufn_timeout( void *tvparam );
240
241
242/*
243 * in unbind.c
244 */
245int ldap_unbind( LDAP *ld );
246int ldap_unbind_s( LDAP *ld );
247int ldap_unbind_ext(LDAP *ld, LDAPControl **serverctrls, LDAPControl **clientctrls);
248
249
250/*
251 * in getfilter.c
252 */
253LDAPFiltDesc *ldap_init_getfilter( char *fname );
254LDAPFiltDesc *ldap_init_getfilter_buf( char *buf, ssize_t buflen );
255LDAPFiltInfo *ldap_getfirstfilter( LDAPFiltDesc *lfdp, char *tagpat,
256	char *value );
257
258LDAPFiltInfo *ldap_getnextfilter( LDAPFiltDesc *lfdp );
259void ldap_setfilteraffixes( LDAPFiltDesc *lfdp, char *prefix, char *suffix );
260void ldap_build_filter( char *filtbuf, size_t buflen,
261	char *pattern, char *prefix, char *suffix, char *attr,
262	char *value, char **valwords );
263
264int ldap_create_filter(char *buf, unsigned long buflen, char *pattern, char *prefix, char *suffix, char *attr, char *value, char **valwords);
265
266/*
267 * in free.c
268 */
269void ldap_getfilter_free( LDAPFiltDesc *lfdp );
270void ldap_mods_free( LDAPMod **mods, int freemods );
271void ldap_ber_free(BerElement *ber, int freebuf);
272
273/*
274 * in friendly.c
275 */
276char *ldap_friendly_name( char *filename, char *uname,
277	FriendlyMap *map );
278
279void ldap_free_friendlymap( FriendlyMap *map );
280
281
282/*
283 * in cldap.c
284 */
285
286
287/*
288 * in sort.c
289 */
290int ldap_sort_entries( LDAP *ld, LDAPMessage **chain, char *attr,
291	int (*cmp)() );
292
293int ldap_sort_values( LDAP *ld, char **vals, int (*cmp)() );
294int ldap_sort_strcasecmp( const char **a, const char **b );
295int ldap_multisort_entries(LDAP *ld, LDAPMessage **chain, char **attr, LDAP_CMP_CALLBACK *cmp);
296
297
298/*
299 * in url.c
300 */
301int ldap_is_ldap_url( const char *url );
302int ldap_url_parse( const char *url, LDAPURLDesc **ludpp );
303int ldap_url_parse_nodn(const char *url, LDAPURLDesc **ludpp);
304void ldap_free_urldesc( LDAPURLDesc *ludp );
305int ldap_url_search( LDAP *ld, const char *url, int attrsonly );
306int ldap_url_search_s( LDAP *ld, const char *url, int attrsonly,
307	LDAPMessage **res );
308
309int ldap_url_search_st( LDAP *ld, const char *url, int attrsonly,
310	struct timeval *timeout, LDAPMessage **res );
311
312char *ldap_dns_to_url(LDAP *ld, char *dns_name, char *attrs,
313char *scope, char *filter);
314char *ldap_dn_to_url(LDAP *ld, char *dn, int nameparts);
315
316
317/*
318 * in charset.c
319 */
320void ldap_set_string_translators( LDAP *ld,
321	BERTranslateProc encode_proc, BERTranslateProc decode_proc );
322
323int ldap_translate_from_t61( LDAP *ld, char **bufp,
324	unsigned int *lenp, int free_input );
325
326int ldap_translate_to_t61( LDAP *ld, char **bufp,
327	unsigned int *lenp, int free_input );
328
329void ldap_enable_translation( LDAP *ld, LDAPMessage *entry,
330	int enable );
331
332int ldap_t61_to_8859(char **bufp, unsigned long *buflenp,
333        int free_input);
334
335int ldap_8859_to_t61(char **bufp, unsigned long *buflenp,
336        int free_input);
337
338
339/*
340 * in io.c
341 */
342BerElement *ber_alloc_t(int options);
343int ber_flatten(BerElement *ber, struct berval **bvPtr);
344void ber_free(BerElement *ber, int freebuf);
345BerElement *ber_alloc(void);
346BerElement *ber_init(const struct berval *bv);
347
348/*
349 * in decode.c
350 */
351struct berval *ber_bvdup(const struct berval *bv);
352void ber_bvecfree(struct berval **bv);
353void ber_bvfree(struct berval *bv);
354ber_tag_t ber_first_element(BerElement *ber, unsigned int *len, char **last);
355ber_tag_t ber_next_element(BerElement *ber, ber_tag_t *len, char *last);
356ber_tag_t ber_peek_tag(BerElement *ber, ber_tag_t *len);
357ber_tag_t ber_scanf(BerElement *ber, const char *fmt, ...);
358ber_tag_t ber_skip_tag(BerElement *ber, ber_tag_t *len);
359ber_tag_t ber_get_int(BerElement *ber, ber_int_t *num);
360
361/*
362 * in encode.c
363 */
364int ber_printf(BerElement *ber, const char *fmt, ...);
365
366/*
367 * in control.c
368 */
369void ldap_control_free (LDAPControl *ctrl);
370void ldap_controls_free (LDAPControl **ctrls);
371
372/*
373 * in spagectrl.c
374 */
375int ldap_create_page_control(LDAP *ld, unsigned int pagesize, struct berval *cookie, char isCritical, LDAPControl **output);
376
377int ldap_parse_page_control(LDAP *ld, LDAPControl **controls, unsigned int *totalcount, struct berval **cookie);
378
379/*
380 * in tmplout.c
381 */
382int ldap_entry2html(LDAP *ld, char *buf, LDAPMessage *entry, struct ldap_disptmpl *tmpl, char **defattrs, char ***defvals, writeptype writeproc, void *writeparm, char *eol, int rdncount, unsigned long opts, char *urlprefix, char *base);
383
384int ldap_entry2html_search(LDAP *ld, char *dn, char *base, LDAPMessage *entry, struct ldap_disptmpl*tmpllist, char **defattrs, char ***defvals, writeptype writeproc, void *writeparm, char *eol,int rdncount, unsigned long opts, char *urlprefix);
385
386int ldap_entry2text(LDAP *ld, char *buf, LDAPMessage *entry, struct ldap_disptmpl *tmpl, char **defattrs, char ***defvals, writeptype writeproc, void *writeparm, char *eol, int rdncount, unsigned long opts);
387
388int ldap_entry2text_search(LDAP *ld,char *dn, char *base, LDAPMessage *entry, struct ldap_disptmpl*tmpllist, char **defattrs, char ***defvals, writeptype writeproc, void *writeparm, char *eol,int rdncount, unsigned long opts);
389
390int ldap_vals2html(LDAP *ld, char *buf, char **vals, char *label, int labelwidth, unsigned long syntaxid, writeptype writeproc, void *writeparm, char *eol, int rdncount, char *urlprefix);
391
392int ldap_vals2text(LDAP *ld, char *buf, char **vals, char *label, int labelwidth, unsigned long syntaxid, writeptype writeproc, void *writeparm, char *eol, int rdncount);
393
394/*
395 * in extendop.c
396 */
397int ldap_extended_operation(LDAP *ld, const char *requestoid, const struct berval *requestdata, LDAPControl **serverctrls, LDAPControl**clientctrls, int *msgidp);
398
399int ldap_extended_operation_s(LDAP *ld, const char *requestoid, const struct berval *requestdata, LDAPControl **serverctrls, LDAPControl **clientctrls, char **retoidp, struct berval **retdatap);
400
401/*
402 * in disptmpl.c
403 */
404struct ldap_disptmpl *ldap_first_disptmpl(struct ldap_disptmpl *tmpllist);
405struct ldap_tmplitem *ldap_first_tmplcol(struct ldap_disptmpl *tmpl,struct ldap_tmplitem *row);
406
407struct ldap_tmplitem *ldap_first_tmplrow(struct ldap_disptmpl *tmpl);
408void ldap_free_templates(struct ldap_disptmpl *tmpllist);
409int ldap_init_templates(char *file, struct ldap_disptmpl **tmpllistp);
410
411int ldap_init_templates_buf(char *buf, long buflen, struct ldap_disptmpl **tmpllistp);
412
413struct ldap_disptmpl *ldap_next_disptmpl(struct ldap_disptmpl *tmpllist, struct ldap_disptmpl *tmpl);
414
415struct ldap_tmplitem *ldap_next_tmplcol(struct ldap_disptmpl *tmpl, struct ldap_tmplitem *row, struct ldap_tmplitem *col);
416
417struct ldap_tmplitem *ldap_next_tmplrow(struct ldap_disptmpl *tmpl, struct ldap_tmplitem *row);
418
419struct ldap_disptmpl *ldap_oc2template(char **oclist, struct ldap_disptmpl *tmpllist);
420
421char **ldap_tmplattrs(struct ldap_disptmpl *tmpl, char **includeattrs, int exclude, unsigned long syntaxmask);
422
423struct ldap_disptmpl *ldap_name2template(char *name, struct ldap_disptmpl *tmpllist);
424
425/*
426 * in cram_md5.c
427 */
428int ldap_sasl_cram_md5_bind_s(LDAP *ld, char *dn, struct berval *cred, LDAPControl **serverctrls, LDAPControl **clientctrls);
429
430/*
431 * in setoption.c
432 */
433int ldap_set_option (LDAP *ld, int option, const void *optdata);
434
435/*
436 * in log.c
437 */
438void ldaplogconfigf(FILE *fd);
439
440/*
441 * in line64.c
442 */
443char *ldif_type_and_value(char *type, char *val, int vlen);
444char *str_getline(char **next);
445int str_parse_line(char *line, char **type, char **value, int *vlen);
446
447/*
448 * in sortctrl.c
449 */
450int ldap_create_sort_control (LDAP *ld, LDAPsortkey **sortKeyList, const char ctl_iscritical, LDAPControl **ctrlp);
451
452int ldap_parse_sort_control(LDAP *ld, LDAPControl **ctrlp, unsigned long *result, char **attribute);
453
454int ldap_create_sort_keylist(LDAPsortkey ***sortKeyList, const char *string_rep);
455
456void ldap_free_sort_keylist(LDAPsortkey **sortKeyList);
457
458/*
459 * in vlistctrl.c
460 */
461int ldap_create_virtuallist_control(LDAP *ld, LDAPVirtualList *ldvlistp, LDAPControl **ctrlp);
462
463int ldap_parse_virtuallist_control(LDAP *ld, LDAPControl **ctrls, unsigned long *target_posp, unsigned long *list_sizep, int *errcodep);
464
465/*
466 * in ldapsinit.c
467 */
468LDAP * ldapssl_init( const char *defhost, int defport, int defsecure );
469int ldapssl_install_routines( LDAP *ld );
470int ldapssl_enable_clientauth( LDAP *ld, char *keynickname, char *keypasswd, char *certnickname );
471
472/*
473 * in clientinit.c
474 */
475int ldapssl_client_init( const char *certdbpath, void *certdbhandle);
476int ldapssl_clientauth_init(const char *certdbpath, void *certdbhandle, const int needkeydb, const char *keydbpath, void *keydbhandle);
477
478int ldapssl_advclientauth_init( const char *certdbpath, void *certdbhandle, const int needkeydb, const char *keydbpath, void *keydbhandle, const int needsecmoddb, const char *secmoddbpath, const int sslstrength );
479
480int ldapssl_pkcs_init( const struct ldapssl_pkcs_fns *pfns);
481
482/*
483 * in errormap.c
484 */
485const char * ldapssl_err2string( const int prerrno );
486
487/*
488 * in psearch.c
489 */
490int ldap_create_persistentsearch_control(LDAP *ld, int changetypes, int changesonly, int return_echg_ctls, char ctl_iscritical, LDAPControl **ctrlp);
491
492int ldap_parse_entrychange_control(LDAP *ld, LDAPControl **ctrls, int *chgtypep, char **prevdnp, int *chgnumpresentp, ber_int_t *chgnump);
493
494/*
495 * in proxyauthctrl.c
496 */
497int ldap_create_proxyauth_control(LDAP *ld, const char *dn, const char ctl_iscritical, LDAPControl **ctrlp);
498
499int ldap_create_proxiedauth_control(LDAP *ld, const char *authzid, LDAPControl **ctrlp);
500
501/*
502 * in srchpref.c
503 */
504struct ldap_searchobj *ldap_first_searchobj(struct ldap_searchobj *solist);
505void ldap_free_searchprefs(struct ldap_searchobj *solist);
506int ldap_init_searchprefs(char *file, struct ldap_searchobj **solistp);
507int ldap_init_searchprefs_buf(char *buf, long buflen, struct ldap_searchobj **solistp);
508
509struct ldap_searchobj *ldap_next_searchobj(struct ldap_searchobj *solist, struct ldap_searchobj *so);
510
511/*
512 * in getoption.c
513 */
514int ldap_get_option (LDAP *ld, int option, void *outvalue);
515
516/*
517 * in memcache.c
518 */
519int ldap_memcache_init(unsigned long ttl, unsigned long size, char **baseDNs, struct ldap_thread_fns *thread_fns, LDAPMemCache **cachep);
520
521int ldap_memcache_set(LDAP *ld, LDAPMemCache *cache);
522int ldap_memcache_get(LDAP *ld, LDAPMemCache **cachep);
523void ldap_memcache_flush(LDAPMemCache *cache, char *dn, int scope);
524void ldap_memcache_destroy(LDAPMemCache *cache);
525void ldap_memcache_update(LDAPMemCache *cache);
526
527/*
528 * in digest_md5.c
529 */
530int ldap_x_sasl_digest_md5_bind_s(LDAP *ld, char *dn, struct berval *cred, LDAPControl **serverctrls, LDAPControl **clientctrls);
531