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