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
545916cd2Sjpk  * Common Development and Distribution License (the "License").
645916cd2Sjpk  * 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 /*
22479ac375Sdm  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate #ifndef	_NS_SLDAP_H
287c478bd9Sstevel@tonic-gate #define	_NS_SLDAP_H
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #ifdef __cplusplus
317c478bd9Sstevel@tonic-gate extern "C" {
327c478bd9Sstevel@tonic-gate #endif
337c478bd9Sstevel@tonic-gate 
347c478bd9Sstevel@tonic-gate #include <stdio.h>
357c478bd9Sstevel@tonic-gate #include <sys/types.h>
367c478bd9Sstevel@tonic-gate #include <lber.h>
377c478bd9Sstevel@tonic-gate #include <ldap.h>
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate /*
407c478bd9Sstevel@tonic-gate  * Version
417c478bd9Sstevel@tonic-gate  */
427c478bd9Sstevel@tonic-gate #define	NS_LDAP_VERSION		NS_LDAP_VERSION_2
437c478bd9Sstevel@tonic-gate #define	NS_LDAP_VERSION_1	"1.0"
447c478bd9Sstevel@tonic-gate #define	NS_LDAP_VERSION_2	"2.0"
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate /*
477c478bd9Sstevel@tonic-gate  * Flags
487c478bd9Sstevel@tonic-gate  */
497c478bd9Sstevel@tonic-gate #define	NS_LDAP_HARD		  0x001
507c478bd9Sstevel@tonic-gate #define	NS_LDAP_ALL_RES		  0x002
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate /* Search Referral Option */
537c478bd9Sstevel@tonic-gate typedef enum SearchRef {
547c478bd9Sstevel@tonic-gate 	NS_LDAP_FOLLOWREF	= 0x004,
557c478bd9Sstevel@tonic-gate 	NS_LDAP_NOREF		= 0x008
567c478bd9Sstevel@tonic-gate } SearchRef_t;
577c478bd9Sstevel@tonic-gate 
587c478bd9Sstevel@tonic-gate typedef enum ScopeType {
597c478bd9Sstevel@tonic-gate 	NS_LDAP_SCOPE_BASE	= 0x010,
607c478bd9Sstevel@tonic-gate 	NS_LDAP_SCOPE_ONELEVEL	= 0x020,
617c478bd9Sstevel@tonic-gate 	NS_LDAP_SCOPE_SUBTREE	= 0x040
627c478bd9Sstevel@tonic-gate } ScopeType_t;
637c478bd9Sstevel@tonic-gate 
647c478bd9Sstevel@tonic-gate /*
657c478bd9Sstevel@tonic-gate  * BE VERY CAREFUL. DO NOT USE FLAG NS_LDAP_KEEP_CONN UNLESS YOU MUST
667c478bd9Sstevel@tonic-gate  * IN libsldap.so.1 THERE IS NO CONNECTION GARBAGE COLLECTION AND IF
677c478bd9Sstevel@tonic-gate  * THIS FLAG GETS USED THERE MIGHT BE A CONNECTION LEAK. CURRENTLY THIS
687c478bd9Sstevel@tonic-gate  * IS ONLY SUPPORTED FOR LIST AND INTENDED FOR APPLICATIONS LIKE AUTOMOUNTER
697c478bd9Sstevel@tonic-gate  */
707c478bd9Sstevel@tonic-gate 
717c478bd9Sstevel@tonic-gate #define	NS_LDAP_KEEP_CONN	  0x080
727c478bd9Sstevel@tonic-gate #define	NS_LDAP_NEW_CONN	  0x400
737c478bd9Sstevel@tonic-gate #define	NS_LDAP_NOMAP		  0x800
747c478bd9Sstevel@tonic-gate 
757c478bd9Sstevel@tonic-gate #define	NS_LDAP_PAGE_CTRL	  0x1000
767c478bd9Sstevel@tonic-gate #define	NS_LDAP_NO_PAGE_CTRL	  0x0000
777c478bd9Sstevel@tonic-gate 
78f5c3c7a7Ssdussud /*
79f5c3c7a7Ssdussud  * NS_LDAP_NOT_CVT_DN is needed when attribute mapping is used
80f5c3c7a7Ssdussud  * to retrieve the DN in LDAP and DN is not to be converted when
81f5c3c7a7Ssdussud  * being passed back to the application. See __ns_ldap_uid2dn()
82f5c3c7a7Ssdussud  * and __ns_ldap_host2dn() for such usage.
83f5c3c7a7Ssdussud  */
84f5c3c7a7Ssdussud #define	NS_LDAP_NOT_CVT_DN	0x2000
85f5c3c7a7Ssdussud 
867c478bd9Sstevel@tonic-gate /*
877c478bd9Sstevel@tonic-gate  * Authentication Information
887c478bd9Sstevel@tonic-gate  */
897c478bd9Sstevel@tonic-gate typedef enum CredLevel {
907c478bd9Sstevel@tonic-gate 	NS_LDAP_CRED_ANON	= 0,
917c478bd9Sstevel@tonic-gate 	NS_LDAP_CRED_PROXY	= 1,
92cb5caa98Sdjl 	NS_LDAP_CRED_SELF	= 2
937c478bd9Sstevel@tonic-gate } CredLevel_t;
947c478bd9Sstevel@tonic-gate 
957c478bd9Sstevel@tonic-gate typedef enum AuthType {
967c478bd9Sstevel@tonic-gate 	NS_LDAP_AUTH_NONE	= 0,
977c478bd9Sstevel@tonic-gate 	NS_LDAP_AUTH_SIMPLE	= 1,
987c478bd9Sstevel@tonic-gate 	NS_LDAP_AUTH_SASL	= 2,
997c478bd9Sstevel@tonic-gate 	NS_LDAP_AUTH_TLS	= 3,	/* implied SASL usage */
1007c478bd9Sstevel@tonic-gate 	NS_LDAP_AUTH_ATLS	= 4	/* implied SASL usage */
1017c478bd9Sstevel@tonic-gate } AuthType_t;
1027c478bd9Sstevel@tonic-gate 
1037c478bd9Sstevel@tonic-gate typedef enum TlsType {
1047c478bd9Sstevel@tonic-gate 	NS_LDAP_TLS_NONE	= 0,
1057c478bd9Sstevel@tonic-gate 	NS_LDAP_TLS_SIMPLE	= 1,
1067c478bd9Sstevel@tonic-gate 	NS_LDAP_TLS_SASL	= 2
1077c478bd9Sstevel@tonic-gate } TlsType_t;
1087c478bd9Sstevel@tonic-gate 
1097c478bd9Sstevel@tonic-gate typedef enum SaslMech {
1107c478bd9Sstevel@tonic-gate 	NS_LDAP_SASL_NONE	= 0,	/* No SASL mechanism */
1117c478bd9Sstevel@tonic-gate 	NS_LDAP_SASL_CRAM_MD5	= 1,
1127c478bd9Sstevel@tonic-gate 	NS_LDAP_SASL_DIGEST_MD5	= 2,
1137c478bd9Sstevel@tonic-gate 	NS_LDAP_SASL_EXTERNAL	= 3,	/* currently not supported */
114cb5caa98Sdjl 	NS_LDAP_SASL_GSSAPI	= 4,
1157c478bd9Sstevel@tonic-gate 	NS_LDAP_SASL_SPNEGO	= 5	/* currently not supported */
1167c478bd9Sstevel@tonic-gate } SaslMech_t;
1177c478bd9Sstevel@tonic-gate 
1187c478bd9Sstevel@tonic-gate typedef enum SaslOpt {
1197c478bd9Sstevel@tonic-gate 	NS_LDAP_SASLOPT_NONE	= 0,
120cb5caa98Sdjl 	NS_LDAP_SASLOPT_INT	= 1,
121cb5caa98Sdjl 	NS_LDAP_SASLOPT_PRIV	= 2
1227c478bd9Sstevel@tonic-gate } SaslOpt_t;
1237c478bd9Sstevel@tonic-gate 
1247c478bd9Sstevel@tonic-gate typedef enum PrefOnly {
1257c478bd9Sstevel@tonic-gate 	NS_LDAP_PREF_FALSE	= 0,
1267c478bd9Sstevel@tonic-gate 	NS_LDAP_PREF_TRUE	= 1
1277c478bd9Sstevel@tonic-gate } PrefOnly_t;
1287c478bd9Sstevel@tonic-gate 
1297c478bd9Sstevel@tonic-gate typedef struct UnixCred {
1307c478bd9Sstevel@tonic-gate 	char	*userID;	/* Unix ID number */
1317c478bd9Sstevel@tonic-gate 	char	*passwd;	/* password */
1327c478bd9Sstevel@tonic-gate } UnixCred_t;
1337c478bd9Sstevel@tonic-gate 
1347c478bd9Sstevel@tonic-gate typedef struct CertCred {
1357c478bd9Sstevel@tonic-gate 	char	*path;		/* certificate path */
1367c478bd9Sstevel@tonic-gate 	char	*passwd;	/* password */
1377c478bd9Sstevel@tonic-gate 	char	*nickname;	/* nickname */
1387c478bd9Sstevel@tonic-gate } CertCred_t;
1397c478bd9Sstevel@tonic-gate 
1407c478bd9Sstevel@tonic-gate typedef struct ns_auth {
1417c478bd9Sstevel@tonic-gate 	AuthType_t	type;
1427c478bd9Sstevel@tonic-gate 	TlsType_t	tlstype;
1437c478bd9Sstevel@tonic-gate 	SaslMech_t	saslmech;
1447c478bd9Sstevel@tonic-gate 	SaslOpt_t	saslopt;
1457c478bd9Sstevel@tonic-gate } ns_auth_t;
1467c478bd9Sstevel@tonic-gate 
1477c478bd9Sstevel@tonic-gate typedef struct ns_cred {
1487c478bd9Sstevel@tonic-gate 	ns_auth_t	auth;
1497c478bd9Sstevel@tonic-gate 	char		*hostcertpath;
1507c478bd9Sstevel@tonic-gate 	union {
1517c478bd9Sstevel@tonic-gate 		UnixCred_t	unix_cred;
1527c478bd9Sstevel@tonic-gate 		CertCred_t	cert_cred;
1537c478bd9Sstevel@tonic-gate 	} cred;
1547c478bd9Sstevel@tonic-gate } ns_cred_t;
1557c478bd9Sstevel@tonic-gate 
1567c478bd9Sstevel@tonic-gate 
1577c478bd9Sstevel@tonic-gate typedef struct LineBuf {
1587c478bd9Sstevel@tonic-gate 	char *str;
1597c478bd9Sstevel@tonic-gate 	int len;
1607c478bd9Sstevel@tonic-gate 	int alloc;
1617c478bd9Sstevel@tonic-gate } LineBuf;
1627c478bd9Sstevel@tonic-gate 
1637c478bd9Sstevel@tonic-gate /*
1647c478bd9Sstevel@tonic-gate  * Configuration Information
1657c478bd9Sstevel@tonic-gate  */
1667c478bd9Sstevel@tonic-gate 
1677c478bd9Sstevel@tonic-gate typedef enum {
1687c478bd9Sstevel@tonic-gate 	NS_LDAP_FILE_VERSION_P		= 0,
1697c478bd9Sstevel@tonic-gate 	NS_LDAP_BINDDN_P		= 1,
1707c478bd9Sstevel@tonic-gate 	NS_LDAP_BINDPASSWD_P		= 2,
1717c478bd9Sstevel@tonic-gate 	NS_LDAP_SERVERS_P		= 3,
1727c478bd9Sstevel@tonic-gate 	NS_LDAP_SEARCH_BASEDN_P		= 4,
1737c478bd9Sstevel@tonic-gate 	NS_LDAP_AUTH_P			= 5,
1747c478bd9Sstevel@tonic-gate /*
1757c478bd9Sstevel@tonic-gate  * NS_LDAP_TRANSPORT_SEC_P is only left in for backward compatibility
1767c478bd9Sstevel@tonic-gate  * with version 1 clients and their configuration files.  The only
1777c478bd9Sstevel@tonic-gate  * supported value is NS_LDAP_SEC_NONE.  No application should be
1787c478bd9Sstevel@tonic-gate  * using this parameter type (either through getParam or setParam.
1797c478bd9Sstevel@tonic-gate  */
1807c478bd9Sstevel@tonic-gate 	NS_LDAP_TRANSPORT_SEC_P		= 6,
1817c478bd9Sstevel@tonic-gate 	NS_LDAP_SEARCH_REF_P		= 7,
1827c478bd9Sstevel@tonic-gate 	NS_LDAP_DOMAIN_P		= 8,
1837c478bd9Sstevel@tonic-gate 	NS_LDAP_EXP_P			= 9,
1847c478bd9Sstevel@tonic-gate 	NS_LDAP_CERT_PATH_P		= 10,
1857c478bd9Sstevel@tonic-gate 	NS_LDAP_CERT_PASS_P		= 11,
1867c478bd9Sstevel@tonic-gate 	NS_LDAP_SEARCH_DN_P		= 12,
1877c478bd9Sstevel@tonic-gate 	NS_LDAP_SEARCH_SCOPE_P		= 13,
1887c478bd9Sstevel@tonic-gate 	NS_LDAP_SEARCH_TIME_P		= 14,
1897c478bd9Sstevel@tonic-gate 	NS_LDAP_SERVER_PREF_P		= 15,
1907c478bd9Sstevel@tonic-gate 	NS_LDAP_PREF_ONLY_P		= 16,
1917c478bd9Sstevel@tonic-gate 	NS_LDAP_CACHETTL_P		= 17,
1927c478bd9Sstevel@tonic-gate 	NS_LDAP_PROFILE_P		= 18,
1937c478bd9Sstevel@tonic-gate 	NS_LDAP_CREDENTIAL_LEVEL_P	= 19,
1947c478bd9Sstevel@tonic-gate 	NS_LDAP_SERVICE_SEARCH_DESC_P	= 20,
1957c478bd9Sstevel@tonic-gate 	NS_LDAP_BIND_TIME_P		= 21,
1967c478bd9Sstevel@tonic-gate 	NS_LDAP_ATTRIBUTEMAP_P		= 22,
1977c478bd9Sstevel@tonic-gate 	NS_LDAP_OBJECTCLASSMAP_P	= 23,
1987c478bd9Sstevel@tonic-gate 	NS_LDAP_CERT_NICKNAME_P		= 24,
1997c478bd9Sstevel@tonic-gate 	NS_LDAP_SERVICE_AUTH_METHOD_P	= 25,
2007c478bd9Sstevel@tonic-gate 	NS_LDAP_SERVICE_CRED_LEVEL_P	= 26,
2017c478bd9Sstevel@tonic-gate 	NS_LDAP_HOST_CERTPATH_P		= 27,
2027c478bd9Sstevel@tonic-gate /*
2037c478bd9Sstevel@tonic-gate  * The following entry (max ParamIndexType) is an internal
2047c478bd9Sstevel@tonic-gate  * placeholder.  It must be the last (and highest value)
2057c478bd9Sstevel@tonic-gate  * entry in this eNum.  Please update accordingly.
2067c478bd9Sstevel@tonic-gate  */
2077c478bd9Sstevel@tonic-gate 	NS_LDAP_MAX_PIT_P		= 28
2087c478bd9Sstevel@tonic-gate 
2097c478bd9Sstevel@tonic-gate } ParamIndexType;
2107c478bd9Sstevel@tonic-gate 
211cb5caa98Sdjl /*
212cb5caa98Sdjl  * NONE - No self / SASL/GSSAPI configured
213cb5caa98Sdjl  * ONLY - Only self / SASL/GSSAPI configured
214cb5caa98Sdjl  * MIXED - self / SASL/GSSAPI is mixed with other types of configuration
215cb5caa98Sdjl  */
216cb5caa98Sdjl typedef enum {
217cb5caa98Sdjl 	NS_LDAP_SELF_GSSAPI_CONFIG_NONE = 0,
218cb5caa98Sdjl 	NS_LDAP_SELF_GSSAPI_CONFIG_ONLY = 1,
219cb5caa98Sdjl 	NS_LDAP_SELF_GSSAPI_CONFIG_MIXED = 2
220cb5caa98Sdjl } ns_ldap_self_gssapi_config_t;
221cb5caa98Sdjl 
2227c478bd9Sstevel@tonic-gate /*
2237c478bd9Sstevel@tonic-gate  * __ns_ldap_*() return codes
2247c478bd9Sstevel@tonic-gate  */
2257c478bd9Sstevel@tonic-gate typedef enum {
2267c478bd9Sstevel@tonic-gate 	NS_LDAP_SUCCESS		= 0, /* success, no info in errorp */
2277c478bd9Sstevel@tonic-gate 	NS_LDAP_OP_FAILED	= 1, /* failed operation, no info in errorp */
2287c478bd9Sstevel@tonic-gate 	NS_LDAP_NOTFOUND	= 2, /* entry not found, no info in errorp */
2297c478bd9Sstevel@tonic-gate 	NS_LDAP_MEMORY		= 3, /* memory failure, no info in errorp */
2307c478bd9Sstevel@tonic-gate 	NS_LDAP_CONFIG		= 4, /* config problem, detail in errorp */
2317c478bd9Sstevel@tonic-gate 	NS_LDAP_PARTIAL		= 5, /* partial result, detail in errorp */
2327c478bd9Sstevel@tonic-gate 	NS_LDAP_INTERNAL	= 7, /* LDAP error, detail in errorp */
2337c478bd9Sstevel@tonic-gate 	NS_LDAP_INVALID_PARAM	= 8, /* LDAP error, no info in errorp */
2347c478bd9Sstevel@tonic-gate 	NS_LDAP_SUCCESS_WITH_INFO
2357c478bd9Sstevel@tonic-gate 				= 9  /* success, with info in errorp */
2367c478bd9Sstevel@tonic-gate } ns_ldap_return_code;
2377c478bd9Sstevel@tonic-gate 
2387c478bd9Sstevel@tonic-gate /*
2397c478bd9Sstevel@tonic-gate  * Detailed error code for NS_LDAP_CONFIG
2407c478bd9Sstevel@tonic-gate  */
2417c478bd9Sstevel@tonic-gate typedef enum {
2427c478bd9Sstevel@tonic-gate 	NS_CONFIG_SYNTAX	= 0,	/* syntax error */
2437c478bd9Sstevel@tonic-gate 	NS_CONFIG_NODEFAULT	= 1,	/* no default value */
2447c478bd9Sstevel@tonic-gate 	NS_CONFIG_NOTLOADED	= 2,	/* configuration not loaded */
2457c478bd9Sstevel@tonic-gate 	NS_CONFIG_NOTALLOW	= 3,	/* operation requested not allowed */
2467c478bd9Sstevel@tonic-gate 	NS_CONFIG_FILE		= 4,	/* configuration file problem */
2477c478bd9Sstevel@tonic-gate 	NS_CONFIG_CACHEMGR	= 5	/* error with door to ldap_cachemgr */
2487c478bd9Sstevel@tonic-gate } ns_ldap_config_return_code;
2497c478bd9Sstevel@tonic-gate 
2507c478bd9Sstevel@tonic-gate /*
2517c478bd9Sstevel@tonic-gate  * Detailed error code for NS_LDAP_PARTIAL
2527c478bd9Sstevel@tonic-gate  */
2537c478bd9Sstevel@tonic-gate typedef enum {
2547c478bd9Sstevel@tonic-gate 	NS_PARTIAL_TIMEOUT	= 0,	/* partial results due to timeout */
2557c478bd9Sstevel@tonic-gate 	NS_PARTIAL_OTHER	= 1	/* error encountered */
2567c478bd9Sstevel@tonic-gate } ns_ldap_partial_return_code;
2577c478bd9Sstevel@tonic-gate 
2587c478bd9Sstevel@tonic-gate /*
2597c478bd9Sstevel@tonic-gate  * For use by __ns_ldap_addTypedEntry() for publickey serivicetype
2607c478bd9Sstevel@tonic-gate  */
2617c478bd9Sstevel@tonic-gate typedef enum {
2627c478bd9Sstevel@tonic-gate 	NS_HOSTCRED_FALSE = 0,
2637c478bd9Sstevel@tonic-gate 	NS_HOSTCRED_TRUE  = 1
2647c478bd9Sstevel@tonic-gate } hostcred_t;
2657c478bd9Sstevel@tonic-gate 
2667c478bd9Sstevel@tonic-gate /*
2677c478bd9Sstevel@tonic-gate  * Detailed password status
2687c478bd9Sstevel@tonic-gate  */
2697c478bd9Sstevel@tonic-gate typedef enum {
2707c478bd9Sstevel@tonic-gate 	NS_PASSWD_GOOD			= 0,	/* password is good */
2717c478bd9Sstevel@tonic-gate 	NS_PASSWD_ABOUT_TO_EXPIRE	= 1,	/* password is good but */
2727c478bd9Sstevel@tonic-gate 						/* about to expire */
2737c478bd9Sstevel@tonic-gate 	NS_PASSWD_CHANGE_NEEDED		= 2,	/* good but need to be */
2747c478bd9Sstevel@tonic-gate 						/* changed immediately */
2757c478bd9Sstevel@tonic-gate 	NS_PASSWD_EXPIRED		= 3,	/* password expired */
2767c478bd9Sstevel@tonic-gate 	NS_PASSWD_RETRY_EXCEEDED	= 4,	/* exceed retry limit; */
2777c478bd9Sstevel@tonic-gate 						/* account is locked */
2787c478bd9Sstevel@tonic-gate 	NS_PASSWD_CHANGE_NOT_ALLOWED	= 5,	/* can only be changed */
2797c478bd9Sstevel@tonic-gate 						/* by the administrator */
2807c478bd9Sstevel@tonic-gate 	NS_PASSWD_INVALID_SYNTAX	= 6,	/* can not be changed: */
2817c478bd9Sstevel@tonic-gate 						/* new password has */
2827c478bd9Sstevel@tonic-gate 						/* invalid syntax -- */
283*c31b4830SSerge Dussud 						/* trivial password: same */
284*c31b4830SSerge Dussud 						/* value as attr, cn, sn, */
285*c31b4830SSerge Dussud 						/* uid, etc. */
286*c31b4830SSerge Dussud 						/* or strong password */
287*c31b4830SSerge Dussud 						/* policies check */
2887c478bd9Sstevel@tonic-gate 	NS_PASSWD_TOO_SHORT		= 7,	/* can not be changed: */
2897c478bd9Sstevel@tonic-gate 						/* new password has */
2907c478bd9Sstevel@tonic-gate 						/* less chars than */
2917c478bd9Sstevel@tonic-gate 						/* required */
2927c478bd9Sstevel@tonic-gate 	NS_PASSWD_IN_HISTORY		= 8,	/* can not be changed: */
2937c478bd9Sstevel@tonic-gate 						/* reuse old password  */
2947c478bd9Sstevel@tonic-gate 	NS_PASSWD_WITHIN_MIN_AGE	= 9 	/* can not be changed: */
2957c478bd9Sstevel@tonic-gate 						/* within minimum age  */
2967c478bd9Sstevel@tonic-gate } ns_ldap_passwd_status_t;
2977c478bd9Sstevel@tonic-gate 
2987c478bd9Sstevel@tonic-gate /*
2997c478bd9Sstevel@tonic-gate  * Password management information structure
30047789246Svv  *
30147789246Svv  * This structure is different from AcctUsableResponse_t structure in
30247789246Svv  * that this structure holds result of users account mgmt information when
30347789246Svv  * an ldap bind is done with user name and user password.
3047c478bd9Sstevel@tonic-gate  */
3057c478bd9Sstevel@tonic-gate typedef struct ns_ldap_passwd_mgmt {
3067c478bd9Sstevel@tonic-gate 	ns_ldap_passwd_status_t
3077c478bd9Sstevel@tonic-gate 		status;			/* password status */
3087c478bd9Sstevel@tonic-gate 	int	sec_until_expired;	/* seconds until expired, */
3097c478bd9Sstevel@tonic-gate 					/* valid if status is */
3107c478bd9Sstevel@tonic-gate 					/* NS_PASSWD_ABOUT_TO_EXPIRE */
3117c478bd9Sstevel@tonic-gate } ns_ldap_passwd_mgmt_t;
3127c478bd9Sstevel@tonic-gate 
31347789246Svv /*
31447789246Svv  * LDAP V3 control flag for account management - Used for account management
31547789246Svv  * when no password is provided
31647789246Svv  */
31747789246Svv #define	NS_LDAP_ACCOUNT_USABLE_CONTROL	"1.3.6.1.4.1.42.2.27.9.5.8"
31847789246Svv 
31947789246Svv /*
32047789246Svv  * Structure for holding the response returned by server for
32147789246Svv  * NS_LDAP_ACCOUNT_USABLE_CONTROL control when account is not available.
32247789246Svv  */
32347789246Svv typedef struct AcctUsableMoreInfo {
32447789246Svv 	int inactive;
32547789246Svv 	int reset;
32647789246Svv 	int expired;
32747789246Svv 	int rem_grace;
32847789246Svv 	int sec_b4_unlock;
32947789246Svv } AcctUsableMoreInfo_t;
33047789246Svv 
33147789246Svv /*
33247789246Svv  * Structure used to hold the response from the server for
33347789246Svv  * NS_LDAP_ACCOUNT_USABLE_CONTROL control. The ASN1 notation is as below:
33447789246Svv  *
33547789246Svv  * ACCOUNT_USABLE_RESPONSE::= CHOICE {
33647789246Svv  * is_available		[0] INTEGER, seconds before expiration
33747789246Svv  * is_not_available	[1] More_info
33847789246Svv  * }
33947789246Svv  *
34047789246Svv  * More_info::= SEQUENCE {
34147789246Svv  * inactive		[0] BOOLEAN DEFAULT FALSE,
34247789246Svv  * reset		[1] BOOLEAN DEFAULT FALSE,
34347789246Svv  * expired		[2] BOOLEAN DEFAULT FALSE,
34447789246Svv  * remaining_grace	[3] INTEGER OPTIONAL,
34547789246Svv  * seconds_before_unlock[4] INTEGER OPTIONAL
34647789246Svv  * }
34747789246Svv  *
34847789246Svv  * This structure is different from ns_ldap_passwd_mgmt_t structure in
34947789246Svv  * that this structure holds result of users account mgmt information when
35047789246Svv  * pam_ldap doesn't have the users password and proxy agent is used for
35147789246Svv  * obtaining the account management information.
35247789246Svv  */
35347789246Svv typedef struct AcctUsableResponse {
35447789246Svv 	int choice;
35547789246Svv 	union {
35647789246Svv 		int seconds_before_expiry;
35747789246Svv 		AcctUsableMoreInfo_t more_info;
35847789246Svv 	} AcctUsableResp;
35947789246Svv } AcctUsableResponse_t;
3607c478bd9Sstevel@tonic-gate 
3617c478bd9Sstevel@tonic-gate /*
3627c478bd9Sstevel@tonic-gate  * Simplified LDAP Naming API result structure
3637c478bd9Sstevel@tonic-gate  */
3647c478bd9Sstevel@tonic-gate typedef struct ns_ldap_error {
3657c478bd9Sstevel@tonic-gate 	int	status;				/* LDAP error code */
3667c478bd9Sstevel@tonic-gate 	char	*message;			/* LDAP error message */
3677c478bd9Sstevel@tonic-gate 	ns_ldap_passwd_mgmt_t	pwd_mgmt;	/* LDAP password */
3687c478bd9Sstevel@tonic-gate 						/* management info */
3697c478bd9Sstevel@tonic-gate } ns_ldap_error_t;
3707c478bd9Sstevel@tonic-gate 
3717c478bd9Sstevel@tonic-gate typedef struct	 ns_ldap_attr {
3727c478bd9Sstevel@tonic-gate 	char	*attrname;			/* attribute name */
3737c478bd9Sstevel@tonic-gate 	uint_t	value_count;
3747c478bd9Sstevel@tonic-gate 	char	**attrvalue;			/* attribute values */
3757c478bd9Sstevel@tonic-gate } ns_ldap_attr_t;
3767c478bd9Sstevel@tonic-gate 
3777c478bd9Sstevel@tonic-gate typedef struct ns_ldap_entry {
3787c478bd9Sstevel@tonic-gate 	uint_t		attr_count;		/* number of attributes */
3797c478bd9Sstevel@tonic-gate 	ns_ldap_attr_t	**attr_pair;		/* attributes pairs */
3807c478bd9Sstevel@tonic-gate 	struct ns_ldap_entry *next;		/* next entry */
3817c478bd9Sstevel@tonic-gate } ns_ldap_entry_t;
3827c478bd9Sstevel@tonic-gate 
3837c478bd9Sstevel@tonic-gate typedef struct ns_ldap_result {
3847c478bd9Sstevel@tonic-gate 	uint_t	entries_count;		/* number of entries */
3857c478bd9Sstevel@tonic-gate 	ns_ldap_entry_t	*entry;		/* data */
3867c478bd9Sstevel@tonic-gate } ns_ldap_result_t;
3877c478bd9Sstevel@tonic-gate 
3887c478bd9Sstevel@tonic-gate /*
3897c478bd9Sstevel@tonic-gate  * structures for the conversion routines used by typedAddEntry()
3907c478bd9Sstevel@tonic-gate  */
3917c478bd9Sstevel@tonic-gate 
3927c478bd9Sstevel@tonic-gate typedef struct _ns_netgroups {
3937c478bd9Sstevel@tonic-gate 	char  *name;
3947c478bd9Sstevel@tonic-gate 	char  **triplet;
3957c478bd9Sstevel@tonic-gate 	char  **netgroup;
3967c478bd9Sstevel@tonic-gate } _ns_netgroups_t;
3977c478bd9Sstevel@tonic-gate 
3987c478bd9Sstevel@tonic-gate typedef struct _ns_netmasks {
3997c478bd9Sstevel@tonic-gate 	char *netnumber;
4007c478bd9Sstevel@tonic-gate 	char *netmask;
4017c478bd9Sstevel@tonic-gate } _ns_netmasks_t;
4027c478bd9Sstevel@tonic-gate 
4037c478bd9Sstevel@tonic-gate typedef struct _ns_bootp {
4047c478bd9Sstevel@tonic-gate 	char *name;
4057c478bd9Sstevel@tonic-gate 	char **param;
4067c478bd9Sstevel@tonic-gate } _ns_bootp_t;
4077c478bd9Sstevel@tonic-gate 
4087c478bd9Sstevel@tonic-gate typedef struct _ns_ethers {
4097c478bd9Sstevel@tonic-gate 	char *name;
4107c478bd9Sstevel@tonic-gate 	char *ether;
4117c478bd9Sstevel@tonic-gate } _ns_ethers_t;
4127c478bd9Sstevel@tonic-gate 
4137c478bd9Sstevel@tonic-gate typedef struct _ns_pubkey {
4147c478bd9Sstevel@tonic-gate 	char *name;
4157c478bd9Sstevel@tonic-gate 	hostcred_t hostcred;
4167c478bd9Sstevel@tonic-gate 	char *pubkey;
4177c478bd9Sstevel@tonic-gate 	char *privkey;
4187c478bd9Sstevel@tonic-gate } _ns_pubkey_t;
4197c478bd9Sstevel@tonic-gate 
4207c478bd9Sstevel@tonic-gate typedef struct _ns_alias {
4217c478bd9Sstevel@tonic-gate 	char *alias;
4227c478bd9Sstevel@tonic-gate 	char **member;
4237c478bd9Sstevel@tonic-gate } _ns_alias_t;
4247c478bd9Sstevel@tonic-gate 
4257c478bd9Sstevel@tonic-gate typedef struct _ns_automount {
4267c478bd9Sstevel@tonic-gate 	char *mapname;
4277c478bd9Sstevel@tonic-gate 	char *key;
4287c478bd9Sstevel@tonic-gate 	char *value;
4297c478bd9Sstevel@tonic-gate } _ns_automount_t;
4307c478bd9Sstevel@tonic-gate 
4317c478bd9Sstevel@tonic-gate /*
4327c478bd9Sstevel@tonic-gate  * return values for the callback function in __ns_ldap_list()
4337c478bd9Sstevel@tonic-gate  */
4347c478bd9Sstevel@tonic-gate #define	NS_LDAP_CB_NEXT	0	/* get the next entry */
4357c478bd9Sstevel@tonic-gate #define	NS_LDAP_CB_DONE	1	/* done */
4367c478bd9Sstevel@tonic-gate 
4377c478bd9Sstevel@tonic-gate /*
4387c478bd9Sstevel@tonic-gate  * Input values for the type specified in __ns_ldap_addTypedEntry()
4397c478bd9Sstevel@tonic-gate  * and __ns_ldap_delTypedEntry()
4407c478bd9Sstevel@tonic-gate  */
4417c478bd9Sstevel@tonic-gate 
4427c478bd9Sstevel@tonic-gate #define	NS_LDAP_TYPE_PASSWD	"passwd"
4437c478bd9Sstevel@tonic-gate #define	NS_LDAP_TYPE_GROUP	"group"
4447c478bd9Sstevel@tonic-gate #define	NS_LDAP_TYPE_HOSTS	"hosts"
4457c478bd9Sstevel@tonic-gate #define	NS_LDAP_TYPE_IPNODES	"ipnodes"
4467c478bd9Sstevel@tonic-gate #define	NS_LDAP_TYPE_PROFILE	"prof_attr"
4477c478bd9Sstevel@tonic-gate #define	NS_LDAP_TYPE_RPC	"rpc"
4487c478bd9Sstevel@tonic-gate #define	NS_LDAP_TYPE_PROTOCOLS	"protocols"
4497c478bd9Sstevel@tonic-gate #define	NS_LDAP_TYPE_NETWORKS	"networks"
4507c478bd9Sstevel@tonic-gate #define	NS_LDAP_TYPE_NETGROUP	"netgroup"
4517c478bd9Sstevel@tonic-gate #define	NS_LDAP_TYPE_ALIASES	"aliases"
4527c478bd9Sstevel@tonic-gate #define	NS_LDAP_TYPE_SERVICES	"services"
4537c478bd9Sstevel@tonic-gate #define	NS_LDAP_TYPE_ETHERS	"ethers"
4547c478bd9Sstevel@tonic-gate #define	NS_LDAP_TYPE_SHADOW	"shadow"
4557c478bd9Sstevel@tonic-gate #define	NS_LDAP_TYPE_NETMASKS	"netmasks"
4567c478bd9Sstevel@tonic-gate #define	NS_LDAP_TYPE_AUTHATTR	"auth_attr"
4577c478bd9Sstevel@tonic-gate #define	NS_LDAP_TYPE_EXECATTR	"exec_attr"
4587c478bd9Sstevel@tonic-gate #define	NS_LDAP_TYPE_USERATTR	"user_attr"
4597c478bd9Sstevel@tonic-gate #define	NS_LDAP_TYPE_PROJECT	"project"
4607c478bd9Sstevel@tonic-gate #define	NS_LDAP_TYPE_PUBLICKEY	"publickey"
4617c478bd9Sstevel@tonic-gate #define	NS_LDAP_TYPE_AUUSER	"audit_user"
4627c478bd9Sstevel@tonic-gate #define	NS_LDAP_TYPE_BOOTPARAMS "bootparams"
4637c478bd9Sstevel@tonic-gate #define	NS_LDAP_TYPE_AUTOMOUNT  "auto_"
46445916cd2Sjpk #define	NS_LDAP_TYPE_TNRHDB	"tnrhdb"
46545916cd2Sjpk #define	NS_LDAP_TYPE_TNRHTP	"tnrhtp"
4667c478bd9Sstevel@tonic-gate 
4677c478bd9Sstevel@tonic-gate /*
4687c478bd9Sstevel@tonic-gate  * service descriptor/attribute mapping structure
4697c478bd9Sstevel@tonic-gate  */
4707c478bd9Sstevel@tonic-gate 
4717c478bd9Sstevel@tonic-gate typedef struct ns_ldap_search_desc {
4727c478bd9Sstevel@tonic-gate 	char		*basedn;	/* search base dn */
4737c478bd9Sstevel@tonic-gate 	ScopeType_t	scope;		/* search scope */
4747c478bd9Sstevel@tonic-gate 	char		*filter;	/* search filter */
4757c478bd9Sstevel@tonic-gate } ns_ldap_search_desc_t;
4767c478bd9Sstevel@tonic-gate 
4777c478bd9Sstevel@tonic-gate typedef struct ns_ldap_attribute_map {
4787c478bd9Sstevel@tonic-gate 	char		*origAttr;	/* original attribute */
4797c478bd9Sstevel@tonic-gate 	char		**mappedAttr;	/* mapped attribute(s) */
4807c478bd9Sstevel@tonic-gate } ns_ldap_attribute_map_t;
4817c478bd9Sstevel@tonic-gate 
4827c478bd9Sstevel@tonic-gate typedef struct ns_ldap_objectclass_map {
4837c478bd9Sstevel@tonic-gate 	char		*origOC;	/* original objectclass */
4847c478bd9Sstevel@tonic-gate 	char		*mappedOC;	/* mapped objectclass */
4857c478bd9Sstevel@tonic-gate } ns_ldap_objectclass_map_t;
4867c478bd9Sstevel@tonic-gate 
487479ac375Sdm /* Opaque handle for batch API */
488479ac375Sdm typedef struct ns_ldap_list_batch ns_ldap_list_batch_t;
489479ac375Sdm 
490e1dd0a2fSth /*
491e1dd0a2fSth  * The type of standalone configuration specified by a client application.
492e1dd0a2fSth  * The meaning of the requests is as follows:
493e1dd0a2fSth  *
494e1dd0a2fSth  * NS_CACHEMGR:    libsldap will request all the configuration via door_call(3C)
495e1dd0a2fSth  *                 to ldap_cachemgr.
496e1dd0a2fSth  * NS_LDAP_SERVER: the consumer application has specified a directory server
497e1dd0a2fSth  *                 to communicate to.
498e1dd0a2fSth  * NS_PREDEFINED:  reserved for internal use
499e1dd0a2fSth  */
500e1dd0a2fSth typedef enum {
501e1dd0a2fSth 	NS_CACHEMGR = 0,
502e1dd0a2fSth 	NS_LDAP_SERVER
503e1dd0a2fSth } ns_standalone_request_type_t;
504e1dd0a2fSth 
505e1dd0a2fSth /*
506e1dd0a2fSth  * This structure describes an LDAP server specified by a client application.
507e1dd0a2fSth  */
508e1dd0a2fSth typedef struct ns_dir_server {
509e1dd0a2fSth 	char *server;			/* A directory server's IP */
510e1dd0a2fSth 	uint16_t port;			/* A directory server's port. */
511e1dd0a2fSth 					/* Default value is 389 */
512e1dd0a2fSth 	char *domainName;		/* A domain name being served */
513e1dd0a2fSth 					/* by the specified server. */
514e1dd0a2fSth 					/* Default value is the local */
515e1dd0a2fSth 					/* domain's name */
516e1dd0a2fSth 	char *profileName;		/* A DUAProfile's name. */
517e1dd0a2fSth 					/* Default value is 'default' */
518e1dd0a2fSth 	ns_auth_t *auth;		/* Authentication information used */
519e1dd0a2fSth 					/* during subsequent connections */
520e1dd0a2fSth 	char *cred;			/* A credential level to be used */
521e1dd0a2fSth 					/* along with the authentication info */
522e1dd0a2fSth 	char *host_cert_path;		/* A path to the certificate database */
523e1dd0a2fSth 					/* Default is '/vat/ldap' */
524e1dd0a2fSth 	char *bind_dn;			/* A bind DN to be used during */
525e1dd0a2fSth 					/* subsequent LDAP Bind requests */
526e1dd0a2fSth 	char *bind_passwd;		/* A bind password to be used during */
527e1dd0a2fSth 					/* subsequent LDAP Bind requests */
528e1dd0a2fSth } ns_dir_server_t;
529e1dd0a2fSth 
530e1dd0a2fSth /*
531e1dd0a2fSth  * This structure contains information describing an LDAP server.
532e1dd0a2fSth  */
533e1dd0a2fSth typedef struct ns_standalone_conf {
534e1dd0a2fSth 	union {
535e1dd0a2fSth 		ns_dir_server_t server;
536e1dd0a2fSth 		void *predefined_conf;	/* Reserved for internal use */
537e1dd0a2fSth 	} ds_profile;			/* A type of the configuration */
538e1dd0a2fSth 
539e1dd0a2fSth #define	SA_SERVER	ds_profile.server.server
540e1dd0a2fSth #define	SA_PORT		ds_profile.server.port
541e1dd0a2fSth #define	SA_DOMAIN	ds_profile.server.domainName
542e1dd0a2fSth #define	SA_PROFILE_NAME	ds_profile.server.profileName
543e1dd0a2fSth #define	SA_AUTH		ds_profile.server.auth
544e1dd0a2fSth #define	SA_CRED		ds_profile.server.cred
545e1dd0a2fSth #define	SA_CERT_PATH	ds_profile.server.host_cert_path
546e1dd0a2fSth #define	SA_BIND_DN	ds_profile.server.bind_dn
547e1dd0a2fSth #define	SA_BIND_PWD	ds_profile.server.bind_passwd
548e1dd0a2fSth 
549e1dd0a2fSth 	ns_standalone_request_type_t type;
550e1dd0a2fSth } ns_standalone_conf_t;
551e1dd0a2fSth 
552e1dd0a2fSth /*
553e1dd0a2fSth  * This function "informs" libsldap that a client application has specified
554e1dd0a2fSth  * a directory to use. The function obtains a DUAProfile, credentials,
555e1dd0a2fSth  * and naming context. During all further operations on behalf
556e1dd0a2fSth  * of the application requested a standalone schema libsldap will use
557e1dd0a2fSth  * the information obtained by __ns_ldap_initStandalone() instead of
558e1dd0a2fSth  * door_call(3C)ing ldap_cachemgr(1M).
559e1dd0a2fSth  *
560e1dd0a2fSth  * conf
561e1dd0a2fSth  * 	A structure describing where and in which way to obtain all the
562e1dd0a2fSth  * 	configuration describing how to communicate to a choosen LDAP directory.
563e1dd0a2fSth  *
564e1dd0a2fSth  * errorp
565e1dd0a2fSth  * 	An error object describing an error occured.
566e1dd0a2fSth  */
567e1dd0a2fSth ns_ldap_return_code __ns_ldap_initStandalone(
568e1dd0a2fSth 	const ns_standalone_conf_t *conf,
569e1dd0a2fSth 	ns_ldap_error_t	**errorp);
570e1dd0a2fSth 
571e1dd0a2fSth /*
572e1dd0a2fSth  * This function obtains the directory's base DN and a DUAProfile
573e1dd0a2fSth  * from a specified server.
574e1dd0a2fSth  *
575e1dd0a2fSth  * server
576e1dd0a2fSth  * 	Specifies the selected directory sever.
577e1dd0a2fSth  *
578e1dd0a2fSth  * cred
579e1dd0a2fSth  * 	Contains an authentication information and credential required to
580e1dd0a2fSth  * 	establish a connection.
581e1dd0a2fSth  *
582e1dd0a2fSth  * config
583e1dd0a2fSth  * 	If not NULL, a new configuration basing on a DUAProfile specified in the
584e1dd0a2fSth  * 	server parameter will be create and returned.
585e1dd0a2fSth  *
586e1dd0a2fSth  * baseDN
587e1dd0a2fSth  * 	If not NULL, the directory's base DN will be returned.
588e1dd0a2fSth  *
589e1dd0a2fSth  * error
590e1dd0a2fSth  * 	Describes an error, if any.
591e1dd0a2fSth  */
592e1dd0a2fSth ns_ldap_return_code __ns_ldap_getConnectionInfoFromDUA(
593e1dd0a2fSth 	const ns_dir_server_t *server,
594e1dd0a2fSth 	const ns_cred_t *cred,
595e1dd0a2fSth 	char **config,	char **baseDN,
596e1dd0a2fSth 	ns_ldap_error_t **error);
597e1dd0a2fSth 
598e1dd0a2fSth #define	SA_PROHIBIT_FALLBACK 0
599e1dd0a2fSth #define	SA_ALLOW_FALLBACK 1
600e1dd0a2fSth 
601e1dd0a2fSth #define	DONT_SAVE_NSCONF 0
602e1dd0a2fSth #define	SAVE_NSCONF 1
603e1dd0a2fSth 
604e1dd0a2fSth /*
605e1dd0a2fSth  * This function obtains the root DSE from a specified server.
606e1dd0a2fSth  *
607e1dd0a2fSth  * server_addr
608e1dd0a2fSth  * 	An adress of a server to be connected to.
609e1dd0a2fSth  *
610e1dd0a2fSth  * rootDSE
611e1dd0a2fSth  * 	A buffer containing the root DSE in the ldap_cachmgr door call format.
612e1dd0a2fSth  *
613e1dd0a2fSth  * errorp
614e1dd0a2fSth  * 	Describes an error, if any.
615e1dd0a2fSth  *
616e1dd0a2fSth  * anon_fallback
617e1dd0a2fSth  * 	If set to 1 and establishing a connection fails, __s_api_getRootDSE()
618e1dd0a2fSth  * 	will try once again using anonymous credentials.
619e1dd0a2fSth  */
620e1dd0a2fSth ns_ldap_return_code __ns_ldap_getRootDSE(
621e1dd0a2fSth 	const char *server_addr,
622e1dd0a2fSth 	char **rootDSE,
623e1dd0a2fSth 	ns_ldap_error_t **errorp,
624e1dd0a2fSth 	int anon_fallback);
625e1dd0a2fSth 
626e1dd0a2fSth /*
627e1dd0a2fSth  * This function iterates through the list of the configured LDAP servers
628e1dd0a2fSth  * and "pings" those which are marked as removed or if any error occurred
629e1dd0a2fSth  * during the previous receiving of the server's root DSE. If the
630e1dd0a2fSth  * function is able to reach such a server and get its root DSE, it
631e1dd0a2fSth  * marks the server as on-line. Otherwise, the server's status is set
632e1dd0a2fSth  * to "Error".
633e1dd0a2fSth  * For each server the function tries to connect to, it fires up
634e1dd0a2fSth  * a separate thread and then waits until all the threads finish.
635e1dd0a2fSth  * The function returns NS_LDAP_INTERNAL if the Standalone mode was not
636e1dd0a2fSth  * initialized or was canceled prior to an invocation of
637e1dd0a2fSth  * __ns_ldap_pingOfflineServers().
638e1dd0a2fSth  */
639e1dd0a2fSth ns_ldap_return_code __ns_ldap_pingOfflineServers(void);
640e1dd0a2fSth 
641e1dd0a2fSth /*
642e1dd0a2fSth  * This function cancels the Standalone mode and destroys the list of root DSEs.
643e1dd0a2fSth  */
644e1dd0a2fSth void __ns_ldap_cancelStandalone(void);
645e1dd0a2fSth /*
646e1dd0a2fSth  * This function initializes an ns_auth_t structure provided by a caller
647e1dd0a2fSth  * according to a specified authentication mechanism.
648e1dd0a2fSth  */
649e1dd0a2fSth ns_ldap_return_code __ns_ldap_initAuth(const char *auth_mech,
650e1dd0a2fSth 	ns_auth_t *auth,
651e1dd0a2fSth 	ns_ldap_error_t **errorp);
652e1dd0a2fSth 
6537c478bd9Sstevel@tonic-gate /*
6547c478bd9Sstevel@tonic-gate  * Simplified LDAP Naming APIs
6557c478bd9Sstevel@tonic-gate  */
6567c478bd9Sstevel@tonic-gate int __ns_ldap_list(
6577c478bd9Sstevel@tonic-gate 	const char *service,
6587c478bd9Sstevel@tonic-gate 	const char *filter,
6597c478bd9Sstevel@tonic-gate 	int (*init_filter_cb)(const ns_ldap_search_desc_t *desc,
6607c478bd9Sstevel@tonic-gate 			char **realfilter, const void *userdata),
6617c478bd9Sstevel@tonic-gate 	const char * const *attribute,
6627c478bd9Sstevel@tonic-gate 	const ns_cred_t *cred,
6637c478bd9Sstevel@tonic-gate 	const int flags,
6647c478bd9Sstevel@tonic-gate 	ns_ldap_result_t ** result,
6657c478bd9Sstevel@tonic-gate 	ns_ldap_error_t ** errorp,
6667c478bd9Sstevel@tonic-gate 	int (*callback)(const ns_ldap_entry_t *entry, const void *userdata),
6677c478bd9Sstevel@tonic-gate 	const void *userdata);
6687c478bd9Sstevel@tonic-gate 
669479ac375Sdm int __ns_ldap_list_batch_start(
670479ac375Sdm 	ns_ldap_list_batch_t **batch);
671479ac375Sdm 
672479ac375Sdm int __ns_ldap_list_batch_add(
673479ac375Sdm 	ns_ldap_list_batch_t *batch,
674479ac375Sdm 	const char *service,
675479ac375Sdm 	const char *filter,
676479ac375Sdm 	int (*init_filter_cb)(const ns_ldap_search_desc_t *desc,
677479ac375Sdm 			char **realfilter, const void *userdata),
678479ac375Sdm 	const char * const *attribute,
679479ac375Sdm 	const ns_cred_t *cred,
680479ac375Sdm 	const int flags,
681479ac375Sdm 	ns_ldap_result_t ** result,
682479ac375Sdm 	ns_ldap_error_t ** errorp,
683479ac375Sdm 	int *rcp,
684479ac375Sdm 	int (*callback)(const ns_ldap_entry_t *entry, const void *userdata),
685479ac375Sdm 	const void *userdata);
686479ac375Sdm 
687479ac375Sdm int __ns_ldap_list_batch_end(
688479ac375Sdm 	ns_ldap_list_batch_t *batch);
689479ac375Sdm 
690479ac375Sdm void __ns_ldap_list_batch_release(
691479ac375Sdm 	ns_ldap_list_batch_t *batch);
692479ac375Sdm 
6937c478bd9Sstevel@tonic-gate int  __ns_ldap_addAttr(
6947c478bd9Sstevel@tonic-gate 	const char *service,
6957c478bd9Sstevel@tonic-gate 	const char *dn,
6967c478bd9Sstevel@tonic-gate 	const ns_ldap_attr_t * const *attr,
6977c478bd9Sstevel@tonic-gate 	const ns_cred_t *cred,
6987c478bd9Sstevel@tonic-gate 	const int flags,
6997c478bd9Sstevel@tonic-gate 	ns_ldap_error_t **errorp);
7007c478bd9Sstevel@tonic-gate 
7017c478bd9Sstevel@tonic-gate int __ns_ldap_delAttr(
7027c478bd9Sstevel@tonic-gate 	const char *service,
7037c478bd9Sstevel@tonic-gate 	const char *dn,
7047c478bd9Sstevel@tonic-gate 	const ns_ldap_attr_t * const *attr,
7057c478bd9Sstevel@tonic-gate 	const ns_cred_t *cred,
7067c478bd9Sstevel@tonic-gate 	const int flags,
7077c478bd9Sstevel@tonic-gate 	ns_ldap_error_t **errorp);
7087c478bd9Sstevel@tonic-gate 
7097c478bd9Sstevel@tonic-gate int  __ns_ldap_repAttr(
7107c478bd9Sstevel@tonic-gate 	const char *service,
7117c478bd9Sstevel@tonic-gate 	const char *dn,
7127c478bd9Sstevel@tonic-gate 	const ns_ldap_attr_t * const *attr,
7137c478bd9Sstevel@tonic-gate 	const ns_cred_t *cred,
7147c478bd9Sstevel@tonic-gate 	const int flags,
7157c478bd9Sstevel@tonic-gate 	ns_ldap_error_t **errorp);
7167c478bd9Sstevel@tonic-gate 
7177c478bd9Sstevel@tonic-gate int  __ns_ldap_addEntry(
7187c478bd9Sstevel@tonic-gate 	const char *service,
7197c478bd9Sstevel@tonic-gate 	const char *dn,
7207c478bd9Sstevel@tonic-gate 	const ns_ldap_entry_t *entry,
7217c478bd9Sstevel@tonic-gate 	const ns_cred_t *cred,
7227c478bd9Sstevel@tonic-gate 	const int flags,
7237c478bd9Sstevel@tonic-gate 	ns_ldap_error_t **errorp);
7247c478bd9Sstevel@tonic-gate 
7257c478bd9Sstevel@tonic-gate int  __ns_ldap_addTypedEntry(
7267c478bd9Sstevel@tonic-gate 	const char *servicetype,
7277c478bd9Sstevel@tonic-gate 	const char *basedn,
7287c478bd9Sstevel@tonic-gate 	const void *data,
7297c478bd9Sstevel@tonic-gate 	const int  create,
7307c478bd9Sstevel@tonic-gate 	const ns_cred_t *cred,
7317c478bd9Sstevel@tonic-gate 	const int flags,
7327c478bd9Sstevel@tonic-gate 	ns_ldap_error_t **errorp);
7337c478bd9Sstevel@tonic-gate 
7347c478bd9Sstevel@tonic-gate int __ns_ldap_delEntry(
7357c478bd9Sstevel@tonic-gate 	const char *service,
7367c478bd9Sstevel@tonic-gate 	const char *dn,
7377c478bd9Sstevel@tonic-gate 	const ns_cred_t *cred,
7387c478bd9Sstevel@tonic-gate 	const int flags,
7397c478bd9Sstevel@tonic-gate 	ns_ldap_error_t **errorp);
7407c478bd9Sstevel@tonic-gate 
7417c478bd9Sstevel@tonic-gate int __ns_ldap_firstEntry(
7427c478bd9Sstevel@tonic-gate 	const char *service,
7437c478bd9Sstevel@tonic-gate 	const char *filter,
7447c478bd9Sstevel@tonic-gate 	int (*init_filter_cb)(const ns_ldap_search_desc_t *desc,
7457c478bd9Sstevel@tonic-gate 			char **realfilter, const void *userdata),
7467c478bd9Sstevel@tonic-gate 	const char * const *attribute,
7477c478bd9Sstevel@tonic-gate 	const ns_cred_t *cred,
7487c478bd9Sstevel@tonic-gate 	const int flags,
7497c478bd9Sstevel@tonic-gate 	void **cookie,
7507c478bd9Sstevel@tonic-gate 	ns_ldap_result_t ** result,
7517c478bd9Sstevel@tonic-gate 	ns_ldap_error_t **errorp,
7527c478bd9Sstevel@tonic-gate 	const void *userdata);
7537c478bd9Sstevel@tonic-gate 
7547c478bd9Sstevel@tonic-gate int  __ns_ldap_nextEntry(
7557c478bd9Sstevel@tonic-gate 	void *cookie,
7567c478bd9Sstevel@tonic-gate 	ns_ldap_result_t ** result,
7577c478bd9Sstevel@tonic-gate 	ns_ldap_error_t **errorp);
7587c478bd9Sstevel@tonic-gate 
7597c478bd9Sstevel@tonic-gate int  __ns_ldap_endEntry(
7607c478bd9Sstevel@tonic-gate 	void **cookie,
7617c478bd9Sstevel@tonic-gate 	ns_ldap_error_t **errorp);
7627c478bd9Sstevel@tonic-gate 
7637c478bd9Sstevel@tonic-gate int __ns_ldap_freeResult(
7647c478bd9Sstevel@tonic-gate 	ns_ldap_result_t **result);
7657c478bd9Sstevel@tonic-gate 
7667c478bd9Sstevel@tonic-gate int __ns_ldap_freeError(
7677c478bd9Sstevel@tonic-gate 	ns_ldap_error_t **errorp);
7687c478bd9Sstevel@tonic-gate 
7697c478bd9Sstevel@tonic-gate int  __ns_ldap_uid2dn(
7707c478bd9Sstevel@tonic-gate 	const char *uid,
7717c478bd9Sstevel@tonic-gate 	char **userDN,
7727c478bd9Sstevel@tonic-gate 	const ns_cred_t *cred,
7737c478bd9Sstevel@tonic-gate 	ns_ldap_error_t ** errorp);
7747c478bd9Sstevel@tonic-gate 
7757c478bd9Sstevel@tonic-gate int  __ns_ldap_host2dn(
7767c478bd9Sstevel@tonic-gate 	const char *host,
7777c478bd9Sstevel@tonic-gate 	const char *domain,
7787c478bd9Sstevel@tonic-gate 	char **hostDN,
7797c478bd9Sstevel@tonic-gate 	const ns_cred_t *cred,
7807c478bd9Sstevel@tonic-gate 	ns_ldap_error_t ** errorp);
7817c478bd9Sstevel@tonic-gate 
7827c478bd9Sstevel@tonic-gate int  __ns_ldap_dn2domain(
7837c478bd9Sstevel@tonic-gate 	const char *dn,
7847c478bd9Sstevel@tonic-gate 	char **domain,
7857c478bd9Sstevel@tonic-gate 	const ns_cred_t *cred,
7867c478bd9Sstevel@tonic-gate 	ns_ldap_error_t ** errorp);
7877c478bd9Sstevel@tonic-gate 
7887c478bd9Sstevel@tonic-gate int __ns_ldap_auth(
7897c478bd9Sstevel@tonic-gate 	const ns_cred_t *cred,
7907c478bd9Sstevel@tonic-gate 	const int flag,
7917c478bd9Sstevel@tonic-gate 	ns_ldap_error_t **errorp,
7927c478bd9Sstevel@tonic-gate 	LDAPControl **serverctrls,
7937c478bd9Sstevel@tonic-gate 	LDAPControl **clientctrls);
7947c478bd9Sstevel@tonic-gate 
7957c478bd9Sstevel@tonic-gate int __ns_ldap_freeCred(
7967c478bd9Sstevel@tonic-gate 	ns_cred_t **credp);
7977c478bd9Sstevel@tonic-gate 
7987c478bd9Sstevel@tonic-gate int __ns_ldap_err2str(
7997c478bd9Sstevel@tonic-gate 	int err,
8007c478bd9Sstevel@tonic-gate 	char **strmsg);
8017c478bd9Sstevel@tonic-gate 
8027c478bd9Sstevel@tonic-gate int __ns_ldap_setParam(
8037c478bd9Sstevel@tonic-gate 	const ParamIndexType type,
8047c478bd9Sstevel@tonic-gate 	const void *data,
8057c478bd9Sstevel@tonic-gate 	ns_ldap_error_t **errorp);
8067c478bd9Sstevel@tonic-gate 
8077c478bd9Sstevel@tonic-gate int __ns_ldap_getParam(
8087c478bd9Sstevel@tonic-gate 	const ParamIndexType type,
8097c478bd9Sstevel@tonic-gate 	void ***data,
8107c478bd9Sstevel@tonic-gate 	ns_ldap_error_t **errorp);
8117c478bd9Sstevel@tonic-gate 
8127c478bd9Sstevel@tonic-gate int __ns_ldap_freeParam(
8137c478bd9Sstevel@tonic-gate 	void ***data);
8147c478bd9Sstevel@tonic-gate 
8157c478bd9Sstevel@tonic-gate char **__ns_ldap_getAttr(
8167c478bd9Sstevel@tonic-gate 	const ns_ldap_entry_t *entry,
8177c478bd9Sstevel@tonic-gate 	const char *attrname);
8187c478bd9Sstevel@tonic-gate 
819cb5caa98Sdjl ns_ldap_attr_t	*__ns_ldap_getAttrStruct(
820cb5caa98Sdjl 	const ns_ldap_entry_t *entry,
821cb5caa98Sdjl 	const char *attrname);
822cb5caa98Sdjl 
8237c478bd9Sstevel@tonic-gate int __ns_ldap_getServiceAuthMethods(
8247c478bd9Sstevel@tonic-gate 	const char *service,
8257c478bd9Sstevel@tonic-gate 	ns_auth_t ***auth,
8267c478bd9Sstevel@tonic-gate 	ns_ldap_error_t **errorp);
8277c478bd9Sstevel@tonic-gate 
8287c478bd9Sstevel@tonic-gate int __ns_ldap_getSearchDescriptors(
8297c478bd9Sstevel@tonic-gate 	const char *service,
8307c478bd9Sstevel@tonic-gate 	ns_ldap_search_desc_t ***desc,
8317c478bd9Sstevel@tonic-gate 	ns_ldap_error_t **errorp);
8327c478bd9Sstevel@tonic-gate 
8337c478bd9Sstevel@tonic-gate int __ns_ldap_freeSearchDescriptors(
8347c478bd9Sstevel@tonic-gate 	ns_ldap_search_desc_t ***desc);
8357c478bd9Sstevel@tonic-gate 
8367c478bd9Sstevel@tonic-gate int __ns_ldap_getAttributeMaps(
8377c478bd9Sstevel@tonic-gate 	const char *service,
8387c478bd9Sstevel@tonic-gate 	ns_ldap_attribute_map_t ***maps,
8397c478bd9Sstevel@tonic-gate 	ns_ldap_error_t **errorp);
8407c478bd9Sstevel@tonic-gate 
8417c478bd9Sstevel@tonic-gate int __ns_ldap_freeAttributeMaps(
8427c478bd9Sstevel@tonic-gate 	ns_ldap_attribute_map_t ***maps);
8437c478bd9Sstevel@tonic-gate 
8447c478bd9Sstevel@tonic-gate char **__ns_ldap_getMappedAttributes(
8457c478bd9Sstevel@tonic-gate 	const char *service,
8467c478bd9Sstevel@tonic-gate 	const char *origAttribute);
8477c478bd9Sstevel@tonic-gate 
8487c478bd9Sstevel@tonic-gate char **__ns_ldap_getOrigAttribute(
8497c478bd9Sstevel@tonic-gate 	const char *service,
8507c478bd9Sstevel@tonic-gate 	const char *mappedAttribute);
8517c478bd9Sstevel@tonic-gate 
8527c478bd9Sstevel@tonic-gate int __ns_ldap_getObjectClassMaps(
8537c478bd9Sstevel@tonic-gate 	const char *service,
8547c478bd9Sstevel@tonic-gate 	ns_ldap_objectclass_map_t ***maps,
8557c478bd9Sstevel@tonic-gate 	ns_ldap_error_t **errorp);
8567c478bd9Sstevel@tonic-gate 
8577c478bd9Sstevel@tonic-gate int __ns_ldap_freeObjectClassMaps(
8587c478bd9Sstevel@tonic-gate 	ns_ldap_objectclass_map_t ***maps);
8597c478bd9Sstevel@tonic-gate 
8607c478bd9Sstevel@tonic-gate char **__ns_ldap_getMappedObjectClass(
8617c478bd9Sstevel@tonic-gate 	const char *service,
8627c478bd9Sstevel@tonic-gate 	const char *origObjectClass);
8637c478bd9Sstevel@tonic-gate 
8647c478bd9Sstevel@tonic-gate char **__ns_ldap_getOrigObjectClass(
8657c478bd9Sstevel@tonic-gate 	const char *service,
8667c478bd9Sstevel@tonic-gate 	const char *mappedObjectClass);
8677c478bd9Sstevel@tonic-gate 
8687c478bd9Sstevel@tonic-gate int __ns_ldap_getParamType(
8697c478bd9Sstevel@tonic-gate 	const char *value,
8707c478bd9Sstevel@tonic-gate 	ParamIndexType *type);
87147789246Svv 
87247789246Svv int __ns_ldap_getAcctMgmt(
87347789246Svv 	const char *user,
87447789246Svv 	AcctUsableResponse_t *acctResp);
875cb5caa98Sdjl void
876cb5caa98Sdjl __ns_ldap_self_gssapi_only_set(
877cb5caa98Sdjl 	int flag);
878cb5caa98Sdjl int
879cb5caa98Sdjl __ns_ldap_self_gssapi_config(
880cb5caa98Sdjl 	ns_ldap_self_gssapi_config_t *config);
8817c478bd9Sstevel@tonic-gate #ifdef __cplusplus
8827c478bd9Sstevel@tonic-gate }
8837c478bd9Sstevel@tonic-gate #endif
8847c478bd9Sstevel@tonic-gate 
8857c478bd9Sstevel@tonic-gate #endif /* _NS_SLDAP_H */
886