xref: /onnv-gate/usr/src/lib/libsldap/common/ns_sldap.h (revision 12882:5213e1b8c605)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
51676Sjpk  * Common Development and Distribution License (the "License").
61676Sjpk  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
2212758SJulian.Pullen@Sun.COM  * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
230Sstevel@tonic-gate  */
240Sstevel@tonic-gate 
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef	_NS_SLDAP_H
270Sstevel@tonic-gate #define	_NS_SLDAP_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #ifdef __cplusplus
300Sstevel@tonic-gate extern "C" {
310Sstevel@tonic-gate #endif
320Sstevel@tonic-gate 
330Sstevel@tonic-gate #include <stdio.h>
340Sstevel@tonic-gate #include <sys/types.h>
350Sstevel@tonic-gate #include <lber.h>
360Sstevel@tonic-gate #include <ldap.h>
370Sstevel@tonic-gate 
380Sstevel@tonic-gate /*
390Sstevel@tonic-gate  * Version
400Sstevel@tonic-gate  */
410Sstevel@tonic-gate #define	NS_LDAP_VERSION		NS_LDAP_VERSION_2
420Sstevel@tonic-gate #define	NS_LDAP_VERSION_1	"1.0"
430Sstevel@tonic-gate #define	NS_LDAP_VERSION_2	"2.0"
440Sstevel@tonic-gate 
450Sstevel@tonic-gate /*
460Sstevel@tonic-gate  * Flags
470Sstevel@tonic-gate  */
480Sstevel@tonic-gate #define	NS_LDAP_HARD		  0x001
490Sstevel@tonic-gate #define	NS_LDAP_ALL_RES		  0x002
500Sstevel@tonic-gate 
510Sstevel@tonic-gate /* Search Referral Option */
520Sstevel@tonic-gate typedef enum SearchRef {
530Sstevel@tonic-gate 	NS_LDAP_FOLLOWREF	= 0x004,
540Sstevel@tonic-gate 	NS_LDAP_NOREF		= 0x008
550Sstevel@tonic-gate } SearchRef_t;
560Sstevel@tonic-gate 
570Sstevel@tonic-gate typedef enum ScopeType {
580Sstevel@tonic-gate 	NS_LDAP_SCOPE_BASE	= 0x010,
590Sstevel@tonic-gate 	NS_LDAP_SCOPE_ONELEVEL	= 0x020,
600Sstevel@tonic-gate 	NS_LDAP_SCOPE_SUBTREE	= 0x040
610Sstevel@tonic-gate } ScopeType_t;
620Sstevel@tonic-gate 
630Sstevel@tonic-gate /*
640Sstevel@tonic-gate  * BE VERY CAREFUL. DO NOT USE FLAG NS_LDAP_KEEP_CONN UNLESS YOU MUST
650Sstevel@tonic-gate  * IN libsldap.so.1 THERE IS NO CONNECTION GARBAGE COLLECTION AND IF
660Sstevel@tonic-gate  * THIS FLAG GETS USED THERE MIGHT BE A CONNECTION LEAK. CURRENTLY THIS
670Sstevel@tonic-gate  * IS ONLY SUPPORTED FOR LIST AND INTENDED FOR APPLICATIONS LIKE AUTOMOUNTER
680Sstevel@tonic-gate  */
690Sstevel@tonic-gate 
700Sstevel@tonic-gate #define	NS_LDAP_KEEP_CONN	  0x080
710Sstevel@tonic-gate #define	NS_LDAP_NEW_CONN	  0x400
720Sstevel@tonic-gate #define	NS_LDAP_NOMAP		  0x800
730Sstevel@tonic-gate 
740Sstevel@tonic-gate #define	NS_LDAP_PAGE_CTRL	  0x1000
750Sstevel@tonic-gate #define	NS_LDAP_NO_PAGE_CTRL	  0x0000
760Sstevel@tonic-gate 
770Sstevel@tonic-gate /*
78699Ssdussud  * NS_LDAP_NOT_CVT_DN is needed when attribute mapping is used
79699Ssdussud  * to retrieve the DN in LDAP and DN is not to be converted when
80699Ssdussud  * being passed back to the application. See __ns_ldap_uid2dn()
81699Ssdussud  * and __ns_ldap_host2dn() for such usage.
82699Ssdussud  */
83699Ssdussud #define	NS_LDAP_NOT_CVT_DN	0x2000
84699Ssdussud 
85699Ssdussud /*
868821SMichen.Chang@Sun.COM  * NS_LDAP_UPDATE_SHADOW is for a privileged caller of the
878821SMichen.Chang@Sun.COM  * __ns_ldap_repAttr() to update the shadow database on the
888821SMichen.Chang@Sun.COM  * LDAP server.
898821SMichen.Chang@Sun.COM  */
908821SMichen.Chang@Sun.COM #define	NS_LDAP_UPDATE_SHADOW	0x4000
918821SMichen.Chang@Sun.COM 
928821SMichen.Chang@Sun.COM /*
939576SJulian.Pullen@Sun.COM  * NS_LDAP_READ_SHADOW is for a privileged caller of __ns_ldap_list()
949576SJulian.Pullen@Sun.COM  * and __ns_ldap_firstEntry() to read the shadow database on the
959576SJulian.Pullen@Sun.COM  * LDAP server.
969576SJulian.Pullen@Sun.COM  */
979576SJulian.Pullen@Sun.COM #define	NS_LDAP_READ_SHADOW	0x8000
989576SJulian.Pullen@Sun.COM 
999576SJulian.Pullen@Sun.COM /*
1000Sstevel@tonic-gate  * Authentication Information
1010Sstevel@tonic-gate  */
1020Sstevel@tonic-gate typedef enum CredLevel {
1030Sstevel@tonic-gate 	NS_LDAP_CRED_ANON	= 0,
1040Sstevel@tonic-gate 	NS_LDAP_CRED_PROXY	= 1,
1052830Sdjl 	NS_LDAP_CRED_SELF	= 2
1060Sstevel@tonic-gate } CredLevel_t;
1070Sstevel@tonic-gate 
1080Sstevel@tonic-gate typedef enum AuthType {
1090Sstevel@tonic-gate 	NS_LDAP_AUTH_NONE	= 0,
1100Sstevel@tonic-gate 	NS_LDAP_AUTH_SIMPLE	= 1,
1110Sstevel@tonic-gate 	NS_LDAP_AUTH_SASL	= 2,
1120Sstevel@tonic-gate 	NS_LDAP_AUTH_TLS	= 3,	/* implied SASL usage */
1130Sstevel@tonic-gate 	NS_LDAP_AUTH_ATLS	= 4	/* implied SASL usage */
1140Sstevel@tonic-gate } AuthType_t;
1150Sstevel@tonic-gate 
1160Sstevel@tonic-gate typedef enum TlsType {
1170Sstevel@tonic-gate 	NS_LDAP_TLS_NONE	= 0,
1180Sstevel@tonic-gate 	NS_LDAP_TLS_SIMPLE	= 1,
1190Sstevel@tonic-gate 	NS_LDAP_TLS_SASL	= 2
1200Sstevel@tonic-gate } TlsType_t;
1210Sstevel@tonic-gate 
1220Sstevel@tonic-gate typedef enum SaslMech {
1230Sstevel@tonic-gate 	NS_LDAP_SASL_NONE	= 0,	/* No SASL mechanism */
1240Sstevel@tonic-gate 	NS_LDAP_SASL_CRAM_MD5	= 1,
1250Sstevel@tonic-gate 	NS_LDAP_SASL_DIGEST_MD5	= 2,
1260Sstevel@tonic-gate 	NS_LDAP_SASL_EXTERNAL	= 3,	/* currently not supported */
1272830Sdjl 	NS_LDAP_SASL_GSSAPI	= 4,
1280Sstevel@tonic-gate 	NS_LDAP_SASL_SPNEGO	= 5	/* currently not supported */
1290Sstevel@tonic-gate } SaslMech_t;
1300Sstevel@tonic-gate 
1310Sstevel@tonic-gate typedef enum SaslOpt {
1320Sstevel@tonic-gate 	NS_LDAP_SASLOPT_NONE	= 0,
1332830Sdjl 	NS_LDAP_SASLOPT_INT	= 1,
1342830Sdjl 	NS_LDAP_SASLOPT_PRIV	= 2
1350Sstevel@tonic-gate } SaslOpt_t;
1360Sstevel@tonic-gate 
1370Sstevel@tonic-gate typedef enum PrefOnly {
1380Sstevel@tonic-gate 	NS_LDAP_PREF_FALSE	= 0,
1390Sstevel@tonic-gate 	NS_LDAP_PREF_TRUE	= 1
1400Sstevel@tonic-gate } PrefOnly_t;
1410Sstevel@tonic-gate 
1428821SMichen.Chang@Sun.COM typedef enum enableShadowUpdate {
1438821SMichen.Chang@Sun.COM 	NS_LDAP_ENABLE_SHADOW_UPDATE_FALSE	= 0,
1448821SMichen.Chang@Sun.COM 	NS_LDAP_ENABLE_SHADOW_UPDATE_TRUE	= 1
1458821SMichen.Chang@Sun.COM } enableShadowUpdate_t;
1468821SMichen.Chang@Sun.COM 
1470Sstevel@tonic-gate typedef struct UnixCred {
1480Sstevel@tonic-gate 	char	*userID;	/* Unix ID number */
1490Sstevel@tonic-gate 	char	*passwd;	/* password */
1500Sstevel@tonic-gate } UnixCred_t;
1510Sstevel@tonic-gate 
1520Sstevel@tonic-gate typedef struct CertCred {
1530Sstevel@tonic-gate 	char	*path;		/* certificate path */
1540Sstevel@tonic-gate 	char	*passwd;	/* password */
1550Sstevel@tonic-gate 	char	*nickname;	/* nickname */
1560Sstevel@tonic-gate } CertCred_t;
1570Sstevel@tonic-gate 
1580Sstevel@tonic-gate typedef struct ns_auth {
1590Sstevel@tonic-gate 	AuthType_t	type;
1600Sstevel@tonic-gate 	TlsType_t	tlstype;
1610Sstevel@tonic-gate 	SaslMech_t	saslmech;
1620Sstevel@tonic-gate 	SaslOpt_t	saslopt;
1630Sstevel@tonic-gate } ns_auth_t;
1640Sstevel@tonic-gate 
1650Sstevel@tonic-gate typedef struct ns_cred {
1660Sstevel@tonic-gate 	ns_auth_t	auth;
1670Sstevel@tonic-gate 	char		*hostcertpath;
1680Sstevel@tonic-gate 	union {
1690Sstevel@tonic-gate 		UnixCred_t	unix_cred;
1700Sstevel@tonic-gate 		CertCred_t	cert_cred;
1710Sstevel@tonic-gate 	} cred;
1720Sstevel@tonic-gate } ns_cred_t;
1730Sstevel@tonic-gate 
1740Sstevel@tonic-gate 
1750Sstevel@tonic-gate typedef struct LineBuf {
1760Sstevel@tonic-gate 	char *str;
1770Sstevel@tonic-gate 	int len;
1780Sstevel@tonic-gate 	int alloc;
1790Sstevel@tonic-gate } LineBuf;
1800Sstevel@tonic-gate 
1810Sstevel@tonic-gate /*
1820Sstevel@tonic-gate  * Configuration Information
1830Sstevel@tonic-gate  */
1840Sstevel@tonic-gate 
1850Sstevel@tonic-gate typedef enum {
1860Sstevel@tonic-gate 	NS_LDAP_FILE_VERSION_P		= 0,
1870Sstevel@tonic-gate 	NS_LDAP_BINDDN_P		= 1,
1880Sstevel@tonic-gate 	NS_LDAP_BINDPASSWD_P		= 2,
1890Sstevel@tonic-gate 	NS_LDAP_SERVERS_P		= 3,
1900Sstevel@tonic-gate 	NS_LDAP_SEARCH_BASEDN_P		= 4,
1910Sstevel@tonic-gate 	NS_LDAP_AUTH_P			= 5,
1920Sstevel@tonic-gate /*
1930Sstevel@tonic-gate  * NS_LDAP_TRANSPORT_SEC_P is only left in for backward compatibility
1940Sstevel@tonic-gate  * with version 1 clients and their configuration files.  The only
1950Sstevel@tonic-gate  * supported value is NS_LDAP_SEC_NONE.  No application should be
1960Sstevel@tonic-gate  * using this parameter type (either through getParam or setParam.
1970Sstevel@tonic-gate  */
1980Sstevel@tonic-gate 	NS_LDAP_TRANSPORT_SEC_P		= 6,
1990Sstevel@tonic-gate 	NS_LDAP_SEARCH_REF_P		= 7,
2000Sstevel@tonic-gate 	NS_LDAP_DOMAIN_P		= 8,
2010Sstevel@tonic-gate 	NS_LDAP_EXP_P			= 9,
2020Sstevel@tonic-gate 	NS_LDAP_CERT_PATH_P		= 10,
2030Sstevel@tonic-gate 	NS_LDAP_CERT_PASS_P		= 11,
2040Sstevel@tonic-gate 	NS_LDAP_SEARCH_DN_P		= 12,
2050Sstevel@tonic-gate 	NS_LDAP_SEARCH_SCOPE_P		= 13,
2060Sstevel@tonic-gate 	NS_LDAP_SEARCH_TIME_P		= 14,
2070Sstevel@tonic-gate 	NS_LDAP_SERVER_PREF_P		= 15,
2080Sstevel@tonic-gate 	NS_LDAP_PREF_ONLY_P		= 16,
2090Sstevel@tonic-gate 	NS_LDAP_CACHETTL_P		= 17,
2100Sstevel@tonic-gate 	NS_LDAP_PROFILE_P		= 18,
2110Sstevel@tonic-gate 	NS_LDAP_CREDENTIAL_LEVEL_P	= 19,
2120Sstevel@tonic-gate 	NS_LDAP_SERVICE_SEARCH_DESC_P	= 20,
2130Sstevel@tonic-gate 	NS_LDAP_BIND_TIME_P		= 21,
2140Sstevel@tonic-gate 	NS_LDAP_ATTRIBUTEMAP_P		= 22,
2150Sstevel@tonic-gate 	NS_LDAP_OBJECTCLASSMAP_P	= 23,
2160Sstevel@tonic-gate 	NS_LDAP_CERT_NICKNAME_P		= 24,
2170Sstevel@tonic-gate 	NS_LDAP_SERVICE_AUTH_METHOD_P	= 25,
2180Sstevel@tonic-gate 	NS_LDAP_SERVICE_CRED_LEVEL_P	= 26,
2190Sstevel@tonic-gate 	NS_LDAP_HOST_CERTPATH_P		= 27,
2208821SMichen.Chang@Sun.COM 	NS_LDAP_ENABLE_SHADOW_UPDATE_P	= 28,
2218821SMichen.Chang@Sun.COM 	NS_LDAP_ADMIN_BINDDN_P		= 29,
2228821SMichen.Chang@Sun.COM 	NS_LDAP_ADMIN_BINDPASSWD_P	= 30,
2230Sstevel@tonic-gate /*
2240Sstevel@tonic-gate  * The following entry (max ParamIndexType) is an internal
2250Sstevel@tonic-gate  * placeholder.  It must be the last (and highest value)
2260Sstevel@tonic-gate  * entry in this eNum.  Please update accordingly.
2270Sstevel@tonic-gate  */
2288821SMichen.Chang@Sun.COM 	NS_LDAP_MAX_PIT_P		= 31
2290Sstevel@tonic-gate 
2300Sstevel@tonic-gate } ParamIndexType;
2310Sstevel@tonic-gate 
2320Sstevel@tonic-gate /*
2332830Sdjl  * NONE - No self / SASL/GSSAPI configured
2342830Sdjl  * ONLY - Only self / SASL/GSSAPI configured
2352830Sdjl  * MIXED - self / SASL/GSSAPI is mixed with other types of configuration
2362830Sdjl  */
2372830Sdjl typedef enum {
2382830Sdjl 	NS_LDAP_SELF_GSSAPI_CONFIG_NONE = 0,
2392830Sdjl 	NS_LDAP_SELF_GSSAPI_CONFIG_ONLY = 1,
2402830Sdjl 	NS_LDAP_SELF_GSSAPI_CONFIG_MIXED = 2
2412830Sdjl } ns_ldap_self_gssapi_config_t;
2422830Sdjl 
2432830Sdjl /*
2440Sstevel@tonic-gate  * __ns_ldap_*() return codes
2450Sstevel@tonic-gate  */
2460Sstevel@tonic-gate typedef enum {
2470Sstevel@tonic-gate 	NS_LDAP_SUCCESS		= 0, /* success, no info in errorp */
2480Sstevel@tonic-gate 	NS_LDAP_OP_FAILED	= 1, /* failed operation, no info in errorp */
2490Sstevel@tonic-gate 	NS_LDAP_NOTFOUND	= 2, /* entry not found, no info in errorp */
2500Sstevel@tonic-gate 	NS_LDAP_MEMORY		= 3, /* memory failure, no info in errorp */
2510Sstevel@tonic-gate 	NS_LDAP_CONFIG		= 4, /* config problem, detail in errorp */
2520Sstevel@tonic-gate 	NS_LDAP_PARTIAL		= 5, /* partial result, detail in errorp */
2530Sstevel@tonic-gate 	NS_LDAP_INTERNAL	= 7, /* LDAP error, detail in errorp */
2540Sstevel@tonic-gate 	NS_LDAP_INVALID_PARAM	= 8, /* LDAP error, no info in errorp */
2550Sstevel@tonic-gate 	NS_LDAP_SUCCESS_WITH_INFO
2560Sstevel@tonic-gate 				= 9  /* success, with info in errorp */
2570Sstevel@tonic-gate } ns_ldap_return_code;
2580Sstevel@tonic-gate 
2590Sstevel@tonic-gate /*
2600Sstevel@tonic-gate  * Detailed error code for NS_LDAP_CONFIG
2610Sstevel@tonic-gate  */
2620Sstevel@tonic-gate typedef enum {
2630Sstevel@tonic-gate 	NS_CONFIG_SYNTAX	= 0,	/* syntax error */
2640Sstevel@tonic-gate 	NS_CONFIG_NODEFAULT	= 1,	/* no default value */
2650Sstevel@tonic-gate 	NS_CONFIG_NOTLOADED	= 2,	/* configuration not loaded */
2660Sstevel@tonic-gate 	NS_CONFIG_NOTALLOW	= 3,	/* operation requested not allowed */
2670Sstevel@tonic-gate 	NS_CONFIG_FILE		= 4,	/* configuration file problem */
2680Sstevel@tonic-gate 	NS_CONFIG_CACHEMGR	= 5	/* error with door to ldap_cachemgr */
2690Sstevel@tonic-gate } ns_ldap_config_return_code;
2700Sstevel@tonic-gate 
2710Sstevel@tonic-gate /*
2720Sstevel@tonic-gate  * Detailed error code for NS_LDAP_PARTIAL
2730Sstevel@tonic-gate  */
2740Sstevel@tonic-gate typedef enum {
2750Sstevel@tonic-gate 	NS_PARTIAL_TIMEOUT	= 0,	/* partial results due to timeout */
2760Sstevel@tonic-gate 	NS_PARTIAL_OTHER	= 1	/* error encountered */
2770Sstevel@tonic-gate } ns_ldap_partial_return_code;
2780Sstevel@tonic-gate 
2790Sstevel@tonic-gate /*
2800Sstevel@tonic-gate  * For use by __ns_ldap_addTypedEntry() for publickey serivicetype
2810Sstevel@tonic-gate  */
2820Sstevel@tonic-gate typedef enum {
2830Sstevel@tonic-gate 	NS_HOSTCRED_FALSE = 0,
2840Sstevel@tonic-gate 	NS_HOSTCRED_TRUE  = 1
2850Sstevel@tonic-gate } hostcred_t;
2860Sstevel@tonic-gate 
2870Sstevel@tonic-gate /*
2880Sstevel@tonic-gate  * Detailed password status
2890Sstevel@tonic-gate  */
2900Sstevel@tonic-gate typedef enum {
2910Sstevel@tonic-gate 	NS_PASSWD_GOOD			= 0,	/* password is good */
2920Sstevel@tonic-gate 	NS_PASSWD_ABOUT_TO_EXPIRE	= 1,	/* password is good but */
2930Sstevel@tonic-gate 						/* about to expire */
2940Sstevel@tonic-gate 	NS_PASSWD_CHANGE_NEEDED		= 2,	/* good but need to be */
2950Sstevel@tonic-gate 						/* changed immediately */
2960Sstevel@tonic-gate 	NS_PASSWD_EXPIRED		= 3,	/* password expired */
2970Sstevel@tonic-gate 	NS_PASSWD_RETRY_EXCEEDED	= 4,	/* exceed retry limit; */
2980Sstevel@tonic-gate 						/* account is locked */
2990Sstevel@tonic-gate 	NS_PASSWD_CHANGE_NOT_ALLOWED	= 5,	/* can only be changed */
3000Sstevel@tonic-gate 						/* by the administrator */
3010Sstevel@tonic-gate 	NS_PASSWD_INVALID_SYNTAX	= 6,	/* can not be changed: */
3020Sstevel@tonic-gate 						/* new password has */
3030Sstevel@tonic-gate 						/* invalid syntax -- */
3048024SSerge.Dussud@Sun.COM 						/* trivial password: same */
3058024SSerge.Dussud@Sun.COM 						/* value as attr, cn, sn, */
3068024SSerge.Dussud@Sun.COM 						/* uid, etc. */
3078024SSerge.Dussud@Sun.COM 						/* or strong password */
3088024SSerge.Dussud@Sun.COM 						/* policies check */
3090Sstevel@tonic-gate 	NS_PASSWD_TOO_SHORT		= 7,	/* can not be changed: */
3100Sstevel@tonic-gate 						/* new password has */
3110Sstevel@tonic-gate 						/* less chars than */
3120Sstevel@tonic-gate 						/* required */
3130Sstevel@tonic-gate 	NS_PASSWD_IN_HISTORY		= 8,	/* can not be changed: */
3140Sstevel@tonic-gate 						/* reuse old password  */
3150Sstevel@tonic-gate 	NS_PASSWD_WITHIN_MIN_AGE	= 9 	/* can not be changed: */
3160Sstevel@tonic-gate 						/* within minimum age  */
3170Sstevel@tonic-gate } ns_ldap_passwd_status_t;
3180Sstevel@tonic-gate 
3190Sstevel@tonic-gate /*
3200Sstevel@tonic-gate  * Password management information structure
3211179Svv149972  *
3221179Svv149972  * This structure is different from AcctUsableResponse_t structure in
3231179Svv149972  * that this structure holds result of users account mgmt information when
3241179Svv149972  * an ldap bind is done with user name and user password.
3250Sstevel@tonic-gate  */
3260Sstevel@tonic-gate typedef struct ns_ldap_passwd_mgmt {
3270Sstevel@tonic-gate 	ns_ldap_passwd_status_t
3280Sstevel@tonic-gate 		status;			/* password status */
3290Sstevel@tonic-gate 	int	sec_until_expired;	/* seconds until expired, */
3300Sstevel@tonic-gate 					/* valid if status is */
3310Sstevel@tonic-gate 					/* NS_PASSWD_ABOUT_TO_EXPIRE */
3320Sstevel@tonic-gate } ns_ldap_passwd_mgmt_t;
3330Sstevel@tonic-gate 
3341179Svv149972 /*
3351179Svv149972  * LDAP V3 control flag for account management - Used for account management
3361179Svv149972  * when no password is provided
3371179Svv149972  */
3381179Svv149972 #define	NS_LDAP_ACCOUNT_USABLE_CONTROL	"1.3.6.1.4.1.42.2.27.9.5.8"
3391179Svv149972 
3401179Svv149972 /*
3411179Svv149972  * Structure for holding the response returned by server for
3421179Svv149972  * NS_LDAP_ACCOUNT_USABLE_CONTROL control when account is not available.
3431179Svv149972  */
3441179Svv149972 typedef struct AcctUsableMoreInfo {
3451179Svv149972 	int inactive;
3461179Svv149972 	int reset;
3471179Svv149972 	int expired;
3481179Svv149972 	int rem_grace;
3491179Svv149972 	int sec_b4_unlock;
3501179Svv149972 } AcctUsableMoreInfo_t;
3511179Svv149972 
3521179Svv149972 /*
3531179Svv149972  * Structure used to hold the response from the server for
3541179Svv149972  * NS_LDAP_ACCOUNT_USABLE_CONTROL control. The ASN1 notation is as below:
3551179Svv149972  *
3561179Svv149972  * ACCOUNT_USABLE_RESPONSE::= CHOICE {
3571179Svv149972  * is_available		[0] INTEGER, seconds before expiration
3581179Svv149972  * is_not_available	[1] More_info
3591179Svv149972  * }
3601179Svv149972  *
3611179Svv149972  * More_info::= SEQUENCE {
3621179Svv149972  * inactive		[0] BOOLEAN DEFAULT FALSE,
3631179Svv149972  * reset		[1] BOOLEAN DEFAULT FALSE,
3641179Svv149972  * expired		[2] BOOLEAN DEFAULT FALSE,
3651179Svv149972  * remaining_grace	[3] INTEGER OPTIONAL,
3661179Svv149972  * seconds_before_unlock[4] INTEGER OPTIONAL
3671179Svv149972  * }
3681179Svv149972  *
3691179Svv149972  * This structure is different from ns_ldap_passwd_mgmt_t structure in
3701179Svv149972  * that this structure holds result of users account mgmt information when
3711179Svv149972  * pam_ldap doesn't have the users password and proxy agent is used for
3721179Svv149972  * obtaining the account management information.
3731179Svv149972  */
3741179Svv149972 typedef struct AcctUsableResponse {
3751179Svv149972 	int choice;
3761179Svv149972 	union {
3771179Svv149972 		int seconds_before_expiry;
3781179Svv149972 		AcctUsableMoreInfo_t more_info;
3791179Svv149972 	} AcctUsableResp;
3801179Svv149972 } AcctUsableResponse_t;
3810Sstevel@tonic-gate 
3820Sstevel@tonic-gate /*
3830Sstevel@tonic-gate  * Simplified LDAP Naming API result structure
3840Sstevel@tonic-gate  */
3850Sstevel@tonic-gate typedef struct ns_ldap_error {
3860Sstevel@tonic-gate 	int	status;				/* LDAP error code */
3870Sstevel@tonic-gate 	char	*message;			/* LDAP error message */
3880Sstevel@tonic-gate 	ns_ldap_passwd_mgmt_t	pwd_mgmt;	/* LDAP password */
3890Sstevel@tonic-gate 						/* management info */
3900Sstevel@tonic-gate } ns_ldap_error_t;
3910Sstevel@tonic-gate 
3920Sstevel@tonic-gate typedef struct	 ns_ldap_attr {
3930Sstevel@tonic-gate 	char	*attrname;			/* attribute name */
3940Sstevel@tonic-gate 	uint_t	value_count;
3950Sstevel@tonic-gate 	char	**attrvalue;			/* attribute values */
3960Sstevel@tonic-gate } ns_ldap_attr_t;
3970Sstevel@tonic-gate 
3980Sstevel@tonic-gate typedef struct ns_ldap_entry {
3990Sstevel@tonic-gate 	uint_t		attr_count;		/* number of attributes */
4000Sstevel@tonic-gate 	ns_ldap_attr_t	**attr_pair;		/* attributes pairs */
4010Sstevel@tonic-gate 	struct ns_ldap_entry *next;		/* next entry */
4020Sstevel@tonic-gate } ns_ldap_entry_t;
4030Sstevel@tonic-gate 
4040Sstevel@tonic-gate typedef struct ns_ldap_result {
4050Sstevel@tonic-gate 	uint_t	entries_count;		/* number of entries */
4060Sstevel@tonic-gate 	ns_ldap_entry_t	*entry;		/* data */
4070Sstevel@tonic-gate } ns_ldap_result_t;
4080Sstevel@tonic-gate 
4090Sstevel@tonic-gate /*
4100Sstevel@tonic-gate  * structures for the conversion routines used by typedAddEntry()
4110Sstevel@tonic-gate  */
4120Sstevel@tonic-gate 
4130Sstevel@tonic-gate typedef struct _ns_netgroups {
4140Sstevel@tonic-gate 	char  *name;
4150Sstevel@tonic-gate 	char  **triplet;
4160Sstevel@tonic-gate 	char  **netgroup;
4170Sstevel@tonic-gate } _ns_netgroups_t;
4180Sstevel@tonic-gate 
4190Sstevel@tonic-gate typedef struct _ns_netmasks {
4200Sstevel@tonic-gate 	char *netnumber;
4210Sstevel@tonic-gate 	char *netmask;
4220Sstevel@tonic-gate } _ns_netmasks_t;
4230Sstevel@tonic-gate 
4240Sstevel@tonic-gate typedef struct _ns_bootp {
4250Sstevel@tonic-gate 	char *name;
4260Sstevel@tonic-gate 	char **param;
4270Sstevel@tonic-gate } _ns_bootp_t;
4280Sstevel@tonic-gate 
4290Sstevel@tonic-gate typedef struct _ns_ethers {
4300Sstevel@tonic-gate 	char *name;
4310Sstevel@tonic-gate 	char *ether;
4320Sstevel@tonic-gate } _ns_ethers_t;
4330Sstevel@tonic-gate 
4340Sstevel@tonic-gate typedef struct _ns_pubkey {
4350Sstevel@tonic-gate 	char *name;
4360Sstevel@tonic-gate 	hostcred_t hostcred;
4370Sstevel@tonic-gate 	char *pubkey;
4380Sstevel@tonic-gate 	char *privkey;
4390Sstevel@tonic-gate } _ns_pubkey_t;
4400Sstevel@tonic-gate 
4410Sstevel@tonic-gate typedef struct _ns_alias {
4420Sstevel@tonic-gate 	char *alias;
4430Sstevel@tonic-gate 	char **member;
4440Sstevel@tonic-gate } _ns_alias_t;
4450Sstevel@tonic-gate 
4460Sstevel@tonic-gate typedef struct _ns_automount {
4470Sstevel@tonic-gate 	char *mapname;
4480Sstevel@tonic-gate 	char *key;
4490Sstevel@tonic-gate 	char *value;
4500Sstevel@tonic-gate } _ns_automount_t;
4510Sstevel@tonic-gate 
4520Sstevel@tonic-gate /*
4530Sstevel@tonic-gate  * return values for the callback function in __ns_ldap_list()
4540Sstevel@tonic-gate  */
4550Sstevel@tonic-gate #define	NS_LDAP_CB_NEXT	0	/* get the next entry */
4560Sstevel@tonic-gate #define	NS_LDAP_CB_DONE	1	/* done */
4570Sstevel@tonic-gate 
4580Sstevel@tonic-gate /*
4590Sstevel@tonic-gate  * Input values for the type specified in __ns_ldap_addTypedEntry()
4600Sstevel@tonic-gate  * and __ns_ldap_delTypedEntry()
4610Sstevel@tonic-gate  */
4620Sstevel@tonic-gate 
4630Sstevel@tonic-gate #define	NS_LDAP_TYPE_PASSWD	"passwd"
4640Sstevel@tonic-gate #define	NS_LDAP_TYPE_GROUP	"group"
4650Sstevel@tonic-gate #define	NS_LDAP_TYPE_HOSTS	"hosts"
4660Sstevel@tonic-gate #define	NS_LDAP_TYPE_IPNODES	"ipnodes"
4670Sstevel@tonic-gate #define	NS_LDAP_TYPE_PROFILE	"prof_attr"
4680Sstevel@tonic-gate #define	NS_LDAP_TYPE_RPC	"rpc"
4690Sstevel@tonic-gate #define	NS_LDAP_TYPE_PROTOCOLS	"protocols"
4700Sstevel@tonic-gate #define	NS_LDAP_TYPE_NETWORKS	"networks"
4710Sstevel@tonic-gate #define	NS_LDAP_TYPE_NETGROUP	"netgroup"
4720Sstevel@tonic-gate #define	NS_LDAP_TYPE_ALIASES	"aliases"
4730Sstevel@tonic-gate #define	NS_LDAP_TYPE_SERVICES	"services"
4740Sstevel@tonic-gate #define	NS_LDAP_TYPE_ETHERS	"ethers"
4750Sstevel@tonic-gate #define	NS_LDAP_TYPE_SHADOW	"shadow"
4760Sstevel@tonic-gate #define	NS_LDAP_TYPE_NETMASKS	"netmasks"
4770Sstevel@tonic-gate #define	NS_LDAP_TYPE_AUTHATTR	"auth_attr"
4780Sstevel@tonic-gate #define	NS_LDAP_TYPE_EXECATTR	"exec_attr"
4790Sstevel@tonic-gate #define	NS_LDAP_TYPE_USERATTR	"user_attr"
4800Sstevel@tonic-gate #define	NS_LDAP_TYPE_PROJECT	"project"
4810Sstevel@tonic-gate #define	NS_LDAP_TYPE_PUBLICKEY	"publickey"
4820Sstevel@tonic-gate #define	NS_LDAP_TYPE_AUUSER	"audit_user"
4830Sstevel@tonic-gate #define	NS_LDAP_TYPE_BOOTPARAMS "bootparams"
4840Sstevel@tonic-gate #define	NS_LDAP_TYPE_AUTOMOUNT  "auto_"
4851676Sjpk #define	NS_LDAP_TYPE_TNRHDB	"tnrhdb"
4861676Sjpk #define	NS_LDAP_TYPE_TNRHTP	"tnrhtp"
4870Sstevel@tonic-gate 
4880Sstevel@tonic-gate /*
4890Sstevel@tonic-gate  * service descriptor/attribute mapping structure
4900Sstevel@tonic-gate  */
4910Sstevel@tonic-gate 
4920Sstevel@tonic-gate typedef struct ns_ldap_search_desc {
4930Sstevel@tonic-gate 	char		*basedn;	/* search base dn */
4940Sstevel@tonic-gate 	ScopeType_t	scope;		/* search scope */
4950Sstevel@tonic-gate 	char		*filter;	/* search filter */
4960Sstevel@tonic-gate } ns_ldap_search_desc_t;
4970Sstevel@tonic-gate 
4980Sstevel@tonic-gate typedef struct ns_ldap_attribute_map {
4990Sstevel@tonic-gate 	char		*origAttr;	/* original attribute */
5000Sstevel@tonic-gate 	char		**mappedAttr;	/* mapped attribute(s) */
5010Sstevel@tonic-gate } ns_ldap_attribute_map_t;
5020Sstevel@tonic-gate 
5030Sstevel@tonic-gate typedef struct ns_ldap_objectclass_map {
5040Sstevel@tonic-gate 	char		*origOC;	/* original objectclass */
5050Sstevel@tonic-gate 	char		*mappedOC;	/* mapped objectclass */
5060Sstevel@tonic-gate } ns_ldap_objectclass_map_t;
5070Sstevel@tonic-gate 
5088821SMichen.Chang@Sun.COM /*
5098821SMichen.Chang@Sun.COM  * Value of the userPassword attribute representing NO Unix password
5108821SMichen.Chang@Sun.COM  */
5118821SMichen.Chang@Sun.COM #define	NS_LDAP_NO_UNIX_PASSWORD	"<NO UNIX PASSWORD>"
5128821SMichen.Chang@Sun.COM 
5136616Sdm199847 /* Opaque handle for batch API */
5146616Sdm199847 typedef struct ns_ldap_list_batch ns_ldap_list_batch_t;
5156616Sdm199847 
5160Sstevel@tonic-gate /*
5176842Sth160488  * The type of standalone configuration specified by a client application.
5186842Sth160488  * The meaning of the requests is as follows:
5196842Sth160488  *
5206842Sth160488  * NS_CACHEMGR:    libsldap will request all the configuration via door_call(3C)
5216842Sth160488  *                 to ldap_cachemgr.
5226842Sth160488  * NS_LDAP_SERVER: the consumer application has specified a directory server
5236842Sth160488  *                 to communicate to.
5246842Sth160488  * NS_PREDEFINED:  reserved for internal use
5256842Sth160488  */
5266842Sth160488 typedef enum {
5276842Sth160488 	NS_CACHEMGR = 0,
5286842Sth160488 	NS_LDAP_SERVER
5296842Sth160488 } ns_standalone_request_type_t;
5306842Sth160488 
5316842Sth160488 /*
5326842Sth160488  * This structure describes an LDAP server specified by a client application.
5336842Sth160488  */
5346842Sth160488 typedef struct ns_dir_server {
5356842Sth160488 	char *server;			/* A directory server's IP */
5366842Sth160488 	uint16_t port;			/* A directory server's port. */
5376842Sth160488 					/* Default value is 389 */
5386842Sth160488 	char *domainName;		/* A domain name being served */
5396842Sth160488 					/* by the specified server. */
5406842Sth160488 					/* Default value is the local */
5416842Sth160488 					/* domain's name */
5426842Sth160488 	char *profileName;		/* A DUAProfile's name. */
5436842Sth160488 					/* Default value is 'default' */
5446842Sth160488 	ns_auth_t *auth;		/* Authentication information used */
5456842Sth160488 					/* during subsequent connections */
5466842Sth160488 	char *cred;			/* A credential level to be used */
5476842Sth160488 					/* along with the authentication info */
5486842Sth160488 	char *host_cert_path;		/* A path to the certificate database */
5496842Sth160488 					/* Default is '/vat/ldap' */
5506842Sth160488 	char *bind_dn;			/* A bind DN to be used during */
5516842Sth160488 					/* subsequent LDAP Bind requests */
5526842Sth160488 	char *bind_passwd;		/* A bind password to be used during */
5536842Sth160488 					/* subsequent LDAP Bind requests */
5546842Sth160488 } ns_dir_server_t;
5556842Sth160488 
5566842Sth160488 /*
5576842Sth160488  * This structure contains information describing an LDAP server.
5586842Sth160488  */
5596842Sth160488 typedef struct ns_standalone_conf {
5606842Sth160488 	union {
5616842Sth160488 		ns_dir_server_t server;
5626842Sth160488 		void *predefined_conf;	/* Reserved for internal use */
5636842Sth160488 	} ds_profile;			/* A type of the configuration */
5646842Sth160488 
5656842Sth160488 #define	SA_SERVER	ds_profile.server.server
5666842Sth160488 #define	SA_PORT		ds_profile.server.port
5676842Sth160488 #define	SA_DOMAIN	ds_profile.server.domainName
5686842Sth160488 #define	SA_PROFILE_NAME	ds_profile.server.profileName
5696842Sth160488 #define	SA_AUTH		ds_profile.server.auth
5706842Sth160488 #define	SA_CRED		ds_profile.server.cred
5716842Sth160488 #define	SA_CERT_PATH	ds_profile.server.host_cert_path
5726842Sth160488 #define	SA_BIND_DN	ds_profile.server.bind_dn
5736842Sth160488 #define	SA_BIND_PWD	ds_profile.server.bind_passwd
5746842Sth160488 
5756842Sth160488 	ns_standalone_request_type_t type;
5766842Sth160488 } ns_standalone_conf_t;
5776842Sth160488 
5786842Sth160488 /*
5796842Sth160488  * This function "informs" libsldap that a client application has specified
5806842Sth160488  * a directory to use. The function obtains a DUAProfile, credentials,
5816842Sth160488  * and naming context. During all further operations on behalf
5826842Sth160488  * of the application requested a standalone schema libsldap will use
5836842Sth160488  * the information obtained by __ns_ldap_initStandalone() instead of
5846842Sth160488  * door_call(3C)ing ldap_cachemgr(1M).
5856842Sth160488  *
5866842Sth160488  * conf
5876842Sth160488  * 	A structure describing where and in which way to obtain all the
5886842Sth160488  * 	configuration describing how to communicate to a choosen LDAP directory.
5896842Sth160488  *
5906842Sth160488  * errorp
5916842Sth160488  * 	An error object describing an error occured.
5926842Sth160488  */
5936842Sth160488 ns_ldap_return_code __ns_ldap_initStandalone(
5946842Sth160488 	const ns_standalone_conf_t *conf,
5956842Sth160488 	ns_ldap_error_t	**errorp);
5966842Sth160488 
5976842Sth160488 /*
5986842Sth160488  * This function obtains the directory's base DN and a DUAProfile
5996842Sth160488  * from a specified server.
6006842Sth160488  *
6016842Sth160488  * server
6026842Sth160488  * 	Specifies the selected directory sever.
6036842Sth160488  *
6046842Sth160488  * cred
6056842Sth160488  * 	Contains an authentication information and credential required to
6066842Sth160488  * 	establish a connection.
6076842Sth160488  *
6086842Sth160488  * config
6096842Sth160488  * 	If not NULL, a new configuration basing on a DUAProfile specified in the
6106842Sth160488  * 	server parameter will be create and returned.
6116842Sth160488  *
6126842Sth160488  * baseDN
6136842Sth160488  * 	If not NULL, the directory's base DN will be returned.
6146842Sth160488  *
6156842Sth160488  * error
6166842Sth160488  * 	Describes an error, if any.
6176842Sth160488  */
6186842Sth160488 ns_ldap_return_code __ns_ldap_getConnectionInfoFromDUA(
6196842Sth160488 	const ns_dir_server_t *server,
6206842Sth160488 	const ns_cred_t *cred,
6216842Sth160488 	char **config,	char **baseDN,
6226842Sth160488 	ns_ldap_error_t **error);
6236842Sth160488 
6246842Sth160488 #define	SA_PROHIBIT_FALLBACK 0
6256842Sth160488 #define	SA_ALLOW_FALLBACK 1
6266842Sth160488 
6276842Sth160488 #define	DONT_SAVE_NSCONF 0
6286842Sth160488 #define	SAVE_NSCONF 1
6296842Sth160488 
6306842Sth160488 /*
6316842Sth160488  * This function obtains the root DSE from a specified server.
6326842Sth160488  *
6336842Sth160488  * server_addr
6346842Sth160488  * 	An adress of a server to be connected to.
6356842Sth160488  *
6366842Sth160488  * rootDSE
6376842Sth160488  * 	A buffer containing the root DSE in the ldap_cachmgr door call format.
6386842Sth160488  *
6396842Sth160488  * errorp
6406842Sth160488  * 	Describes an error, if any.
6416842Sth160488  *
6426842Sth160488  * anon_fallback
6436842Sth160488  * 	If set to 1 and establishing a connection fails, __s_api_getRootDSE()
6446842Sth160488  * 	will try once again using anonymous credentials.
6456842Sth160488  */
6466842Sth160488 ns_ldap_return_code __ns_ldap_getRootDSE(
6476842Sth160488 	const char *server_addr,
6486842Sth160488 	char **rootDSE,
6496842Sth160488 	ns_ldap_error_t **errorp,
6506842Sth160488 	int anon_fallback);
6516842Sth160488 
6526842Sth160488 /*
6536842Sth160488  * This function iterates through the list of the configured LDAP servers
6546842Sth160488  * and "pings" those which are marked as removed or if any error occurred
6556842Sth160488  * during the previous receiving of the server's root DSE. If the
6566842Sth160488  * function is able to reach such a server and get its root DSE, it
6576842Sth160488  * marks the server as on-line. Otherwise, the server's status is set
6586842Sth160488  * to "Error".
6596842Sth160488  * For each server the function tries to connect to, it fires up
6606842Sth160488  * a separate thread and then waits until all the threads finish.
6616842Sth160488  * The function returns NS_LDAP_INTERNAL if the Standalone mode was not
6626842Sth160488  * initialized or was canceled prior to an invocation of
6636842Sth160488  * __ns_ldap_pingOfflineServers().
6646842Sth160488  */
6656842Sth160488 ns_ldap_return_code __ns_ldap_pingOfflineServers(void);
6666842Sth160488 
6676842Sth160488 /*
6686842Sth160488  * This function cancels the Standalone mode and destroys the list of root DSEs.
6696842Sth160488  */
6706842Sth160488 void __ns_ldap_cancelStandalone(void);
6716842Sth160488 /*
6726842Sth160488  * This function initializes an ns_auth_t structure provided by a caller
6736842Sth160488  * according to a specified authentication mechanism.
6746842Sth160488  */
6756842Sth160488 ns_ldap_return_code __ns_ldap_initAuth(const char *auth_mech,
6766842Sth160488 	ns_auth_t *auth,
6776842Sth160488 	ns_ldap_error_t **errorp);
6786842Sth160488 
6796842Sth160488 /*
6800Sstevel@tonic-gate  * Simplified LDAP Naming APIs
6810Sstevel@tonic-gate  */
6820Sstevel@tonic-gate int __ns_ldap_list(
6830Sstevel@tonic-gate 	const char *service,
6840Sstevel@tonic-gate 	const char *filter,
6850Sstevel@tonic-gate 	int (*init_filter_cb)(const ns_ldap_search_desc_t *desc,
6860Sstevel@tonic-gate 			char **realfilter, const void *userdata),
6870Sstevel@tonic-gate 	const char * const *attribute,
6880Sstevel@tonic-gate 	const ns_cred_t *cred,
6890Sstevel@tonic-gate 	const int flags,
6900Sstevel@tonic-gate 	ns_ldap_result_t ** result,
6910Sstevel@tonic-gate 	ns_ldap_error_t ** errorp,
6920Sstevel@tonic-gate 	int (*callback)(const ns_ldap_entry_t *entry, const void *userdata),
6930Sstevel@tonic-gate 	const void *userdata);
6940Sstevel@tonic-gate 
69512758SJulian.Pullen@Sun.COM 
69612758SJulian.Pullen@Sun.COM int __ns_ldap_list_sort(
69712758SJulian.Pullen@Sun.COM 	const char *service,
69812758SJulian.Pullen@Sun.COM 	const char *filter,
69912758SJulian.Pullen@Sun.COM 	const char *sortattr,
70012758SJulian.Pullen@Sun.COM 	int (*init_filter_cb)(const ns_ldap_search_desc_t *desc,
70112758SJulian.Pullen@Sun.COM 			char **realfilter, const void *userdata),
70212758SJulian.Pullen@Sun.COM 	const char * const *attribute,
70312758SJulian.Pullen@Sun.COM 	const ns_cred_t *cred,
70412758SJulian.Pullen@Sun.COM 	const int flags,
70512758SJulian.Pullen@Sun.COM 	ns_ldap_result_t ** result,
70612758SJulian.Pullen@Sun.COM 	ns_ldap_error_t ** errorp,
70712758SJulian.Pullen@Sun.COM 	int (*callback)(const ns_ldap_entry_t *entry, const void *userdata),
70812758SJulian.Pullen@Sun.COM 	const void *userdata);
70912758SJulian.Pullen@Sun.COM 
7106616Sdm199847 int __ns_ldap_list_batch_start(
7116616Sdm199847 	ns_ldap_list_batch_t **batch);
7126616Sdm199847 
7136616Sdm199847 int __ns_ldap_list_batch_add(
7146616Sdm199847 	ns_ldap_list_batch_t *batch,
7156616Sdm199847 	const char *service,
7166616Sdm199847 	const char *filter,
7176616Sdm199847 	int (*init_filter_cb)(const ns_ldap_search_desc_t *desc,
7186616Sdm199847 			char **realfilter, const void *userdata),
7196616Sdm199847 	const char * const *attribute,
7206616Sdm199847 	const ns_cred_t *cred,
7216616Sdm199847 	const int flags,
7226616Sdm199847 	ns_ldap_result_t ** result,
7236616Sdm199847 	ns_ldap_error_t ** errorp,
7246616Sdm199847 	int *rcp,
7256616Sdm199847 	int (*callback)(const ns_ldap_entry_t *entry, const void *userdata),
7266616Sdm199847 	const void *userdata);
7276616Sdm199847 
7286616Sdm199847 int __ns_ldap_list_batch_end(
7296616Sdm199847 	ns_ldap_list_batch_t *batch);
7306616Sdm199847 
7316616Sdm199847 void __ns_ldap_list_batch_release(
7326616Sdm199847 	ns_ldap_list_batch_t *batch);
7336616Sdm199847 
7340Sstevel@tonic-gate int  __ns_ldap_addAttr(
7350Sstevel@tonic-gate 	const char *service,
7360Sstevel@tonic-gate 	const char *dn,
7370Sstevel@tonic-gate 	const ns_ldap_attr_t * const *attr,
7380Sstevel@tonic-gate 	const ns_cred_t *cred,
7390Sstevel@tonic-gate 	const int flags,
7400Sstevel@tonic-gate 	ns_ldap_error_t **errorp);
7410Sstevel@tonic-gate 
7420Sstevel@tonic-gate int __ns_ldap_delAttr(
7430Sstevel@tonic-gate 	const char *service,
7440Sstevel@tonic-gate 	const char *dn,
7450Sstevel@tonic-gate 	const ns_ldap_attr_t * const *attr,
7460Sstevel@tonic-gate 	const ns_cred_t *cred,
7470Sstevel@tonic-gate 	const int flags,
7480Sstevel@tonic-gate 	ns_ldap_error_t **errorp);
7490Sstevel@tonic-gate 
7500Sstevel@tonic-gate int  __ns_ldap_repAttr(
7510Sstevel@tonic-gate 	const char *service,
7520Sstevel@tonic-gate 	const char *dn,
7530Sstevel@tonic-gate 	const ns_ldap_attr_t * const *attr,
7540Sstevel@tonic-gate 	const ns_cred_t *cred,
7550Sstevel@tonic-gate 	const int flags,
7560Sstevel@tonic-gate 	ns_ldap_error_t **errorp);
7570Sstevel@tonic-gate 
7580Sstevel@tonic-gate int  __ns_ldap_addEntry(
7590Sstevel@tonic-gate 	const char *service,
7600Sstevel@tonic-gate 	const char *dn,
7610Sstevel@tonic-gate 	const ns_ldap_entry_t *entry,
7620Sstevel@tonic-gate 	const ns_cred_t *cred,
7630Sstevel@tonic-gate 	const int flags,
7640Sstevel@tonic-gate 	ns_ldap_error_t **errorp);
7650Sstevel@tonic-gate 
7660Sstevel@tonic-gate int  __ns_ldap_addTypedEntry(
7670Sstevel@tonic-gate 	const char *servicetype,
7680Sstevel@tonic-gate 	const char *basedn,
7690Sstevel@tonic-gate 	const void *data,
7700Sstevel@tonic-gate 	const int  create,
7710Sstevel@tonic-gate 	const ns_cred_t *cred,
7720Sstevel@tonic-gate 	const int flags,
7730Sstevel@tonic-gate 	ns_ldap_error_t **errorp);
7740Sstevel@tonic-gate 
7750Sstevel@tonic-gate int __ns_ldap_delEntry(
7760Sstevel@tonic-gate 	const char *service,
7770Sstevel@tonic-gate 	const char *dn,
7780Sstevel@tonic-gate 	const ns_cred_t *cred,
7790Sstevel@tonic-gate 	const int flags,
7800Sstevel@tonic-gate 	ns_ldap_error_t **errorp);
7810Sstevel@tonic-gate 
7820Sstevel@tonic-gate int __ns_ldap_firstEntry(
7830Sstevel@tonic-gate 	const char *service,
7840Sstevel@tonic-gate 	const char *filter,
78512758SJulian.Pullen@Sun.COM 	const char *sortattr,
7860Sstevel@tonic-gate 	int (*init_filter_cb)(const ns_ldap_search_desc_t *desc,
7870Sstevel@tonic-gate 			char **realfilter, const void *userdata),
7880Sstevel@tonic-gate 	const char * const *attribute,
7890Sstevel@tonic-gate 	const ns_cred_t *cred,
7900Sstevel@tonic-gate 	const int flags,
7910Sstevel@tonic-gate 	void **cookie,
7920Sstevel@tonic-gate 	ns_ldap_result_t ** result,
7930Sstevel@tonic-gate 	ns_ldap_error_t **errorp,
7940Sstevel@tonic-gate 	const void *userdata);
7950Sstevel@tonic-gate 
7960Sstevel@tonic-gate int  __ns_ldap_nextEntry(
7970Sstevel@tonic-gate 	void *cookie,
7980Sstevel@tonic-gate 	ns_ldap_result_t ** result,
7990Sstevel@tonic-gate 	ns_ldap_error_t **errorp);
8000Sstevel@tonic-gate 
8010Sstevel@tonic-gate int  __ns_ldap_endEntry(
8020Sstevel@tonic-gate 	void **cookie,
8030Sstevel@tonic-gate 	ns_ldap_error_t **errorp);
8040Sstevel@tonic-gate 
8050Sstevel@tonic-gate int __ns_ldap_freeResult(
8060Sstevel@tonic-gate 	ns_ldap_result_t **result);
8070Sstevel@tonic-gate 
8080Sstevel@tonic-gate int __ns_ldap_freeError(
8090Sstevel@tonic-gate 	ns_ldap_error_t **errorp);
8100Sstevel@tonic-gate 
8110Sstevel@tonic-gate int  __ns_ldap_uid2dn(
8120Sstevel@tonic-gate 	const char *uid,
8130Sstevel@tonic-gate 	char **userDN,
8140Sstevel@tonic-gate 	const ns_cred_t *cred,
8150Sstevel@tonic-gate 	ns_ldap_error_t ** errorp);
8160Sstevel@tonic-gate 
8170Sstevel@tonic-gate int  __ns_ldap_host2dn(
8180Sstevel@tonic-gate 	const char *host,
8190Sstevel@tonic-gate 	const char *domain,
8200Sstevel@tonic-gate 	char **hostDN,
8210Sstevel@tonic-gate 	const ns_cred_t *cred,
8220Sstevel@tonic-gate 	ns_ldap_error_t ** errorp);
8230Sstevel@tonic-gate 
8240Sstevel@tonic-gate int  __ns_ldap_dn2domain(
8250Sstevel@tonic-gate 	const char *dn,
8260Sstevel@tonic-gate 	char **domain,
8270Sstevel@tonic-gate 	const ns_cred_t *cred,
8280Sstevel@tonic-gate 	ns_ldap_error_t ** errorp);
8290Sstevel@tonic-gate 
8300Sstevel@tonic-gate int __ns_ldap_auth(
8310Sstevel@tonic-gate 	const ns_cred_t *cred,
8320Sstevel@tonic-gate 	const int flag,
8330Sstevel@tonic-gate 	ns_ldap_error_t **errorp,
8340Sstevel@tonic-gate 	LDAPControl **serverctrls,
8350Sstevel@tonic-gate 	LDAPControl **clientctrls);
8360Sstevel@tonic-gate 
8370Sstevel@tonic-gate int __ns_ldap_freeCred(
8380Sstevel@tonic-gate 	ns_cred_t **credp);
8390Sstevel@tonic-gate 
8400Sstevel@tonic-gate int __ns_ldap_err2str(
8410Sstevel@tonic-gate 	int err,
8420Sstevel@tonic-gate 	char **strmsg);
8430Sstevel@tonic-gate 
8440Sstevel@tonic-gate int __ns_ldap_setParam(
8450Sstevel@tonic-gate 	const ParamIndexType type,
8460Sstevel@tonic-gate 	const void *data,
8470Sstevel@tonic-gate 	ns_ldap_error_t **errorp);
8480Sstevel@tonic-gate 
8490Sstevel@tonic-gate int __ns_ldap_getParam(
8500Sstevel@tonic-gate 	const ParamIndexType type,
8510Sstevel@tonic-gate 	void ***data,
8520Sstevel@tonic-gate 	ns_ldap_error_t **errorp);
8530Sstevel@tonic-gate 
8540Sstevel@tonic-gate int __ns_ldap_freeParam(
8550Sstevel@tonic-gate 	void ***data);
8560Sstevel@tonic-gate 
8570Sstevel@tonic-gate char **__ns_ldap_getAttr(
8580Sstevel@tonic-gate 	const ns_ldap_entry_t *entry,
8590Sstevel@tonic-gate 	const char *attrname);
8600Sstevel@tonic-gate 
8612830Sdjl ns_ldap_attr_t	*__ns_ldap_getAttrStruct(
8622830Sdjl 	const ns_ldap_entry_t *entry,
8632830Sdjl 	const char *attrname);
8642830Sdjl 
8650Sstevel@tonic-gate int __ns_ldap_getServiceAuthMethods(
8660Sstevel@tonic-gate 	const char *service,
8670Sstevel@tonic-gate 	ns_auth_t ***auth,
8680Sstevel@tonic-gate 	ns_ldap_error_t **errorp);
8690Sstevel@tonic-gate 
8700Sstevel@tonic-gate int __ns_ldap_getSearchDescriptors(
8710Sstevel@tonic-gate 	const char *service,
8720Sstevel@tonic-gate 	ns_ldap_search_desc_t ***desc,
8730Sstevel@tonic-gate 	ns_ldap_error_t **errorp);
8740Sstevel@tonic-gate 
8750Sstevel@tonic-gate int __ns_ldap_freeSearchDescriptors(
8760Sstevel@tonic-gate 	ns_ldap_search_desc_t ***desc);
8770Sstevel@tonic-gate 
8780Sstevel@tonic-gate int __ns_ldap_getAttributeMaps(
8790Sstevel@tonic-gate 	const char *service,
8800Sstevel@tonic-gate 	ns_ldap_attribute_map_t ***maps,
8810Sstevel@tonic-gate 	ns_ldap_error_t **errorp);
8820Sstevel@tonic-gate 
8830Sstevel@tonic-gate int __ns_ldap_freeAttributeMaps(
8840Sstevel@tonic-gate 	ns_ldap_attribute_map_t ***maps);
8850Sstevel@tonic-gate 
8860Sstevel@tonic-gate char **__ns_ldap_getMappedAttributes(
8870Sstevel@tonic-gate 	const char *service,
8880Sstevel@tonic-gate 	const char *origAttribute);
8890Sstevel@tonic-gate 
8900Sstevel@tonic-gate char **__ns_ldap_getOrigAttribute(
8910Sstevel@tonic-gate 	const char *service,
8920Sstevel@tonic-gate 	const char *mappedAttribute);
8930Sstevel@tonic-gate 
8940Sstevel@tonic-gate int __ns_ldap_getObjectClassMaps(
8950Sstevel@tonic-gate 	const char *service,
8960Sstevel@tonic-gate 	ns_ldap_objectclass_map_t ***maps,
8970Sstevel@tonic-gate 	ns_ldap_error_t **errorp);
8980Sstevel@tonic-gate 
8990Sstevel@tonic-gate int __ns_ldap_freeObjectClassMaps(
9000Sstevel@tonic-gate 	ns_ldap_objectclass_map_t ***maps);
9010Sstevel@tonic-gate 
9020Sstevel@tonic-gate char **__ns_ldap_getMappedObjectClass(
9030Sstevel@tonic-gate 	const char *service,
9040Sstevel@tonic-gate 	const char *origObjectClass);
9050Sstevel@tonic-gate 
9060Sstevel@tonic-gate char **__ns_ldap_getOrigObjectClass(
9070Sstevel@tonic-gate 	const char *service,
9080Sstevel@tonic-gate 	const char *mappedObjectClass);
9090Sstevel@tonic-gate 
9100Sstevel@tonic-gate int __ns_ldap_getParamType(
9110Sstevel@tonic-gate 	const char *value,
9120Sstevel@tonic-gate 	ParamIndexType *type);
9131179Svv149972 
9141179Svv149972 int __ns_ldap_getAcctMgmt(
9151179Svv149972 	const char *user,
9161179Svv149972 	AcctUsableResponse_t *acctResp);
9178821SMichen.Chang@Sun.COM 
918*12882SJulian.Pullen@Sun.COM boolean_t __ns_ldap_is_shadow_update_enabled(void);
9198821SMichen.Chang@Sun.COM 
9202830Sdjl void
9212830Sdjl __ns_ldap_self_gssapi_only_set(
9222830Sdjl 	int flag);
9232830Sdjl int
9242830Sdjl __ns_ldap_self_gssapi_config(
9252830Sdjl 	ns_ldap_self_gssapi_config_t *config);
9260Sstevel@tonic-gate #ifdef __cplusplus
9270Sstevel@tonic-gate }
9280Sstevel@tonic-gate #endif
9290Sstevel@tonic-gate 
9300Sstevel@tonic-gate #endif /* _NS_SLDAP_H */
931