5 * Copyright 2001, 2003 Sun Microsystems, Inc. All rights reserved.
6 * Use is subject to license terms.
9 #pragma ident "%Z%%M% %I% %E% SMI"
12 #include <sys/types.h>
20 int ldap_abandon_ext(LDAP *ld, int msgid, LDAPControl **serverctrls, LDAPControl ** clientctrls);
22 int ldap_abandon( LDAP *ld, int msgid );
27 int ldap_add_ext( LDAP *ld, const char *dn, LDAPMod **attrs, LDAPControl ** serverctrls, LDAPControl **clientctrls, int *msgidp);
29 int ldap_add_ext_s( LDAP *ld, const char *dn, LDAPMod **attrs, LDAPControl ** serverctrls, LDAPControl **clientctrls);
31 int ldap_add( LDAP *ld, const char *dn, LDAPMod **attrs );
32 int ldap_add_s( LDAP *ld, const char *dn, LDAPMod **attrs );
37 int ldap_bind(LDAP *ld, const char *dn, const char *passwd, int authmethod);
38 int ldap_bind_s(LDAP *ld, const char *dn, const char *passwd, int authmethod);
39 void ldap_set_rebind_proc(LDAP *ld, LDAP_REBINDPROC_CALLBACK *rebindproc, void *arg);
44 int ldap_simple_bind( LDAP *ld, const char *dn, const char *passwd );
45 int ldap_simple_bind_s( LDAP *ld, const char *dn, const char *passwd );
50 int ldap_sasl_bind(LDAP *ld, const char *dn, const char *mechanism, const struct berval *cred, LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp);
52 int ldap_sasl_bind_s(LDAP *ld, const char *dn, const char *mechanism, const struct berval *cred, LDAPControl **serverctrls, LDAPControl **clientctrls, struct berval **servercredp);
65 int ldap_compare_ext(LDAP *ld, const char *dn, const char *attr, const struct berval *bvalue, LDAPControl ** serverctrls, LDAPControl **clientctrls, int *msgidp);
67 int ldap_compare_ext_s(LDAP *ld, const char *dn, const char *attr, const struct berval *bvalue, LDAPControl ** serverctrls, LDAPControl **clientctrls) ;
69 int ldap_compare( LDAP *ld, const char *dn, const char *attr, const char *value );
71 int ldap_compare_s( LDAP *ld, const char *dn, const char *attr, const char *value );
76 int ldap_delete_ext(LDAP *ld, const char *dn, LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp);
78 int ldap_delete_ext_s(LDAP *ld, const char *dn, LDAPControl **serverctrls, LDAPControl **clientctrls);
80 int ldap_delete( LDAP *ld, const char *dn );
81 int ldap_delete_s( LDAP *ld, const char *dn );
86 char *ldap_err2string( int err );
87 void ldap_perror(LDAP *ld, const char *s);
88 int ldap_result2error(LDAP *ld, LDAPMessage *r, int freeit);
89 int ldap_get_lderrno(LDAP *ld, char **m, char **s);
90 int ldap_set_lderrno(LDAP *ld, int e, char *m, char *s);
95 int ldap_modify_ext(LDAP *ld, const char *dn, LDAPMod **mods, LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp);
97 int ldap_modify_ext_s(LDAP *ld, const char *dn, LDAPMod **mods, LDAPControl **serverctrls, LDAPControl **clientctrls) ;
99 int ldap_modify( LDAP *ld, const char *dn, LDAPMod **mods );
100 int ldtap_modify_s( LDAP *ld, const char *dn, LDAPMod **mods );
109 int ldap_rename(LDAP *ld, const char *dn, const char *newrdn, const char *newparent, int deleteoldrdn, LDAPControl ** serverctrls, LDAPControl **clientctrls, int *msgidp);
111 int ldap_rename_s(LDAP *ld, const char *dn, const char *newrdn, const char *newparent, int deleteoldrdn, LDAPControl ** serverctrls, LDAPControl **clientctrls);
113 int ldap_modrdn(LDAP *ld, const char *dn, const char *newrdn);
114 int ldap_modrdn_s(LDAP *ld, const char *dn, const char *newrdn);
115 int ldap_modrdn2(LDAP *ld, const char *dn, const char *newrdn, int deleteoldrdn);
117 int ldap_modrdn2_s(LDAP *ld, const char *dn, const char *newrdn, int deleteoldrdn);
122 LDAP *ldap_init( const char *defhost, int defport );
123 LDAP *ldap_open(const char *host, int port);
124 int ldap_version(LDAPVersion *ver);
129 LDAPMessage *ldap_first_entry( LDAP *ld, LDAPMessage *res );
130 LDAPMessage *ldap_next_entry( LDAP *ld, LDAPMessage *entry );
131 int ldap_count_entries( LDAP *ld, LDAPMessage *res );
132 int ldap_get_entry_controls(LDAP *ld, LDAPMessage *entry, LDAPControl ***serverctrlsp);
137 LDAPMessage *ldap_first_message( LDAP *ld, LDAPMessage *res );
138 LDAPMessage *ldap_next_message( LDAP *ld, LDAPMessage *msg );
139 int ldap_count_messages( LDAP *ld, LDAPMessage *res );
144 LDAPMessage *ldap_first_reference( LDAP *ld, LDAPMessage *res );
145 LDAPMessage *ldap_next_reference( LDAP *ld, LDAPMessage *entry );
146 int ldap_count_references( LDAP *ld, LDAPMessage *res );
151 char *ldap_get_dn( LDAP *ld, LDAPMessage *entry );
152 char **ldap_explode_dn( const char *dn, const int notypes );
153 char ** ldap_explode_rdn( const char *rdn, const int notypes );
154 char *ldap_dn2ufn( const char *dn );
155 char **ldap_explode_dns( const char *dn );
156 int ldap_is_dns_dn( const char *dn );
157 char *ldap_dns_to_dn(char *dns_name, int *nameparts);
162 char *ldap_first_attribute( LDAP *ld, LDAPMessage *entry,
165 char *ldap_next_attribute( LDAP *ld, LDAPMessage *entry,
168 void ldap_memfree(void *p);
173 char **ldap_get_values( LDAP *ld, LDAPMessage *entry, const char *target );
174 int ldap_count_values( char **vals );
175 int ldap_count_values_len( struct berval **vals );
176 void ldap_value_free( char **vals );
177 void ldap_value_free_len( struct berval **vals );
179 struct berval **ldap_get_values_len(LDAP *ld, LDAPMessage *entry, const char *target);
181 char **ldap_get_lang_values(LDAP *ld, LDAPMessage *entry, const char *target, char **type);
183 struct berval **ldap_get_lang_values_len(LDAP *ld, LDAPMessage *entry, const char *target, char **type);
188 int ldap_parse_reference(LDAP *ld, LDAPMessage *ref,
189 char ***referralsp, LDAPControl ***serverctrlsp, int freeit);
190 char ** ldap_get_reference_urls(LDAP *ld, LDAPMessage *res);
195 int ldap_result( LDAP *ld, int msgid, int all,
196 struct timeval *timeout, LDAPMessage **result );
198 int ldap_msgfree( LDAPMessage *lm );
199 int ldap_msgtype( LDAPMessage *res );
200 int ldap_msgid( LDAPMessage *res );
201 int ldap_parse_result(LDAP *ld, LDAPMessage *res, int *errcodep, char **matcheddnp, char **errmsgp, char ***referralsp, LDAPControl ***serverctrlsp, int freeit) ;
203 int ldap_parse_sasl_bind_result(LDAP *ld, LDAPMessage *res, struct berval **servercredp, int freeit);
205 int ldap_parse_extended_result(LDAP *ld, LDAPMessage *res, char **resultoidp, struct berval **resultdata, int freeit);
210 int 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);
212 int 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);
214 int ldap_search( LDAP *ld, const char *base, int scope, const char *filter,
215 char **attrs, int attrsonly );
217 int ldap_search_s( LDAP *ld, const char *base, int scope, const char *filter,
218 char **attrs, int attrsonly, LDAPMessage **res );
220 int ldap_search_st( LDAP *ld, const char *base, int scope, const char *filter,
221 char **attrs, int attrsonly, struct timeval *timeout, LDAPMessage **res );
226 int ldap_ufn_search_c( LDAP *ld, char *ufn, char **attrs,
227 int attrsonly, LDAPMessage **res, LDAP_CANCELPROC_CALLBACK cancelproc,
230 int 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 );
234 int ldap_ufn_search_s( LDAP *ld, char *ufn, char **attrs,
235 int attrsonly, LDAPMessage **res );
237 LDAPFiltDesc *ldap_ufn_setfilter( LDAP *ld, char *fname );
238 void ldap_ufn_setprefix( LDAP *ld, char *prefix );
239 int ldap_ufn_timeout( void *tvparam );
245 int ldap_unbind( LDAP *ld );
246 int ldap_unbind_s( LDAP *ld );
247 int ldap_unbind_ext(LDAP *ld, LDAPControl **serverctrls, LDAPControl **clientctrls);
253 LDAPFiltDesc *ldap_init_getfilter( char *fname );
254 LDAPFiltDesc *ldap_init_getfilter_buf( char *buf, ssize_t buflen );
255 LDAPFiltInfo *ldap_getfirstfilter( LDAPFiltDesc *lfdp, char *tagpat,
258 LDAPFiltInfo *ldap_getnextfilter( LDAPFiltDesc *lfdp );
259 void ldap_setfilteraffixes( LDAPFiltDesc *lfdp, char *prefix, char *suffix );
260 void ldap_build_filter( char *filtbuf, size_t buflen,
261 char *pattern, char *prefix, char *suffix, char *attr,
262 char *value, char **valwords );
264 int ldap_create_filter(char *buf, unsigned long buflen, char *pattern, char *prefix, char *suffix, char *attr, char *value, char **valwords);
269 void ldap_getfilter_free( LDAPFiltDesc *lfdp );
270 void ldap_mods_free( LDAPMod **mods, int freemods );
271 void ldap_ber_free(BerElement *ber, int freebuf);
276 char *ldap_friendly_name( char *filename, char *uname,
279 void ldap_free_friendlymap( FriendlyMap *map );
290 int ldap_sort_entries( LDAP *ld, LDAPMessage **chain, char *attr,
293 int ldap_sort_values( LDAP *ld, char **vals, int (*cmp)() );
294 int ldap_sort_strcasecmp( const char **a, const char **b );
295 int ldap_multisort_entries(LDAP *ld, LDAPMessage **chain, char **attr, LDAP_CMP_CALLBACK *cmp);
301 int ldap_is_ldap_url( const char *url );
302 int ldap_url_parse( const char *url, LDAPURLDesc **ludpp );
303 int ldap_url_parse_nodn(const char *url, LDAPURLDesc **ludpp);
304 void ldap_free_urldesc( LDAPURLDesc *ludp );
305 int ldap_url_search( LDAP *ld, const char *url, int attrsonly );
306 int ldap_url_search_s( LDAP *ld, const char *url, int attrsonly,
309 int ldap_url_search_st( LDAP *ld, const char *url, int attrsonly,
310 struct timeval *timeout, LDAPMessage **res );
312 char *ldap_dns_to_url(LDAP *ld, char *dns_name, char *attrs,
313 char *scope, char *filter);
314 char *ldap_dn_to_url(LDAP *ld, char *dn, int nameparts);
320 void ldap_set_string_translators( LDAP *ld,
321 BERTranslateProc encode_proc, BERTranslateProc decode_proc );
323 int ldap_translate_from_t61( LDAP *ld, char **bufp,
324 unsigned int *lenp, int free_input );
326 int ldap_translate_to_t61( LDAP *ld, char **bufp,
327 unsigned int *lenp, int free_input );
329 void ldap_enable_translation( LDAP *ld, LDAPMessage *entry,
332 int ldap_t61_to_8859(char **bufp, unsigned long *buflenp,
335 int ldap_8859_to_t61(char **bufp, unsigned long *buflenp,
342 BerElement *ber_alloc_t(int options);
343 int ber_flatten(BerElement *ber, struct berval **bvPtr);
344 void ber_free(BerElement *ber, int freebuf);
345 BerElement *ber_alloc(void);
346 BerElement *ber_init(const struct berval *bv);
351 struct berval *ber_bvdup(const struct berval *bv);
352 void ber_bvecfree(struct berval **bv);
353 void ber_bvfree(struct berval *bv);
354 ber_tag_t ber_first_element(BerElement *ber, unsigned int *len, char **last);
355 ber_tag_t ber_next_element(BerElement *ber, ber_tag_t *len, char *last);
356 ber_tag_t ber_peek_tag(BerElement *ber, ber_tag_t *len);
357 ber_tag_t ber_scanf(BerElement *ber, const char *fmt, ...);
358 ber_tag_t ber_skip_tag(BerElement *ber, ber_tag_t *len);
359 ber_tag_t ber_get_int(BerElement *ber, ber_int_t *num);
364 int ber_printf(BerElement *ber, const char *fmt, ...);
369 void ldap_control_free (LDAPControl *ctrl);
370 void ldap_controls_free (LDAPControl **ctrls);
375 int ldap_create_page_control(LDAP *ld, unsigned int pagesize, struct berval *cookie, char isCritical, LDAPControl **output);
377 int ldap_parse_page_control(LDAP *ld, LDAPControl **controls, unsigned int *totalcount, struct berval **cookie);
382 int 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);
384 int 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);
386 int 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);
388 int 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);
390 int 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);
392 int ldap_vals2text(LDAP *ld, char *buf, char **vals, char *label, int labelwidth, unsigned long syntaxid, writeptype writeproc, void *writeparm, char *eol, int rdncount);
397 int ldap_extended_operation(LDAP *ld, const char *requestoid, const struct berval *requestdata, LDAPControl **serverctrls, LDAPControl**clientctrls, int *msgidp);
399 int ldap_extended_operation_s(LDAP *ld, const char *requestoid, const struct berval *requestdata, LDAPControl **serverctrls, LDAPControl **clientctrls, char **retoidp, struct berval **retdatap);
404 struct ldap_disptmpl *ldap_first_disptmpl(struct ldap_disptmpl *tmpllist);
405 struct ldap_tmplitem *ldap_first_tmplcol(struct ldap_disptmpl *tmpl,struct ldap_tmplitem *row);
407 struct ldap_tmplitem *ldap_first_tmplrow(struct ldap_disptmpl *tmpl);
408 void ldap_free_templates(struct ldap_disptmpl *tmpllist);
409 int ldap_init_templates(char *file, struct ldap_disptmpl **tmpllistp);
411 int ldap_init_templates_buf(char *buf, long buflen, struct ldap_disptmpl **tmpllistp);
413 struct ldap_disptmpl *ldap_next_disptmpl(struct ldap_disptmpl *tmpllist, struct ldap_disptmpl *tmpl);
415 struct ldap_tmplitem *ldap_next_tmplcol(struct ldap_disptmpl *tmpl, struct ldap_tmplitem *row, struct ldap_tmplitem *col);
417 struct ldap_tmplitem *ldap_next_tmplrow(struct ldap_disptmpl *tmpl, struct ldap_tmplitem *row);
419 struct ldap_disptmpl *ldap_oc2template(char **oclist, struct ldap_disptmpl *tmpllist);
421 char **ldap_tmplattrs(struct ldap_disptmpl *tmpl, char **includeattrs, int exclude, unsigned long syntaxmask);
423 struct ldap_disptmpl *ldap_name2template(char *name, struct ldap_disptmpl *tmpllist);
428 int ldap_sasl_cram_md5_bind_s(LDAP *ld, char *dn, struct berval *cred, LDAPControl **serverctrls, LDAPControl **clientctrls);
433 int ldap_set_option (LDAP *ld, int option, const void *optdata);
438 void ldaplogconfigf(FILE *fd);
443 char *ldif_type_and_value(char *type, char *val, int vlen);
444 char *str_getline(char **next);
445 int str_parse_line(char *line, char **type, char **value, int *vlen);
450 int ldap_create_sort_control (LDAP *ld, LDAPsortkey **sortKeyList, const char ctl_iscritical, LDAPControl **ctrlp);
452 int ldap_parse_sort_control(LDAP *ld, LDAPControl **ctrlp, unsigned long *result, char **attribute);
454 int ldap_create_sort_keylist(LDAPsortkey ***sortKeyList, const char *string_rep);
456 void ldap_free_sort_keylist(LDAPsortkey **sortKeyList);
461 int ldap_create_virtuallist_control(LDAP *ld, LDAPVirtualList *ldvlistp, LDAPControl **ctrlp);
463 int ldap_parse_virtuallist_control(LDAP *ld, LDAPControl **ctrls, unsigned long *target_posp, unsigned long *list_sizep, int *errcodep);
468 LDAP * ldapssl_init( const char *defhost, int defport, int defsecure );
469 int ldapssl_install_routines( LDAP *ld );
470 int ldapssl_enable_clientauth( LDAP *ld, char *keynickname, char *keypasswd, char *certnickname );
475 int ldapssl_client_init( const char *certdbpath, void *certdbhandle);
476 int ldapssl_clientauth_init(const char *certdbpath, void *certdbhandle, const int needkeydb, const char *keydbpath, void *keydbhandle);
478 int 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 );
480 int ldapssl_pkcs_init( const struct ldapssl_pkcs_fns *pfns);
485 const char * ldapssl_err2string( const int prerrno );
490 int ldap_create_persistentsearch_control(LDAP *ld, int changetypes, int changesonly, int return_echg_ctls, char ctl_iscritical, LDAPControl **ctrlp);
492 int ldap_parse_entrychange_control(LDAP *ld, LDAPControl **ctrls, int *chgtypep, char **prevdnp, int *chgnumpresentp, ber_int_t *chgnump);
497 int ldap_create_proxyauth_control(LDAP *ld, const char *dn, const char ctl_iscritical, LDAPControl **ctrlp);
499 int ldap_create_proxiedauth_control(LDAP *ld, const char *authzid, LDAPControl **ctrlp);
504 struct ldap_searchobj *ldap_first_searchobj(struct ldap_searchobj *solist);
505 void ldap_free_searchprefs(struct ldap_searchobj *solist);
506 int ldap_init_searchprefs(char *file, struct ldap_searchobj **solistp);
507 int ldap_init_searchprefs_buf(char *buf, long buflen, struct ldap_searchobj **solistp);
509 struct ldap_searchobj *ldap_next_searchobj(struct ldap_searchobj *solist, struct ldap_searchobj *so);
514 int ldap_get_option (LDAP *ld, int option, void *outvalue);
519 int ldap_memcache_init(unsigned long ttl, unsigned long size, char **baseDNs, struct ldap_thread_fns *thread_fns, LDAPMemCache **cachep);
521 int ldap_memcache_set(LDAP *ld, LDAPMemCache *cache);
522 int ldap_memcache_get(LDAP *ld, LDAPMemCache **cachep);
523 void ldap_memcache_flush(LDAPMemCache *cache, char *dn, int scope);
524 void ldap_memcache_destroy(LDAPMemCache *cache);
525 void ldap_memcache_update(LDAPMemCache *cache);
530 int ldap_x_sasl_digest_md5_bind_s(LDAP *ld, char *dn, struct berval *cred, LDAPControl **serverctrls, LDAPControl **clientctrls);