2 Unix SMB/CIFS implementation.
4 Wrapper around winbindd_rpc.c to centralize retry logic.
6 Copyright (C) Volker Lendecke 2005
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program 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
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
26 #define DBGC_CLASS DBGC_WINBIND
28 extern struct winbindd_methods msrpc_methods;
31 static NTSTATUS query_user_list(struct winbindd_domain *domain,
34 struct wbint_userinfo **info)
38 result = msrpc_methods.query_user_list(domain, mem_ctx,
41 if (NT_STATUS_EQUAL(result, NT_STATUS_UNSUCCESSFUL))
42 result = msrpc_methods.query_user_list(domain, mem_ctx,
47 /* list all domain groups */
48 static NTSTATUS enum_dom_groups(struct winbindd_domain *domain,
51 struct acct_info **info)
55 result = msrpc_methods.enum_dom_groups(domain, mem_ctx,
58 if (NT_STATUS_EQUAL(result, NT_STATUS_UNSUCCESSFUL))
59 result = msrpc_methods.enum_dom_groups(domain, mem_ctx,
64 /* List all domain groups */
66 static NTSTATUS enum_local_groups(struct winbindd_domain *domain,
69 struct acct_info **info)
73 result = msrpc_methods.enum_local_groups(domain, mem_ctx,
76 if (NT_STATUS_EQUAL(result, NT_STATUS_UNSUCCESSFUL))
77 result = msrpc_methods.enum_local_groups(domain, mem_ctx,
83 /* convert a single name to a sid in a domain */
84 static NTSTATUS name_to_sid(struct winbindd_domain *domain,
86 const char *domain_name,
90 enum lsa_SidType *type)
94 result = msrpc_methods.name_to_sid(domain, mem_ctx, domain_name, name,
97 if (NT_STATUS_EQUAL(result, NT_STATUS_UNSUCCESSFUL))
98 result = msrpc_methods.name_to_sid(domain, mem_ctx,
99 domain_name, name, flags,
106 convert a domain SID to a user or group name
108 static NTSTATUS sid_to_name(struct winbindd_domain *domain,
113 enum lsa_SidType *type)
117 result = msrpc_methods.sid_to_name(domain, mem_ctx, sid,
118 domain_name, name, type);
120 if (NT_STATUS_EQUAL(result, NT_STATUS_UNSUCCESSFUL))
121 result = msrpc_methods.sid_to_name(domain, mem_ctx, sid,
122 domain_name, name, type);
127 static NTSTATUS rids_to_names(struct winbindd_domain *domain,
134 enum lsa_SidType **types)
138 result = msrpc_methods.rids_to_names(domain, mem_ctx, sid,
140 domain_name, names, types);
141 if (NT_STATUS_EQUAL(result, NT_STATUS_UNSUCCESSFUL)) {
142 result = msrpc_methods.rids_to_names(domain, mem_ctx, sid,
151 /* Lookup user information from a rid or username. */
152 static NTSTATUS query_user(struct winbindd_domain *domain,
154 const DOM_SID *user_sid,
155 struct wbint_userinfo *user_info)
159 result = msrpc_methods.query_user(domain, mem_ctx, user_sid,
162 if (NT_STATUS_EQUAL(result, NT_STATUS_UNSUCCESSFUL))
163 result = msrpc_methods.query_user(domain, mem_ctx, user_sid,
169 /* Lookup groups a user is a member of. I wish Unix had a call like this! */
170 static NTSTATUS lookup_usergroups(struct winbindd_domain *domain,
172 const DOM_SID *user_sid,
173 uint32 *num_groups, DOM_SID **user_gids)
177 result = msrpc_methods.lookup_usergroups(domain, mem_ctx,
178 user_sid, num_groups,
181 if (NT_STATUS_EQUAL(result, NT_STATUS_UNSUCCESSFUL))
182 result = msrpc_methods.lookup_usergroups(domain, mem_ctx,
183 user_sid, num_groups,
189 static NTSTATUS lookup_useraliases(struct winbindd_domain *domain,
191 uint32 num_sids, const DOM_SID *sids,
192 uint32 *num_aliases, uint32 **alias_rids)
196 result = msrpc_methods.lookup_useraliases(domain, mem_ctx,
201 if (NT_STATUS_EQUAL(result, NT_STATUS_UNSUCCESSFUL))
202 result = msrpc_methods.lookup_useraliases(domain, mem_ctx,
210 /* Lookup group membership given a rid. */
211 static NTSTATUS lookup_groupmem(struct winbindd_domain *domain,
213 const DOM_SID *group_sid,
214 enum lsa_SidType type,
216 DOM_SID **sid_mem, char ***names,
221 result = msrpc_methods.lookup_groupmem(domain, mem_ctx,
222 group_sid, type, num_names,
226 if (NT_STATUS_EQUAL(result, NT_STATUS_UNSUCCESSFUL))
227 result = msrpc_methods.lookup_groupmem(domain, mem_ctx,
236 /* find the sequence number for a domain */
237 static NTSTATUS sequence_number(struct winbindd_domain *domain, uint32 *seq)
241 result = msrpc_methods.sequence_number(domain, seq);
243 if (NT_STATUS_EQUAL(result, NT_STATUS_UNSUCCESSFUL))
244 result = msrpc_methods.sequence_number(domain, seq);
249 /* find the lockout policy of a domain */
250 static NTSTATUS lockout_policy(struct winbindd_domain *domain,
252 struct samr_DomInfo12 *policy)
256 result = msrpc_methods.lockout_policy(domain, mem_ctx, policy);
258 if (NT_STATUS_EQUAL(result, NT_STATUS_UNSUCCESSFUL))
259 result = msrpc_methods.lockout_policy(domain, mem_ctx, policy);
264 /* find the password policy of a domain */
265 static NTSTATUS password_policy(struct winbindd_domain *domain,
267 struct samr_DomInfo1 *policy)
271 result = msrpc_methods.password_policy(domain, mem_ctx, policy);
273 if (NT_STATUS_EQUAL(result, NT_STATUS_UNSUCCESSFUL))
274 result = msrpc_methods.password_policy(domain, mem_ctx, policy);
279 /* get a list of trusted domains */
280 static NTSTATUS trusted_domains(struct winbindd_domain *domain,
289 result = msrpc_methods.trusted_domains(domain, mem_ctx,
291 alt_names, dom_sids);
293 if (NT_STATUS_EQUAL(result, NT_STATUS_UNSUCCESSFUL))
294 result = msrpc_methods.trusted_domains(domain, mem_ctx,
296 alt_names, dom_sids);
301 /* the rpc backend methods are exposed via this structure */
302 struct winbindd_methods reconnect_methods = {