xref: /illumos-gate/usr/src/lib/libidmap/common/directory_private.h (revision 1fcced4c370617db71610fecffd5451a5894ca5e)
1*1fcced4cSJordan Brown /*
2*1fcced4cSJordan Brown  * CDDL HEADER START
3*1fcced4cSJordan Brown  *
4*1fcced4cSJordan Brown  * The contents of this file are subject to the terms of the
5*1fcced4cSJordan Brown  * Common Development and Distribution License (the "License").
6*1fcced4cSJordan Brown  * You may not use this file except in compliance with the License.
7*1fcced4cSJordan Brown  *
8*1fcced4cSJordan Brown  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*1fcced4cSJordan Brown  * or http://www.opensolaris.org/os/licensing.
10*1fcced4cSJordan Brown  * See the License for the specific language governing permissions
11*1fcced4cSJordan Brown  * and limitations under the License.
12*1fcced4cSJordan Brown  *
13*1fcced4cSJordan Brown  * When distributing Covered Code, include this CDDL HEADER in each
14*1fcced4cSJordan Brown  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*1fcced4cSJordan Brown  * If applicable, add the following below this CDDL HEADER, with the
16*1fcced4cSJordan Brown  * fields enclosed by brackets "[]" replaced with your own identifying
17*1fcced4cSJordan Brown  * information: Portions Copyright [yyyy] [name of copyright owner]
18*1fcced4cSJordan Brown  *
19*1fcced4cSJordan Brown  * CDDL HEADER END
20*1fcced4cSJordan Brown  */
21*1fcced4cSJordan Brown 
22*1fcced4cSJordan Brown /*
23*1fcced4cSJordan Brown  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24*1fcced4cSJordan Brown  * Use is subject to license terms.
25*1fcced4cSJordan Brown  */
26*1fcced4cSJordan Brown 
27*1fcced4cSJordan Brown #ifndef _DIRECTORY_PRIVATE_H
28*1fcced4cSJordan Brown #define	_DIRECTORY_PRIVATE_H
29*1fcced4cSJordan Brown 
30*1fcced4cSJordan Brown /*
31*1fcced4cSJordan Brown  * A suite of functions for retrieving information about objects
32*1fcced4cSJordan Brown  * in a directory service.
33*1fcced4cSJordan Brown  */
34*1fcced4cSJordan Brown 
35*1fcced4cSJordan Brown #ifdef __cplusplus
36*1fcced4cSJordan Brown extern "C" {
37*1fcced4cSJordan Brown #endif
38*1fcced4cSJordan Brown 
39*1fcced4cSJordan Brown #include <sys/types.h>
40*1fcced4cSJordan Brown 
41*1fcced4cSJordan Brown #define	DIRECTORY_ID_NAME	"n"
42*1fcced4cSJordan Brown #define	DIRECTORY_ID_USER	"u"
43*1fcced4cSJordan Brown #define	DIRECTORY_ID_GROUP	"g"
44*1fcced4cSJordan Brown #define	DIRECTORY_ID_SID	"s"
45*1fcced4cSJordan Brown 
46*1fcced4cSJordan Brown /*
47*1fcced4cSJordan Brown  * Structure of the returned data.
48*1fcced4cSJordan Brown  * Note that this is constructed from the bottom up; what is returned is
49*1fcced4cSJordan Brown  * a directory_entry_list_t.
50*1fcced4cSJordan Brown  */
51*1fcced4cSJordan Brown typedef void *directory_datum_t;
52*1fcced4cSJordan Brown typedef directory_datum_t *directory_attribute_value_t;
53*1fcced4cSJordan Brown typedef struct {
54*1fcced4cSJordan Brown 	directory_attribute_value_t *attrs;
55*1fcced4cSJordan Brown 	directory_error_t err;
56*1fcced4cSJordan Brown } directory_entry_t;
57*1fcced4cSJordan Brown typedef directory_entry_t *directory_entry_list_t;
58*1fcced4cSJordan Brown 
59*1fcced4cSJordan Brown /*
60*1fcced4cSJordan Brown  * Retrieve information about a user or group.  By way of analogy to exec(2),
61*1fcced4cSJordan Brown  * the _v variants accept a list of attributes as an array, while
62*1fcced4cSJordan Brown  * the _l variants accept the attribute list as arguments.
63*1fcced4cSJordan Brown  * All variations accept a list of identifiers, and return a
64*1fcced4cSJordan Brown  * directory_entry_list_t in the same order.  The length of the list of user
65*1fcced4cSJordan Brown  * identifiers can be specified either explicitly, or by a terminating
66*1fcced4cSJordan Brown  * NULL if the associated count is zero.  Attributes are returned in the
67*1fcced4cSJordan Brown  * order they were requested, with missing attributes yielding NULL
68*1fcced4cSJordan Brown  * entries.
69*1fcced4cSJordan Brown  */
70*1fcced4cSJordan Brown directory_error_t directory_get_v(directory_t d, directory_entry_list_t *ret,
71*1fcced4cSJordan Brown     char **ids, int nids, char *types, char **attrlist);
72*1fcced4cSJordan Brown 
73*1fcced4cSJordan Brown directory_error_t directory_get_l(directory_t d, directory_entry_list_t *ret,
74*1fcced4cSJordan Brown     char **ids, int nids, char *types, char *attr1, ...);
75*1fcced4cSJordan Brown 
76*1fcced4cSJordan Brown /*
77*1fcced4cSJordan Brown  * Free the data structure returned by directory_get_by*().
78*1fcced4cSJordan Brown  *
79*1fcced4cSJordan Brown  * Does nothing if list==NULL.
80*1fcced4cSJordan Brown  */
81*1fcced4cSJordan Brown void directory_free(directory_entry_list_t list);
82*1fcced4cSJordan Brown 
83*1fcced4cSJordan Brown /* Return the number of bytes in a directory_datum_t */
84*1fcced4cSJordan Brown size_t directory_datum_len(directory_datum_t d);
85*1fcced4cSJordan Brown 
86*1fcced4cSJordan Brown /*
87*1fcced4cSJordan Brown  * Search a list, case-insensitively, for a string
88*1fcced4cSJordan Brown  */
89*1fcced4cSJordan Brown boolean_t is_in_list(char **list, char *value);
90*1fcced4cSJordan Brown 
91*1fcced4cSJordan Brown /*
92*1fcced4cSJordan Brown  * Examine an objectClass list and distill it into a bitmap of "interesting"
93*1fcced4cSJordan Brown  * classes.
94*1fcced4cSJordan Brown  */
95*1fcced4cSJordan Brown uint64_t class_bitmap(char **objectClass);
96*1fcced4cSJordan Brown 
97*1fcced4cSJordan Brown #ifdef __cplusplus
98*1fcced4cSJordan Brown }
99*1fcced4cSJordan Brown #endif
100*1fcced4cSJordan Brown 
101*1fcced4cSJordan Brown #endif /* _DIRECTORY_PRIVATE_H */
102