xref: /titanic_50/usr/src/lib/libsldap/common/llib-lsldap (revision cb5caa98562cf06753163f558cbcfe30b8f4673a)
17c478bd9Sstevel@tonic-gate/*
27c478bd9Sstevel@tonic-gate * CDDL HEADER START
37c478bd9Sstevel@tonic-gate *
47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*cb5caa98Sdjl * Common Development and Distribution License (the "License").
6*cb5caa98Sdjl * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate *
87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate * and limitations under the License.
127c478bd9Sstevel@tonic-gate *
137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate *
197c478bd9Sstevel@tonic-gate * CDDL HEADER END
207c478bd9Sstevel@tonic-gate */
217c478bd9Sstevel@tonic-gate/* LINTLIBRARY */
227c478bd9Sstevel@tonic-gate/* PROTOLIB1 */
237c478bd9Sstevel@tonic-gate
247c478bd9Sstevel@tonic-gate/*
25*cb5caa98Sdjl * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
267c478bd9Sstevel@tonic-gate * Use is subject to license terms.
277c478bd9Sstevel@tonic-gate */
287c478bd9Sstevel@tonic-gate#pragma ident	"%Z%%M%	%I%	%E% SMI"
297c478bd9Sstevel@tonic-gate
307c478bd9Sstevel@tonic-gate#include <stdio.h>
317c478bd9Sstevel@tonic-gate#include <sys/types.h>
327c478bd9Sstevel@tonic-gate#include <lber.h>
337c478bd9Sstevel@tonic-gate#include <ldap.h>
347c478bd9Sstevel@tonic-gate#include "ns_sldap.h"
357c478bd9Sstevel@tonic-gate
367c478bd9Sstevel@tonic-gate
377c478bd9Sstevel@tonic-gate/*
387c478bd9Sstevel@tonic-gate * Simplified LDAP Naming APIs
397c478bd9Sstevel@tonic-gate */
407c478bd9Sstevel@tonic-gateint __ns_ldap_list(
417c478bd9Sstevel@tonic-gate	const char *service,
427c478bd9Sstevel@tonic-gate	const char *filter,
437c478bd9Sstevel@tonic-gate	int (*init_filter_cb)(const ns_ldap_search_desc_t *desc,
447c478bd9Sstevel@tonic-gate			      char **realfilter, const void *userdata),
457c478bd9Sstevel@tonic-gate	const char * const *attribute,
467c478bd9Sstevel@tonic-gate	const ns_cred_t *cred,
477c478bd9Sstevel@tonic-gate	const int flags,
487c478bd9Sstevel@tonic-gate	ns_ldap_result_t ** result,
497c478bd9Sstevel@tonic-gate	ns_ldap_error_t ** errorp,
507c478bd9Sstevel@tonic-gate	int (*callback)(const ns_ldap_entry_t *entry, const void *userdata),
517c478bd9Sstevel@tonic-gate	const void *userdata);
527c478bd9Sstevel@tonic-gate
537c478bd9Sstevel@tonic-gateint  __ns_ldap_addAttr(
547c478bd9Sstevel@tonic-gate	const char *service,
557c478bd9Sstevel@tonic-gate	const char *dn,
567c478bd9Sstevel@tonic-gate	const ns_ldap_attr_t * const *attr,
577c478bd9Sstevel@tonic-gate	const ns_cred_t *cred,
587c478bd9Sstevel@tonic-gate	const int flags,
597c478bd9Sstevel@tonic-gate	ns_ldap_error_t **errorp);
607c478bd9Sstevel@tonic-gate
617c478bd9Sstevel@tonic-gateint __ns_ldap_delAttr(
627c478bd9Sstevel@tonic-gate	const char *service,
637c478bd9Sstevel@tonic-gate	const char *dn,
647c478bd9Sstevel@tonic-gate	const ns_ldap_attr_t * const *attr,
657c478bd9Sstevel@tonic-gate	const ns_cred_t *cred,
667c478bd9Sstevel@tonic-gate	const int flags,
677c478bd9Sstevel@tonic-gate	ns_ldap_error_t **errorp);
687c478bd9Sstevel@tonic-gate
697c478bd9Sstevel@tonic-gateint  __ns_ldap_repAttr(
707c478bd9Sstevel@tonic-gate	const char *service,
717c478bd9Sstevel@tonic-gate	const char *dn,
727c478bd9Sstevel@tonic-gate	const ns_ldap_attr_t * const *attr,
737c478bd9Sstevel@tonic-gate	const ns_cred_t *cred,
747c478bd9Sstevel@tonic-gate	const int flags,
757c478bd9Sstevel@tonic-gate	ns_ldap_error_t **errorp);
767c478bd9Sstevel@tonic-gate
777c478bd9Sstevel@tonic-gateint  __ns_ldap_addEntry(
787c478bd9Sstevel@tonic-gate	const char *service,
797c478bd9Sstevel@tonic-gate	const char *dn,
807c478bd9Sstevel@tonic-gate	const ns_ldap_entry_t *entry,
817c478bd9Sstevel@tonic-gate	const ns_cred_t *cred,
827c478bd9Sstevel@tonic-gate	const int flags,
837c478bd9Sstevel@tonic-gate	ns_ldap_error_t **errorp);
847c478bd9Sstevel@tonic-gate
857c478bd9Sstevel@tonic-gateint  __ns_ldap_addTypedEntry(
867c478bd9Sstevel@tonic-gate	const char *servicetype,
877c478bd9Sstevel@tonic-gate	const char *basedn,
887c478bd9Sstevel@tonic-gate	const void *data,
897c478bd9Sstevel@tonic-gate	const int  create,
907c478bd9Sstevel@tonic-gate	const ns_cred_t *cred,
917c478bd9Sstevel@tonic-gate	const int flags,
927c478bd9Sstevel@tonic-gate	ns_ldap_error_t **errorp);
937c478bd9Sstevel@tonic-gate
947c478bd9Sstevel@tonic-gateint __ns_ldap_delEntry(
957c478bd9Sstevel@tonic-gate	const char *service,
967c478bd9Sstevel@tonic-gate	const char *dn,
977c478bd9Sstevel@tonic-gate	const ns_cred_t *cred,
987c478bd9Sstevel@tonic-gate	const int flags,
997c478bd9Sstevel@tonic-gate	ns_ldap_error_t **errorp);
1007c478bd9Sstevel@tonic-gate
1017c478bd9Sstevel@tonic-gateint __ns_ldap_firstEntry(
1027c478bd9Sstevel@tonic-gate	const char *service,
1037c478bd9Sstevel@tonic-gate	const char *filter,
1047c478bd9Sstevel@tonic-gate	int (*init_filter_cb)(const ns_ldap_search_desc_t *desc,
1057c478bd9Sstevel@tonic-gate			      char **realfilter, const void *userdata),
1067c478bd9Sstevel@tonic-gate	const char * const *attribute,
1077c478bd9Sstevel@tonic-gate	const ns_cred_t *cred,
1087c478bd9Sstevel@tonic-gate	const int flags,
1097c478bd9Sstevel@tonic-gate	void **cookie,
1107c478bd9Sstevel@tonic-gate	ns_ldap_result_t ** result,
1117c478bd9Sstevel@tonic-gate	ns_ldap_error_t **errorp,
1127c478bd9Sstevel@tonic-gate	const void *userdata);
1137c478bd9Sstevel@tonic-gate
1147c478bd9Sstevel@tonic-gateint  __ns_ldap_nextEntry(
1157c478bd9Sstevel@tonic-gate	void *cookie,
1167c478bd9Sstevel@tonic-gate	ns_ldap_result_t ** result,
1177c478bd9Sstevel@tonic-gate	ns_ldap_error_t **errorp);
1187c478bd9Sstevel@tonic-gate
1197c478bd9Sstevel@tonic-gateint  __ns_ldap_endEntry(
1207c478bd9Sstevel@tonic-gate	void **cookie,
1217c478bd9Sstevel@tonic-gate	ns_ldap_error_t **errorp);
1227c478bd9Sstevel@tonic-gate
1237c478bd9Sstevel@tonic-gateint __ns_ldap_freeResult(
1247c478bd9Sstevel@tonic-gate	ns_ldap_result_t **result);
1257c478bd9Sstevel@tonic-gate
1267c478bd9Sstevel@tonic-gateint __ns_ldap_freeError(
1277c478bd9Sstevel@tonic-gate	ns_ldap_error_t **errorp);
1287c478bd9Sstevel@tonic-gate
1297c478bd9Sstevel@tonic-gateint __ns_ldap_freeCookie(
1307c478bd9Sstevel@tonic-gate	void **cookie);
1317c478bd9Sstevel@tonic-gate
1327c478bd9Sstevel@tonic-gateint  __ns_ldap_uid2dn(
1337c478bd9Sstevel@tonic-gate	const char *uid,
1347c478bd9Sstevel@tonic-gate	char **userDN,
1357c478bd9Sstevel@tonic-gate	const ns_cred_t *cred,
1367c478bd9Sstevel@tonic-gate	ns_ldap_error_t ** errorp);
1377c478bd9Sstevel@tonic-gate
1387c478bd9Sstevel@tonic-gateint  __ns_ldap_host2dn(
1397c478bd9Sstevel@tonic-gate	const char *host,
1407c478bd9Sstevel@tonic-gate	const char *domain,
1417c478bd9Sstevel@tonic-gate	char **hostDN,
1427c478bd9Sstevel@tonic-gate	const ns_cred_t *cred,
1437c478bd9Sstevel@tonic-gate	ns_ldap_error_t ** errorp);
1447c478bd9Sstevel@tonic-gate
1457c478bd9Sstevel@tonic-gateint  __ns_ldap_dn2domain(
1467c478bd9Sstevel@tonic-gate	const char *dn,
1477c478bd9Sstevel@tonic-gate	char **domain,
1487c478bd9Sstevel@tonic-gate	const ns_cred_t *cred,
1497c478bd9Sstevel@tonic-gate	ns_ldap_error_t **errorp);
1507c478bd9Sstevel@tonic-gate
1517c478bd9Sstevel@tonic-gateint __ns_ldap_auth(
1527c478bd9Sstevel@tonic-gate	const ns_cred_t *cred,
1537c478bd9Sstevel@tonic-gate	const int flag,
1547c478bd9Sstevel@tonic-gate	ns_ldap_error_t **errorp,
1557c478bd9Sstevel@tonic-gate	LDAPControl **serverctrls,
1567c478bd9Sstevel@tonic-gate	LDAPControl **clientctrls);
1577c478bd9Sstevel@tonic-gate
1587c478bd9Sstevel@tonic-gateint __ns_ldap_err2str(
1597c478bd9Sstevel@tonic-gate	int err,
1607c478bd9Sstevel@tonic-gate	char **strmsg);
1617c478bd9Sstevel@tonic-gate
1627c478bd9Sstevel@tonic-gateint __ns_ldap_setParam(
1637c478bd9Sstevel@tonic-gate	const ParamIndexType type,
1647c478bd9Sstevel@tonic-gate	const void *data,
1657c478bd9Sstevel@tonic-gate	ns_ldap_error_t **errorp);
1667c478bd9Sstevel@tonic-gate
1677c478bd9Sstevel@tonic-gateint __ns_ldap_getParam(
1687c478bd9Sstevel@tonic-gate	const ParamIndexType type,
1697c478bd9Sstevel@tonic-gate	void ***data,
1707c478bd9Sstevel@tonic-gate	ns_ldap_error_t **errorp);
1717c478bd9Sstevel@tonic-gate
1727c478bd9Sstevel@tonic-gateint __ns_ldap_freeParam(
1737c478bd9Sstevel@tonic-gate	void ***data);
1747c478bd9Sstevel@tonic-gate
1757c478bd9Sstevel@tonic-gatechar **__ns_ldap_getAttr(
1767c478bd9Sstevel@tonic-gate	const ns_ldap_entry_t *entry,
1777c478bd9Sstevel@tonic-gate	const char *attrname);
1787c478bd9Sstevel@tonic-gate
1797c478bd9Sstevel@tonic-gateint __s_api_prepend_automountmapname_to_dn(
1807c478bd9Sstevel@tonic-gate	const char *service,
1817c478bd9Sstevel@tonic-gate	char **basedn,
1827c478bd9Sstevel@tonic-gate	ns_ldap_error_t ** errorp);
1837c478bd9Sstevel@tonic-gate
1847c478bd9Sstevel@tonic-gatechar *__s_api_get_canonical_name(
1857c478bd9Sstevel@tonic-gate	ns_ldap_entry_t *entry,
1867c478bd9Sstevel@tonic-gate	ns_ldap_attr_t *attrptr,
1877c478bd9Sstevel@tonic-gate	int case_ignore);
188*cb5caa98Sdjl
189*cb5caa98Sdjlvoid __ns_ldap_setServer(
190*cb5caa98Sdjl	int set);
191*cb5caa98Sdjl
192*cb5caa98Sdjlns_ldap_error_t *__ns_ldap_LoadConfiguration(
193*cb5caa98Sdjl	void);
194*cb5caa98Sdjl
195*cb5caa98Sdjlns_ldap_error_t *__ns_ldap_DumpConfiguration(
196*cb5caa98Sdjl	char *file);
197*cb5caa98Sdjl
198*cb5caa98Sdjlns_ldap_error_t *__ns_ldap_DumpLdif(
199*cb5caa98Sdjl	char *filename);
200*cb5caa98Sdjl
201*cb5caa98Sdjlns_ldap_error_t *__ns_ldap_print_config(
202*cb5caa98Sdjl	int verbose);
203*cb5caa98Sdjl
204*cb5caa98Sdjlvoid __ns_ldap_default_config(
205*cb5caa98Sdjl	void);
206*cb5caa98Sdjl
207*cb5caa98Sdjlint __ns_ldap_download(
208*cb5caa98Sdjl	const char *profile,
209*cb5caa98Sdjl	char *addr,
210*cb5caa98Sdjl	char *baseDN,
211*cb5caa98Sdjl	ns_ldap_error_t **errorp);
212*cb5caa98Sdjl
213*cb5caa98Sdjlint __ns_ldap_check_dns_preq(
214*cb5caa98Sdjl	int foreground,
215*cb5caa98Sdjl	int mode_verbose,
216*cb5caa98Sdjl	int mode_quiet,
217*cb5caa98Sdjl	const char *fname,
218*cb5caa98Sdjl	ns_ldap_self_gssapi_config_t config,
219*cb5caa98Sdjl	ns_ldap_error_t **errpp);
220*cb5caa98Sdjl
221*cb5caa98Sdjlint __ns_ldap_check_gssapi_preq(
222*cb5caa98Sdjl	int foreground,
223*cb5caa98Sdjl	int mode_verbose,
224*cb5caa98Sdjl	int mode_quiet,
225*cb5caa98Sdjl	ns_ldap_self_gssapi_config_t config,
226*cb5caa98Sdjl	ns_ldap_error_t **errpp);
227*cb5caa98Sdjl
228*cb5caa98Sdjlint __ns_ldap_check_all_preq(
229*cb5caa98Sdjl	int foreground,
230*cb5caa98Sdjl	int mode_verbose,
231*cb5caa98Sdjl	int mode_quiet,
232*cb5caa98Sdjl	ns_ldap_self_gssapi_config_t config,
233*cb5caa98Sdjl	ns_ldap_error_t **errpp);
234