xref: /illumos-gate/usr/src/uts/common/rpcsvc/idmap_prot.x (revision 148c5f43199ca0b43fc8e3b643aab11cd66ea327)
19b214d32SJordan Brown /*
29b214d32SJordan Brown  * CDDL HEADER START
39b214d32SJordan Brown  *
49b214d32SJordan Brown  * The contents of this file are subject to the terms of the
59b214d32SJordan Brown  * Common Development and Distribution License (the "License").
69b214d32SJordan Brown  * You may not use this file except in compliance with the License.
79b214d32SJordan Brown  *
89b214d32SJordan Brown  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
99b214d32SJordan Brown  * or http://www.opensolaris.org/os/licensing.
109b214d32SJordan Brown  * See the License for the specific language governing permissions
119b214d32SJordan Brown  * and limitations under the License.
129b214d32SJordan Brown  *
139b214d32SJordan Brown  * When distributing Covered Code, include this CDDL HEADER in each
149b214d32SJordan Brown  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
159b214d32SJordan Brown  * If applicable, add the following below this CDDL HEADER, with the
169b214d32SJordan Brown  * fields enclosed by brackets "[]" replaced with your own identifying
179b214d32SJordan Brown  * information: Portions Copyright [yyyy] [name of copyright owner]
189b214d32SJordan Brown  *
199b214d32SJordan Brown  * CDDL HEADER END
209b214d32SJordan Brown  */
219b214d32SJordan Brown /*
22*148c5f43SAlan Wright  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
239b214d32SJordan Brown  */
249b214d32SJordan Brown 
25*148c5f43SAlan Wright %#if	defined(_KERNEL)
26*148c5f43SAlan Wright %#include <sys/nvpair.h>
27*148c5f43SAlan Wright %#else
28*148c5f43SAlan Wright %#include <libnvpair.h>
29*148c5f43SAlan Wright %#endif
30*148c5f43SAlan Wright 
31*148c5f43SAlan Wright /*
32*148c5f43SAlan Wright  * XDR support for nvlist_t.  libnvpair includes support for serializing
33*148c5f43SAlan Wright  * an nvlist, but does not include any direct XDR plug-in support.  Support
34*148c5f43SAlan Wright  * is made trickier by the fact that on read xdr_pointer() wants to allocate
35*148c5f43SAlan Wright  * structures on its own, even when there's a custom xdr_*() function for
36*148c5f43SAlan Wright  * the structure.  nvlist_unpack *also* wants to allocate the nvlist_t,
37*148c5f43SAlan Wright  * and it seems wrong to burn sizeof(nvlist_t) into the program binary.
38*148c5f43SAlan Wright  *
39*148c5f43SAlan Wright  * Another possibility is to use opaque<> in this declaration, but that
40*148c5f43SAlan Wright  * requires moving part of the encoding (the interaction with nvlist_pack
41*148c5f43SAlan Wright  * and nvlist_unpack) out into the application, instead of keeping it
42*148c5f43SAlan Wright  * all encapsulated in this layer.
43*148c5f43SAlan Wright  *
44*148c5f43SAlan Wright  * The resolution here is to put an nvlist_t * into a new typedef, and have
45*148c5f43SAlan Wright  * *that* typedef have a custom xdr_*() function.  xdr allocates space for
46*148c5f43SAlan Wright  * the pointer, but leaves all initialization of it nvlist_t *) to the
47*148c5f43SAlan Wright  * custom function.
48*148c5f43SAlan Wright  */
49*148c5f43SAlan Wright #if	defined(RPC_HDR)
50*148c5f43SAlan Wright %typedef nvlist_t *nvlist_t_ptr;
51*148c5f43SAlan Wright #endif
52*148c5f43SAlan Wright 
53*148c5f43SAlan Wright #if	defined(RPC_XDR)
54*148c5f43SAlan Wright %#if	!defined(_KERNEL)
55*148c5f43SAlan Wright %#include <string.h>
56*148c5f43SAlan Wright %#include <stdio.h>
57*148c5f43SAlan Wright %#endif
58*148c5f43SAlan Wright %
59*148c5f43SAlan Wright %bool_t
60*148c5f43SAlan Wright %xdr_nvlist_t_ptr(XDR *xdrs, nvlist_t_ptr *n)
61*148c5f43SAlan Wright %{
62*148c5f43SAlan Wright %	char *buf;
63*148c5f43SAlan Wright %	u_int len;
64*148c5f43SAlan Wright %	bool_t ret;
65*148c5f43SAlan Wright %	int err;
66*148c5f43SAlan Wright %	size_t	sz;
67*148c5f43SAlan Wright %	bool_t	present;
68*148c5f43SAlan Wright %
69*148c5f43SAlan Wright %	switch (xdrs->x_op) {
70*148c5f43SAlan Wright %	case XDR_DECODE:
71*148c5f43SAlan Wright %		if (!xdr_bool(xdrs, &present))
72*148c5f43SAlan Wright %			return (FALSE);
73*148c5f43SAlan Wright %		if (!present) {
74*148c5f43SAlan Wright %			*n = NULL;
75*148c5f43SAlan Wright %			return (TRUE);
76*148c5f43SAlan Wright %		}
77*148c5f43SAlan Wright %		buf = NULL;
78*148c5f43SAlan Wright %		if (!xdr_bytes(xdrs, &buf, &len, ~0))
79*148c5f43SAlan Wright %			return (FALSE);
80*148c5f43SAlan Wright %
81*148c5f43SAlan Wright %		err = nvlist_unpack(buf, (size_t)len, n, 0);
82*148c5f43SAlan Wright %#if	defined(_KERNEL)
83*148c5f43SAlan Wright %		kmem_free(buf, len);
84*148c5f43SAlan Wright %#else
85*148c5f43SAlan Wright %		free(buf);
86*148c5f43SAlan Wright %#endif
87*148c5f43SAlan Wright %
88*148c5f43SAlan Wright %		if (err != 0) {
89*148c5f43SAlan Wright %#if	!defined(_KERNEL)
90*148c5f43SAlan Wright %			fprintf(stderr, "xdr_nvlist_t unpack:  %s\n",
91*148c5f43SAlan Wright %			    strerror(err));
92*148c5f43SAlan Wright %#endif
93*148c5f43SAlan Wright %			return (FALSE);
94*148c5f43SAlan Wright %		}
95*148c5f43SAlan Wright %		return (TRUE);
96*148c5f43SAlan Wright %
97*148c5f43SAlan Wright %	case XDR_ENCODE:
98*148c5f43SAlan Wright %		present = (*n != NULL);
99*148c5f43SAlan Wright %		if (!xdr_bool(xdrs, &present))
100*148c5f43SAlan Wright %			return (FALSE);
101*148c5f43SAlan Wright %		if (!present)
102*148c5f43SAlan Wright %			return (TRUE);
103*148c5f43SAlan Wright %		buf = NULL;
104*148c5f43SAlan Wright %		err = nvlist_pack(*n, &buf, &sz, NV_ENCODE_XDR, 0);
105*148c5f43SAlan Wright %		if (err != 0) {
106*148c5f43SAlan Wright %#if	!defined(_KERNEL)
107*148c5f43SAlan Wright %			fprintf(stderr, "xdr_nvlist_t pack:  %s\n",
108*148c5f43SAlan Wright %			    strerror(err));
109*148c5f43SAlan Wright %#endif
110*148c5f43SAlan Wright %			return (FALSE);
111*148c5f43SAlan Wright %		}
112*148c5f43SAlan Wright %
113*148c5f43SAlan Wright %		/* nvlist_pack() and xdr_bytes() want different types */
114*148c5f43SAlan Wright %		len = (u_int) sz;
115*148c5f43SAlan Wright %
116*148c5f43SAlan Wright %		ret = xdr_bytes(xdrs, &buf, &len, ~0);
117*148c5f43SAlan Wright %#if	defined(_KERNEL)
118*148c5f43SAlan Wright %		kmem_free(buf, len);
119*148c5f43SAlan Wright %#else
120*148c5f43SAlan Wright %		free(buf);
121*148c5f43SAlan Wright %#endif
122*148c5f43SAlan Wright %
123*148c5f43SAlan Wright %		return (ret);
124*148c5f43SAlan Wright %
125*148c5f43SAlan Wright %	case XDR_FREE:
126*148c5f43SAlan Wright %		if (*n != NULL) {
127*148c5f43SAlan Wright %			nvlist_free(*n);
128*148c5f43SAlan Wright %			*n = NULL;
129*148c5f43SAlan Wright %		}
130*148c5f43SAlan Wright %		return (TRUE);
131*148c5f43SAlan Wright %
132*148c5f43SAlan Wright %	default:
133*148c5f43SAlan Wright %		return (FALSE);
134*148c5f43SAlan Wright %	}
135*148c5f43SAlan Wright %}
136*148c5f43SAlan Wright #endif
137*148c5f43SAlan Wright 
1389b214d32SJordan Brown /* opaque type to support non-ASCII strings */
1399b214d32SJordan Brown typedef	string	idmap_utf8str<>;
1401fcced4cSJordan Brown typedef	idmap_utf8str	idmap_utf8str_list<>;
1419b214d32SJordan Brown 
1429b214d32SJordan Brown /* Return status */
1439b214d32SJordan Brown typedef int idmap_retcode;
1449b214d32SJordan Brown 
1459b214d32SJordan Brown /* Identity types */
1469b214d32SJordan Brown enum idmap_id_type {
1479b214d32SJordan Brown 	IDMAP_NONE = 0,
1489b214d32SJordan Brown 	IDMAP_UID = 1,
1499b214d32SJordan Brown 	IDMAP_GID,
1509b214d32SJordan Brown 	IDMAP_SID,
1519b214d32SJordan Brown 	IDMAP_USID,
1529b214d32SJordan Brown 	IDMAP_GSID,
1539b214d32SJordan Brown 	IDMAP_POSIXID
1549b214d32SJordan Brown };
1559b214d32SJordan Brown 
1569b214d32SJordan Brown /* The type of ID mapping */
1579b214d32SJordan Brown enum idmap_map_type {
1589b214d32SJordan Brown 	IDMAP_MAP_TYPE_UNKNOWN = 0,
1599b214d32SJordan Brown 	IDMAP_MAP_TYPE_DS_AD,
1609b214d32SJordan Brown 	IDMAP_MAP_TYPE_DS_NLDAP,
1619b214d32SJordan Brown 	IDMAP_MAP_TYPE_RULE_BASED,
1629b214d32SJordan Brown 	IDMAP_MAP_TYPE_EPHEMERAL,
1639b214d32SJordan Brown 	IDMAP_MAP_TYPE_LOCAL_SID,
164e3f2c991SKeyur Desai 	IDMAP_MAP_TYPE_KNOWN_SID,
165e3f2c991SKeyur Desai 	IDMAP_MAP_TYPE_IDMU
1669b214d32SJordan Brown };
1679b214d32SJordan Brown 
1689b214d32SJordan Brown 
1699b214d32SJordan Brown /* Source of ID mapping */
1709b214d32SJordan Brown enum idmap_map_src {
1719b214d32SJordan Brown 	IDMAP_MAP_SRC_UNKNOWN = 0,
1729b214d32SJordan Brown 	IDMAP_MAP_SRC_NEW,
1739b214d32SJordan Brown 	IDMAP_MAP_SRC_CACHE,
1749b214d32SJordan Brown 	IDMAP_MAP_SRC_HARD_CODED,
1759b214d32SJordan Brown 	IDMAP_MAP_SRC_ALGORITHMIC
1769b214d32SJordan Brown };
1779b214d32SJordan Brown 
1789b214d32SJordan Brown 
1799b214d32SJordan Brown /* SID */
1809b214d32SJordan Brown struct idmap_sid {
1819b214d32SJordan Brown 	string		prefix<>;
1829b214d32SJordan Brown 	uint32_t	rid;
1839b214d32SJordan Brown };
1849b214d32SJordan Brown 
1859b214d32SJordan Brown /* Identity (sid-posix) */
1869b214d32SJordan Brown union idmap_id switch(idmap_id_type idtype) {
1879b214d32SJordan Brown 	case IDMAP_UID: uint32_t uid;
1889b214d32SJordan Brown 	case IDMAP_GID: uint32_t gid;
1899b214d32SJordan Brown 	case IDMAP_SID: idmap_sid sid;
1909b214d32SJordan Brown 	case IDMAP_USID: idmap_sid usid;
1919b214d32SJordan Brown 	case IDMAP_GSID: idmap_sid gsid;
1929b214d32SJordan Brown 	case IDMAP_NONE: void;
1939b214d32SJordan Brown 	case IDMAP_POSIXID: void;
1949b214d32SJordan Brown };
1959b214d32SJordan Brown 
1969b214d32SJordan Brown 
1979b214d32SJordan Brown /* Name-based mapping rules */
1989b214d32SJordan Brown struct idmap_namerule {
1999b214d32SJordan Brown 	bool		is_user;
2009b214d32SJordan Brown 	bool		is_wuser;
2019b214d32SJordan Brown 	int		direction;
2029b214d32SJordan Brown 	idmap_utf8str	windomain;
2039b214d32SJordan Brown 	idmap_utf8str	winname;
2049b214d32SJordan Brown 	idmap_utf8str	unixname;
2059b214d32SJordan Brown 	bool		is_nt4;
2069b214d32SJordan Brown };
2079b214d32SJordan Brown struct idmap_namerules_res {
2089b214d32SJordan Brown 	idmap_retcode	retcode;
2099b214d32SJordan Brown 	uint64_t	lastrowid;
2109b214d32SJordan Brown 	idmap_namerule	rules<>;
2119b214d32SJordan Brown };
2129b214d32SJordan Brown 
2139b214d32SJordan Brown /* How ID is mapped */
2149b214d32SJordan Brown struct idmap_how_ds_based {
2159b214d32SJordan Brown 	idmap_utf8str	dn;
2169b214d32SJordan Brown 	idmap_utf8str	attr;
2179b214d32SJordan Brown 	idmap_utf8str	value;
2189b214d32SJordan Brown };
2199b214d32SJordan Brown 
2209b214d32SJordan Brown union idmap_how switch(idmap_map_type map_type) {
2219b214d32SJordan Brown 	case IDMAP_MAP_TYPE_UNKNOWN: void;
2229b214d32SJordan Brown 	case IDMAP_MAP_TYPE_DS_AD: idmap_how_ds_based ad;
2239b214d32SJordan Brown 	case IDMAP_MAP_TYPE_DS_NLDAP: idmap_how_ds_based nldap;
2249b214d32SJordan Brown 	case IDMAP_MAP_TYPE_RULE_BASED: idmap_namerule rule;
2259b214d32SJordan Brown 	case IDMAP_MAP_TYPE_EPHEMERAL: void;
2269b214d32SJordan Brown 	case IDMAP_MAP_TYPE_LOCAL_SID: void;
2279b214d32SJordan Brown 	case IDMAP_MAP_TYPE_KNOWN_SID: void;
228e3f2c991SKeyur Desai 	case IDMAP_MAP_TYPE_IDMU: idmap_how_ds_based idmu;
2299b214d32SJordan Brown };
2309b214d32SJordan Brown 
2319b214d32SJordan Brown struct idmap_info {
2329b214d32SJordan Brown 	idmap_map_src	src;
2339b214d32SJordan Brown 	idmap_how	how;
234*148c5f43SAlan Wright 	nvlist_t_ptr	trace;
2359b214d32SJordan Brown };
2369b214d32SJordan Brown 
2379b214d32SJordan Brown 
2389b214d32SJordan Brown /* Id result */
2399b214d32SJordan Brown struct idmap_id_res {
2409b214d32SJordan Brown 	idmap_retcode	retcode;
2419b214d32SJordan Brown 	idmap_id	id;
2429b214d32SJordan Brown 	int		direction;
2439b214d32SJordan Brown 	idmap_info	info;
2449b214d32SJordan Brown };
2459b214d32SJordan Brown struct idmap_ids_res {
2469b214d32SJordan Brown 	idmap_retcode	retcode;
2479b214d32SJordan Brown 	idmap_id_res	ids<>;
2489b214d32SJordan Brown };
2499b214d32SJordan Brown 
2509b214d32SJordan Brown 
2519b214d32SJordan Brown /*
2529b214d32SJordan Brown  * Flag supported by mapping requests
2539b214d32SJordan Brown  */
2549b214d32SJordan Brown 
2559b214d32SJordan Brown /* Don't allocate a new value for the mapping */
2569b214d32SJordan Brown const IDMAP_REQ_FLG_NO_NEW_ID_ALLOC	= 0x00000001;
2579b214d32SJordan Brown 
2589b214d32SJordan Brown /* Validate the given identity before mapping */
2599b214d32SJordan Brown const IDMAP_REQ_FLG_VALIDATE		= 0x00000002;
2609b214d32SJordan Brown 
2619b214d32SJordan Brown /* Avoid name service lookups to prevent looping */
2629b214d32SJordan Brown const IDMAP_REQ_FLG_NO_NAMESERVICE	= 0x00000004;
2639b214d32SJordan Brown 
2649b214d32SJordan Brown /* Request how a mapping was formed */
2659b214d32SJordan Brown const IDMAP_REQ_FLG_MAPPING_INFO	= 0x00000008;
2669b214d32SJordan Brown 
2679b214d32SJordan Brown /*
2689b214d32SJordan Brown  * This libidmap only flag is defined in idmap.h
2699b214d32SJordan Brown  * It enables use of the libidmap cache
2709b214d32SJordan Brown  * const IDMAP_REQ_FLG_USE_CACHE	= 0x00000010;
2719b214d32SJordan Brown  */
2729b214d32SJordan Brown 
2739b214d32SJordan Brown /* Request mapping for well-known or local SIDs only */
2749b214d32SJordan Brown const IDMAP_REQ_FLG_WK_OR_LOCAL_SIDS_ONLY	= 0x00000020;
2759b214d32SJordan Brown 
276*148c5f43SAlan Wright /* Request trace of mapping process */
277*148c5f43SAlan Wright const IDMAP_REQ_FLG_TRACE	= 0x00000040;
278*148c5f43SAlan Wright 
2799b214d32SJordan Brown 
2809b214d32SJordan Brown /*
2819b214d32SJordan Brown  * Mapping direction definitions
2829b214d32SJordan Brown  */
2839b214d32SJordan Brown const IDMAP_DIRECTION_UNDEF =	-1;	/* not defined */
2849b214d32SJordan Brown const IDMAP_DIRECTION_BI =	0;	/* bi-directional */
2859b214d32SJordan Brown const IDMAP_DIRECTION_W2U =	1;	/* windows to unix only */
2869b214d32SJordan Brown const IDMAP_DIRECTION_U2W =	2;	/* unix to windows only */
2879b214d32SJordan Brown 
2889b214d32SJordan Brown 
2899b214d32SJordan Brown /* Identity mappings (sid-posix) */
2909b214d32SJordan Brown struct idmap_mapping {
2919b214d32SJordan Brown 	int32_t		flag;
2929b214d32SJordan Brown 	int		direction;
2939b214d32SJordan Brown 	idmap_id	id1;
2949b214d32SJordan Brown 	idmap_utf8str	id1domain;
2959b214d32SJordan Brown 	idmap_utf8str	id1name;
2969b214d32SJordan Brown 	idmap_id	id2;
2979b214d32SJordan Brown 	idmap_utf8str	id2domain;
2989b214d32SJordan Brown 	idmap_utf8str	id2name;
2999b214d32SJordan Brown 	idmap_info	info;
3009b214d32SJordan Brown };
3019b214d32SJordan Brown 
3029b214d32SJordan Brown typedef idmap_mapping	idmap_mapping_batch<>;
3039b214d32SJordan Brown 
304*148c5f43SAlan Wright #ifndef IDMAP_XDR_MAPPING_ONLY
3059b214d32SJordan Brown struct idmap_mappings_res {
3069b214d32SJordan Brown 	idmap_retcode		retcode;
3079b214d32SJordan Brown 	uint64_t		lastrowid;
3089b214d32SJordan Brown 	idmap_mapping		mappings<>;
3099b214d32SJordan Brown };
3109b214d32SJordan Brown 
3119b214d32SJordan Brown 
3129b214d32SJordan Brown /* Update result */
3139b214d32SJordan Brown struct idmap_update_res {
3149b214d32SJordan Brown 	idmap_retcode	retcode;
3159b214d32SJordan Brown 	int64_t	error_index;
3169b214d32SJordan Brown 	idmap_namerule	error_rule;
3179b214d32SJordan Brown 	idmap_namerule	conflict_rule;
3189b214d32SJordan Brown };
3199b214d32SJordan Brown 
3209b214d32SJordan Brown /* Update requests */
3219b214d32SJordan Brown enum idmap_opnum {
3229b214d32SJordan Brown 	OP_NONE = 0,
3239b214d32SJordan Brown 	OP_ADD_NAMERULE = 1,
3249b214d32SJordan Brown 	OP_RM_NAMERULE = 2,
3259b214d32SJordan Brown 	OP_FLUSH_NAMERULES = 3
3269b214d32SJordan Brown };
3279b214d32SJordan Brown union idmap_update_op switch(idmap_opnum opnum) {
3289b214d32SJordan Brown 	case OP_ADD_NAMERULE:
3299b214d32SJordan Brown 	case OP_RM_NAMERULE:
3309b214d32SJordan Brown 		idmap_namerule rule;
3319b214d32SJordan Brown 	default:
3329b214d32SJordan Brown 		void;
3339b214d32SJordan Brown };
3349b214d32SJordan Brown typedef idmap_update_op idmap_update_batch<>;
3359b214d32SJordan Brown 
3369b214d32SJordan Brown const AD_DISC_MAXHOSTNAME = 256;
3379b214d32SJordan Brown 
3389b214d32SJordan Brown struct idmap_ad_disc_ds_t {
3399b214d32SJordan Brown 	int	port;
3409b214d32SJordan Brown 	int	priority;
3419b214d32SJordan Brown 	int	weight;
3429b214d32SJordan Brown 	char	host[AD_DISC_MAXHOSTNAME];
3439b214d32SJordan Brown };
3449b214d32SJordan Brown 
3459b214d32SJordan Brown 
3469b214d32SJordan Brown /* get-prop, set-prop */
3479b214d32SJordan Brown enum idmap_prop_type {
3489b214d32SJordan Brown 	PROP_UNKNOWN = 0,
3499b214d32SJordan Brown 	PROP_LIST_SIZE_LIMIT = 1,
3509b214d32SJordan Brown 	PROP_DEFAULT_DOMAIN = 2,	/* default domain name */
3519b214d32SJordan Brown 	PROP_DOMAIN_NAME = 3,		/* AD domain name */
3529b214d32SJordan Brown 	PROP_MACHINE_SID = 4,		/* machine sid */
3539b214d32SJordan Brown 	PROP_DOMAIN_CONTROLLER = 5,	/* domain controller hosts */
3549b214d32SJordan Brown 	PROP_FOREST_NAME = 6,		/* forest name */
3559b214d32SJordan Brown 	PROP_SITE_NAME = 7,		/* site name */
3569b214d32SJordan Brown 	PROP_GLOBAL_CATALOG = 8,	/* global catalog hosts */
3579b214d32SJordan Brown 	PROP_AD_UNIXUSER_ATTR = 9,
3589b214d32SJordan Brown 	PROP_AD_UNIXGROUP_ATTR = 10,
3599b214d32SJordan Brown 	PROP_NLDAP_WINNAME_ATTR = 11,
360e3f2c991SKeyur Desai 	PROP_DIRECTORY_BASED_MAPPING = 12
3619b214d32SJordan Brown };
3629b214d32SJordan Brown 
3639b214d32SJordan Brown union idmap_prop_val switch(idmap_prop_type prop) {
3649b214d32SJordan Brown 	case PROP_LIST_SIZE_LIMIT:
3659b214d32SJordan Brown 		uint64_t intval;
3669b214d32SJordan Brown 	case PROP_DEFAULT_DOMAIN:
3679b214d32SJordan Brown 	case PROP_DOMAIN_NAME:
3689b214d32SJordan Brown 	case PROP_MACHINE_SID:
3699b214d32SJordan Brown 	case PROP_FOREST_NAME:
3709b214d32SJordan Brown 	case PROP_SITE_NAME:
3719b214d32SJordan Brown 	case PROP_AD_UNIXUSER_ATTR:
3729b214d32SJordan Brown 	case PROP_AD_UNIXGROUP_ATTR:
3739b214d32SJordan Brown 	case PROP_NLDAP_WINNAME_ATTR:
374e3f2c991SKeyur Desai 	case PROP_DIRECTORY_BASED_MAPPING:
3759b214d32SJordan Brown 		idmap_utf8str utf8val;
3769b214d32SJordan Brown 	case PROP_DOMAIN_CONTROLLER:
3779b214d32SJordan Brown 	case PROP_GLOBAL_CATALOG:
3789b214d32SJordan Brown 		idmap_ad_disc_ds_t dsval;
3799b214d32SJordan Brown 	default:
3809b214d32SJordan Brown 		void;
3819b214d32SJordan Brown };
3829b214d32SJordan Brown 
3839b214d32SJordan Brown struct idmap_prop_res {
3849b214d32SJordan Brown 	idmap_retcode	retcode;
3859b214d32SJordan Brown 	idmap_prop_val	value;
3869b214d32SJordan Brown 	bool		auto_discovered;
3879b214d32SJordan Brown };
3889b214d32SJordan Brown 
3899fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States enum idmap_flush_op {
3909fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	IDMAP_FLUSH_EXPIRE = 0,
3919fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	IDMAP_FLUSH_DELETE = 1
3929fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States };
3939fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 
3941fcced4cSJordan Brown /*
3951fcced4cSJordan Brown  * Represents an error from the directory lookup service.
3961fcced4cSJordan Brown  *
3971fcced4cSJordan Brown  * code is an ASCII string that is a key for the error.  It is not
3981fcced4cSJordan Brown  * localized.
3991fcced4cSJordan Brown  *
4001fcced4cSJordan Brown  * fmt is a format string with %n markers for where to include
4011fcced4cSJordan Brown  * params[n-1].  It should be, but NEEDSWORK is not localized to
4021fcced4cSJordan Brown  * the caller's locale.
4031fcced4cSJordan Brown  *
4041fcced4cSJordan Brown  * params is a list of parameters for the error - e.g. the name that
4051fcced4cSJordan Brown  * encountered a failure, the server that reported the failure, et cetera.
4061fcced4cSJordan Brown  * The values are to be used both as marked in fmt and for machine
4071fcced4cSJordan Brown  * interpretation of the error.
4081fcced4cSJordan Brown  */
4091fcced4cSJordan Brown struct directory_error_rpc {
4101fcced4cSJordan Brown 	idmap_utf8str	code;
4111fcced4cSJordan Brown 	idmap_utf8str	fmt;
4121fcced4cSJordan Brown 	idmap_utf8str	params<>;
4131fcced4cSJordan Brown };
4141fcced4cSJordan Brown 
4151fcced4cSJordan Brown /*
4161fcced4cSJordan Brown  * One value of a multivalued attribute.
4171fcced4cSJordan Brown  */
4181fcced4cSJordan Brown typedef opaque			directory_value_rpc<>;
4191fcced4cSJordan Brown 
4201fcced4cSJordan Brown /*
4211fcced4cSJordan Brown  * The value of an attribute, if found.  Note that this is a list
4221fcced4cSJordan Brown  * of directory_value_rpc objects, to support multivalued attributes.
4231fcced4cSJordan Brown  */
4241fcced4cSJordan Brown union directory_values_rpc switch (bool found) {
4251fcced4cSJordan Brown 	case TRUE:
4261fcced4cSJordan Brown 		directory_value_rpc values<>;
4271fcced4cSJordan Brown 	case FALSE:
4281fcced4cSJordan Brown 		void;
4291fcced4cSJordan Brown };
4301fcced4cSJordan Brown 
4311fcced4cSJordan Brown /*
4321fcced4cSJordan Brown  * The status of the lookup for any particular identifier.
4331fcced4cSJordan Brown  */
4341fcced4cSJordan Brown enum directory_lookup_status_rpc {
4351fcced4cSJordan Brown 	DIRECTORY_NOT_FOUND = 0,
4361fcced4cSJordan Brown 	DIRECTORY_FOUND = 1,
4371fcced4cSJordan Brown 	DIRECTORY_ERROR = 2
4381fcced4cSJordan Brown };
4391fcced4cSJordan Brown 
4401fcced4cSJordan Brown /*
4411fcced4cSJordan Brown  * This is the data returned for a particular identifier, either a
4421fcced4cSJordan Brown  * list of attribute values or an error.
4431fcced4cSJordan Brown  */
4441fcced4cSJordan Brown union directory_entry_rpc switch (directory_lookup_status_rpc status) {
4451fcced4cSJordan Brown 	case DIRECTORY_NOT_FOUND:
4461fcced4cSJordan Brown 		void;
4471fcced4cSJordan Brown 	case DIRECTORY_FOUND:
4481fcced4cSJordan Brown 		directory_values_rpc attrs<>;
4491fcced4cSJordan Brown 	case DIRECTORY_ERROR:
4501fcced4cSJordan Brown 		directory_error_rpc err;
4511fcced4cSJordan Brown };
4521fcced4cSJordan Brown 
4531fcced4cSJordan Brown /*
4541fcced4cSJordan Brown  * This is the result from a request, either a list of the entries for
4551fcced4cSJordan Brown  * the identifiers specified, or an error.
4561fcced4cSJordan Brown  */
4571fcced4cSJordan Brown union directory_results_rpc switch (bool failed) {
4581fcced4cSJordan Brown 	case TRUE:
4591fcced4cSJordan Brown 		directory_error_rpc	err;
4601fcced4cSJordan Brown 	case FALSE:
4611fcced4cSJordan Brown 		directory_entry_rpc	entries<>;
4621fcced4cSJordan Brown };
463*148c5f43SAlan Wright #endif	/* IDMAP_XDR_MAPPING_ONLY */
4641fcced4cSJordan Brown 
4659b214d32SJordan Brown program IDMAP_PROG {
4669b214d32SJordan Brown 	version IDMAP_V1 {
467*148c5f43SAlan Wright #ifndef	IDMAP_XDR_MAPPING_ONLY
4689b214d32SJordan Brown 		void
4699b214d32SJordan Brown 		IDMAP_NULL(void) = 0;
470*148c5f43SAlan Wright #endif	/* IDMAP_XDR_MAPPING_ONLY */
4719b214d32SJordan Brown 
4729b214d32SJordan Brown 		/* Batch of requests to get mapped identities */
4739b214d32SJordan Brown 		idmap_ids_res
4749b214d32SJordan Brown 		IDMAP_GET_MAPPED_IDS(idmap_mapping_batch batch) = 1;
4759b214d32SJordan Brown 
476*148c5f43SAlan Wright #ifndef	IDMAP_XDR_MAPPING_ONLY
4779b214d32SJordan Brown 		/* List all identity mappings */
4789b214d32SJordan Brown 		idmap_mappings_res
4799b214d32SJordan Brown 		IDMAP_LIST_MAPPINGS(int64_t lastrowid,
4809b214d32SJordan Brown 			uint64_t limit, int32_t flag) = 2;
4819b214d32SJordan Brown 
4829b214d32SJordan Brown 		/* List all name-based mapping rules */
4839b214d32SJordan Brown 		idmap_namerules_res
4849b214d32SJordan Brown 		IDMAP_LIST_NAMERULES(idmap_namerule rule,
4859b214d32SJordan Brown 			uint64_t lastrowid, uint64_t limit) = 3;
4869b214d32SJordan Brown 
4879b214d32SJordan Brown 		/* Batch of update requests */
4889b214d32SJordan Brown 		idmap_update_res
4899b214d32SJordan Brown 		IDMAP_UPDATE(idmap_update_batch batch) = 4;
4909b214d32SJordan Brown 
4919b214d32SJordan Brown 		/* Get mapped identity by name */
4929b214d32SJordan Brown 		idmap_mappings_res
4939b214d32SJordan Brown 		IDMAP_GET_MAPPED_ID_BY_NAME(idmap_mapping request) = 5;
4949b214d32SJordan Brown 
4959b214d32SJordan Brown 		/* Get configuration property */
4969b214d32SJordan Brown 		idmap_prop_res
4979b214d32SJordan Brown 		IDMAP_GET_PROP(idmap_prop_type) = 6;
498*148c5f43SAlan Wright 
4991fcced4cSJordan Brown 		/*
5001fcced4cSJordan Brown 		 * Retrieve directory information about a list of users
5011fcced4cSJordan Brown 		 * or groups by name or SID.
5021fcced4cSJordan Brown 		 *
5031fcced4cSJordan Brown 		 * ids is a list of user names, group names, or SIDs.
5041fcced4cSJordan Brown 		 *
5051fcced4cSJordan Brown 		 * types is a list of types of the ids in the id list.
5061fcced4cSJordan Brown 		 * If the type list is shorter than the id list, the last
5071fcced4cSJordan Brown 		 * type listed applies to all of the ids from that point.
5081fcced4cSJordan Brown 		 * The defined types are:
5091fcced4cSJordan Brown 		 *     'n' - name (could be user or group)
5101fcced4cSJordan Brown 		 *     'u' - user
5111fcced4cSJordan Brown 		 *     'g' - group
5121fcced4cSJordan Brown 		 *     's' - SID
5131fcced4cSJordan Brown 		 *
5141fcced4cSJordan Brown 		 * attrs is a list of attribute names to retrieve.
5151fcced4cSJordan Brown 		 */
5161fcced4cSJordan Brown 		directory_results_rpc DIRECTORY_GET_COMMON(
5171fcced4cSJordan Brown 			idmap_utf8str_list ids,
5181fcced4cSJordan Brown 			idmap_utf8str types,
5191fcced4cSJordan Brown 			idmap_utf8str_list attrs) = 7;
5209b214d32SJordan Brown 
5219fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 		idmap_retcode
5229fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 		IDMAP_FLUSH(idmap_flush_op) = 8;
523*148c5f43SAlan Wright #endif	/* IDMAP_XDR_MAPPING_ONLY */
5249b214d32SJordan Brown 	} = 1;
5259b214d32SJordan Brown } = 100172;
526