Add files for new LGPL libwbclient DSO implementing the Winbind client API
[ira/wip.git] / source3 / nsswitch / libwbclient / wbclient.h
1 /*
2    Unix SMB/CIFS implementation.
3
4    Winbind client API
5
6    Copyright (C) Gerald (Jerry) Carter 2007
7
8    This library is free software; you can redistribute it and/or
9    modify it under the terms of the GNU Lesser General Public
10    License as published by the Free Software Foundation; either
11    version 3 of the License, or (at your option) any later version.
12
13    This library is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16    Library General Public License for more details.
17
18    You should have received a copy of the GNU Lesser General Public License
19    along with this program.  If not, see <http://www.gnu.org/licenses/>.
20 */
21
22 #ifndef _WBCLIENT_H
23 #define _WBCLIENT_H
24
25 #include <pwd.h>
26 #include <nsswitch/libwbclient/wbc_err.h>
27
28 /*
29  * Data types used by the Winbind Client API
30  */
31
32 #ifndef MAXSUBAUTHS
33 #define MAXSUBAUTHS 15 /* max sub authorities in a SID */
34 #endif
35
36 /**
37  *  @brief Windows Security Identifier
38  *
39  **/
40
41 struct wbcDomainSid {
42         uint8_t   sid_rev_num;
43         uint8_t   num_auths;
44         uint8_t   id_auth[6];
45         uint32_t  sub_auths[MAXSUBAUTHS];
46 };
47
48 /**
49  * @brief Security Identifier type
50  **/
51
52 enum wbcSidType {
53         WBC_SID_NAME_USE_NONE=0,
54         WBC_SID_NAME_USER=1,
55         WBC_SID_NAME_DOM_GRP=2,
56         WBC_SID_NAME_DOMAIN=3,
57         WBC_SID_NAME_ALIAS=4,
58         WBC_SID_NAME_WKN_GRP=5,
59         WBC_SID_NAME_DELETED=6,
60         WBC_SID_NAME_INVALID=7,
61         WBC_SID_NAME_UNKNOWN=8,
62         WBC_SID_NAME_COMPUTER=9
63 };
64
65 /**
66  * @brief Domain Information
67  **/
68
69 struct wbcDomainInfo {
70         char *short_name;
71         char *dns_name;
72         struct wbcDomainSid sid;
73         uint32_t flags;
74 };
75
76 /* wbcDomainInfo->flags */
77
78 #define WBC_DOMINFO_NATIVE            0x00000001
79 #define WBC_DOMINFO_AD                0x00000002
80 #define WBC_DOMINFO_PRIMARY           0x00000004
81
82 /*
83  * Memory Management
84  */
85
86 void wbcFreeMemory(void*);
87
88
89 /*
90  * Utility functions for dealing with SIDs
91  */
92
93 wbcErr wbcSidToString(const struct wbcDomainSid *sid,
94                       char **sid_string);
95
96 wbcErr wbcStringToSid(const char *sid_string,
97                       struct wbcDomainSid *sid);
98
99 wbcErr wbcPing(void);
100
101 /*
102  * Name/SID conversion
103  */
104
105 wbcErr wbcLookupName(const char *dom_name,
106                      const char *name,
107                      struct wbcDomainSid *sid,
108                      enum wbcSidType *name_type);
109
110 wbcErr wbcLookupSid(const struct wbcDomainSid *sid,
111                     char **domain,
112                     char **name,
113                     enum wbcSidType *name_type);
114
115 wbcErr wbcLookupRids(struct wbcDomainSid *dom_sid,
116                      int num_rids,
117                      uint32_t *rids,
118                      const char **domain_name,
119                      const char ***names,
120                      enum wbcSidType **types);
121
122 /*
123  * SID/uid/gid Mappings
124  */
125
126 wbcErr wbcSidToUid(const struct wbcDomainSid *sid,
127                    uid_t *puid);
128
129 wbcErr wbcUidToSid(uid_t uid,
130                    struct wbcDomainSid *sid);
131
132 wbcErr wbcSidToGid(const struct wbcDomainSid *sid,
133                    gid_t *pgid);
134
135 wbcErr wbcGidToSid(gid_t gid,
136                    struct wbcDomainSid *sid);
137
138 wbcErr wbcAllocateUid(uid_t *puid);
139
140 wbcErr wbcAllocateGid(uid_t *pgid);
141
142 /*
143  * NSS Lookup User/Group details
144  */
145
146 wbcErr wbcGetpwnam(const char *name, struct passwd **pwd);
147
148 wbcErr wbcGetpwuid(uid_t uid, struct passwd **pwd);
149
150 wbcErr wbcGetgrnam(const char *name, struct group **grp);
151
152 wbcErr wbcGetgrgid(gid_t gid, struct group **grp);
153
154 wbcErr wbcSetpwent(void);
155
156 wbcErr wbcEndpwent(void);
157
158 wbcErr wbcGetpwent(struct passwd **pwd);
159
160 wbcErr wbcSetgrent(void);
161
162 wbcErr wbcEndgrent(void);
163
164 wbcErr wbcGetgrent(struct group **grp);
165
166
167 /*
168  * Lookup Domain information
169  */
170
171 wbcErr wbcDomainInfo(const char *domain,
172                      struct wbcDomainInfo **info);
173
174 wbcErr wbcDomainSequenceNumbers(void);
175
176 /*
177  * Athenticate functions
178  */
179
180 wbcErr wbcAuthenticateUser(const char *username, 
181                            const char *password);
182
183
184 #endif      /* _WBCLIENT_H */