1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown * CDDL HEADER START
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown * The contents of this file are subject to the terms of the
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown * Common Development and Distribution License (the "License").
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown * You may not use this file except in compliance with the License.
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown * See the License for the specific language governing permissions
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown * and limitations under the License.
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown * When distributing Covered Code, include this CDDL HEADER in each
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown * If applicable, add the following below this CDDL HEADER, with the
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown * fields enclosed by brackets "[]" replaced with your own identifying
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown * information: Portions Copyright [yyyy] [name of copyright owner]
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown * CDDL HEADER END
c586600796766c83eb9485c446886fd9ed2359a9Keyur Desai * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown * Some helper routines for directory lookup. These offer functions that
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown * you could implement yourself on top of the generic routines, but since
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown * they're a common request we implement them here. (Well, OK, we cheat a bit
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown * and call an internal routine to do the dirty work to reduce code
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown * duplication, but you could still implement them using the generic routines.)
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown * Given a username, return a text-form SID.
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown * The SID must be free()ed by the caller.
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown * d, if non-NULL, specifies an existing directory-search context.
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown * If NULL, a temporary one will be created.
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown "objectSid",
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown "objectClass",
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown /* Prep for error cases. */
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown de = directory_get_v(d1, &ret_list, &name, 1, type, attrs);
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown de = directory_error("ENOMEM.directory_sid_from_name_common",
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown "Insufficient memory retrieving data about SID", NULL);
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown return (directory_sid_from_name_common(d, name, DIRECTORY_ID_NAME, sid,
1fcced4c370617db71610fecffd5451a5894ca5eJordan Browndirectory_sid_from_user_name(directory_t d, char *name, char **sid)
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown return (directory_sid_from_name_common(d, name, DIRECTORY_ID_USER, sid,
1fcced4c370617db71610fecffd5451a5894ca5eJordan Browndirectory_sid_from_group_name(directory_t d, char *name, char **sid)
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown return (directory_sid_from_name_common(d, name, DIRECTORY_ID_GROUP, sid,
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown * Given a name or text-format SID, return a user@domain.
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown * The user@domain returned must be free()ed by the caller.
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown * Returns NULL and sets *name to NULL if no error occurred but the specified
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown * entity does not exist.
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown * d, if non-NULL, specifies an existing directory-search context.
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown * If NULL, a temporary one will be created.
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown * Attributes required to generate a canonical name, in named-list and
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown * structure form.
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown "x-sun-canonicalName",
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown "objectClass",
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown /* Prep for error cases. */
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown de = directory_get_v(d1, &ret_list, &id, 1, id_type, attrs);
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown ret_name = (struct canon_name_ret *)ret_list[0].attrs;
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown *canon = strdup(ret_name->x_sun_canonicalName[0]);
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown *classes = class_bitmap(ret_name->objectClass);
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown de = directory_error("ENOMEM.directory_canon_common",
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown "Insufficient memory retrieving data about name", NULL);
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown return (directory_canon_common(d, sid, DIRECTORY_ID_SID, canon,
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown return (directory_canon_common(d, name, DIRECTORY_ID_NAME, canon,
1fcced4c370617db71610fecffd5451a5894ca5eJordan Browndirectory_canon_from_user_name(directory_t d, char *name, char **canon)
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown directory_canon_common(d, name, DIRECTORY_ID_USER, canon, NULL));
1fcced4c370617db71610fecffd5451a5894ca5eJordan Browndirectory_canon_from_group_name(directory_t d, char *name, char **canon)