if we are adding a new sambaAccount, make sure that we add a
[Samba.git] / source / nsswitch / winbindd.h
blob4d35c27c21339ba6d74a5887053247443101b9ad
1 /*
2 Unix SMB/CIFS implementation.
4 Winbind daemon for ntdom nss module
6 Copyright (C) Tim Potter 2000
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either
11 version 2 of the License, or (at your option) any later version.
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.
18 You should have received a copy of the GNU Library General Public
19 License along with this library; if not, write to the
20 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA.
24 #ifndef _WINBINDD_H
25 #define _WINBINDD_H
27 #include "includes.h"
28 #include "nterr.h"
30 #include "winbindd_nss.h"
32 /* Client state structure */
34 struct winbindd_cli_state {
35 struct winbindd_cli_state *prev, *next; /* Linked list pointers */
36 int sock; /* Open socket from client */
37 pid_t pid; /* pid of client */
38 int read_buf_len, write_buf_len; /* Indexes in request/response */
39 BOOL finished; /* Can delete from list */
40 BOOL write_extra_data; /* Write extra_data field */
41 struct winbindd_request request; /* Request from client */
42 struct winbindd_response response; /* Respose to client */
43 struct getent_state *getpwent_state; /* State for getpwent() */
44 struct getent_state *getgrent_state; /* State for getgrent() */
47 /* State between get{pw,gr}ent() calls */
49 struct getent_state {
50 struct getent_state *prev, *next;
51 void *sam_entries;
52 uint32 sam_entry_index, num_sam_entries;
53 BOOL got_sam_entries;
54 fstring domain_name;
57 /* Storage for cached getpwent() user entries */
59 struct getpwent_user {
60 fstring name; /* Account name */
61 fstring gecos; /* User information */
62 uint32 user_rid, group_rid; /* NT user and group rids */
65 /* Server state structure */
67 struct winbindd_state {
69 /* User and group id pool */
71 uid_t uid_low, uid_high; /* Range of uids to allocate */
72 gid_t gid_low, gid_high; /* Range of gids to allocate */
75 extern struct winbindd_state server_state; /* Server information */
77 typedef struct {
78 char *acct_name;
79 char *full_name;
80 uint32 user_rid;
81 uint32 group_rid; /* primary group */
82 } WINBIND_USERINFO;
84 /* Structures to hold per domain information */
86 struct winbindd_domain {
87 fstring name; /* Domain name */
88 fstring full_name; /* full Domain name (realm) */
89 DOM_SID sid; /* SID for this domain */
91 /* Lookup methods for this domain (LDAP or RPC) */
93 struct winbindd_methods *methods;
95 /* Private data for the backends (used for connection cache) */
97 void *private;
99 /* Sequence number stuff */
101 time_t last_seq_check;
102 uint32 sequence_number;
104 /* Linked list info */
106 struct winbindd_domain *prev, *next;
109 /* per-domain methods. This is how LDAP vs RPC is selected
111 struct winbindd_methods {
112 /* does this backend provide a consistent view of the data? (ie. is the primary group
113 always correct) */
114 BOOL consistent;
116 /* get a list of users, returning a WINBIND_USERINFO for each one */
117 NTSTATUS (*query_user_list)(struct winbindd_domain *domain,
118 TALLOC_CTX *mem_ctx,
119 uint32 *num_entries,
120 WINBIND_USERINFO **info);
122 /* get a list of groups */
123 NTSTATUS (*enum_dom_groups)(struct winbindd_domain *domain,
124 TALLOC_CTX *mem_ctx,
125 uint32 *num_entries,
126 struct acct_info **info);
128 /* convert one user or group name to a sid */
129 NTSTATUS (*name_to_sid)(struct winbindd_domain *domain,
130 const char *name,
131 DOM_SID *sid,
132 enum SID_NAME_USE *type);
134 /* convert a sid to a user or group name */
135 NTSTATUS (*sid_to_name)(struct winbindd_domain *domain,
136 TALLOC_CTX *mem_ctx,
137 DOM_SID *sid,
138 char **name,
139 enum SID_NAME_USE *type);
141 /* lookup user info for a given rid */
142 NTSTATUS (*query_user)(struct winbindd_domain *domain,
143 TALLOC_CTX *mem_ctx,
144 uint32 user_rid,
145 WINBIND_USERINFO *user_info);
147 /* lookup all groups that a user is a member of. The backend
148 can also choose to lookup by username or rid for this
149 function */
150 NTSTATUS (*lookup_usergroups)(struct winbindd_domain *domain,
151 TALLOC_CTX *mem_ctx,
152 uint32 user_rid,
153 uint32 *num_groups, uint32 **user_gids);
155 /* find all members of the group with the specified group_rid */
156 NTSTATUS (*lookup_groupmem)(struct winbindd_domain *domain,
157 TALLOC_CTX *mem_ctx,
158 uint32 group_rid, uint32 *num_names,
159 uint32 **rid_mem, char ***names,
160 uint32 **name_types);
162 /* return the current global sequence number */
163 NTSTATUS (*sequence_number)(struct winbindd_domain *domain, uint32 *seq);
165 /* enumerate trusted domains */
166 NTSTATUS (*trusted_domains)(struct winbindd_domain *domain,
167 TALLOC_CTX *mem_ctx,
168 uint32 *num_domains,
169 char ***names,
170 DOM_SID **dom_sids);
172 /* find the domain sid */
173 NTSTATUS (*domain_sid)(struct winbindd_domain *domain,
174 DOM_SID *sid);
177 /* Used to glue a policy handle and cli_state together */
179 typedef struct {
180 struct cli_state *cli;
181 POLICY_HND pol;
182 } CLI_POLICY_HND;
184 #include "winbindd_proto.h"
186 #include "rpc_parse.h"
187 #include "rpc_client.h"
189 #define WINBINDD_ESTABLISH_LOOP 30
190 #define DOM_SEQUENCE_NONE ((uint32)-1)
192 /* SETENV */
193 #if HAVE_SETENV
194 #define SETENV(name, value, overwrite) setenv(name,value,overwrite)
195 #elif HAVE_PUTENV
196 #define SETENV(name, value, overwrite) \
198 fstring envvar; \
199 slprintf(envvar, sizeof(fstring), "%s=%s", name, value); \
200 putenv(envvar); \
202 #else
203 #define SETENV(name, value, overwrite) ;
204 #endif
206 #endif /* _WINBINDD_H */