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;
30 bool reconnect_need_retry(NTSTATUS status, struct winbindd_domain *domain)
32 if (NT_STATUS_IS_OK(status)) {
36 if (!NT_STATUS_IS_ERR(status)) {
40 if (NT_STATUS_EQUAL(status, NT_STATUS_NONE_MAPPED)) {
44 if (NT_STATUS_EQUAL(status, NT_STATUS_NO_SUCH_USER)) {
48 if (NT_STATUS_EQUAL(status, NT_STATUS_NO_SUCH_GROUP)) {
52 if (NT_STATUS_EQUAL(status, NT_STATUS_NO_SUCH_ALIAS)) {
56 if (NT_STATUS_EQUAL(status, NT_STATUS_NO_SUCH_MEMBER)) {
60 if (NT_STATUS_EQUAL(status, NT_STATUS_NO_SUCH_DOMAIN)) {
64 if (NT_STATUS_EQUAL(status, NT_STATUS_NO_SUCH_PRIVILEGE)) {
68 if (NT_STATUS_EQUAL(status, NT_STATUS_NO_MEMORY)) {
72 if (NT_STATUS_EQUAL(status, NT_STATUS_IO_DEVICE_ERROR)) {
74 * RPC call sent on expired session, needs
77 invalidate_cm_connection(domain);
84 static NTSTATUS query_user_list(struct winbindd_domain *domain,
90 result = msrpc_methods.query_user_list(domain, mem_ctx, rids);
92 if (reconnect_need_retry(result, domain))
93 result = msrpc_methods.query_user_list(domain, mem_ctx, rids);
98 /* list all domain groups */
99 static NTSTATUS enum_dom_groups(struct winbindd_domain *domain,
101 uint32_t *num_entries,
102 struct wb_acct_info **info)
106 result = msrpc_methods.enum_dom_groups(domain, mem_ctx,
109 if (reconnect_need_retry(result, domain))
110 result = msrpc_methods.enum_dom_groups(domain, mem_ctx,
115 /* List all domain groups */
117 static NTSTATUS enum_local_groups(struct winbindd_domain *domain,
119 uint32_t *num_entries,
120 struct wb_acct_info **info)
124 result = msrpc_methods.enum_local_groups(domain, mem_ctx,
127 if (reconnect_need_retry(result, domain))
128 result = msrpc_methods.enum_local_groups(domain, mem_ctx,
134 /* convert a single name to a sid in a domain */
135 static NTSTATUS name_to_sid(struct winbindd_domain *domain,
137 const char *domain_name,
141 enum lsa_SidType *type)
145 result = msrpc_methods.name_to_sid(domain, mem_ctx, domain_name, name,
148 if (reconnect_need_retry(result, domain))
149 result = msrpc_methods.name_to_sid(domain, mem_ctx,
150 domain_name, name, flags,
157 convert a domain SID to a user or group name
159 static NTSTATUS sid_to_name(struct winbindd_domain *domain,
161 const struct dom_sid *sid,
164 enum lsa_SidType *type)
168 result = msrpc_methods.sid_to_name(domain, mem_ctx, sid,
169 domain_name, name, type);
171 if (reconnect_need_retry(result, domain))
172 result = msrpc_methods.sid_to_name(domain, mem_ctx, sid,
173 domain_name, name, type);
178 static NTSTATUS rids_to_names(struct winbindd_domain *domain,
180 const struct dom_sid *sid,
185 enum lsa_SidType **types)
189 result = msrpc_methods.rids_to_names(domain, mem_ctx, sid,
191 domain_name, names, types);
192 if (reconnect_need_retry(result, domain)) {
193 result = msrpc_methods.rids_to_names(domain, mem_ctx, sid,
202 static NTSTATUS lookup_useraliases(struct winbindd_domain *domain,
204 uint32_t num_sids, const struct dom_sid *sids,
205 uint32_t *num_aliases, uint32_t **alias_rids)
209 result = msrpc_methods.lookup_useraliases(domain, mem_ctx,
214 if (reconnect_need_retry(result, domain))
215 result = msrpc_methods.lookup_useraliases(domain, mem_ctx,
223 /* Lookup group membership given a rid. */
224 static NTSTATUS lookup_groupmem(struct winbindd_domain *domain,
226 const struct dom_sid *group_sid,
227 enum lsa_SidType type,
229 struct dom_sid **sid_mem, char ***names,
230 uint32_t **name_types)
234 result = msrpc_methods.lookup_groupmem(domain, mem_ctx,
235 group_sid, type, num_names,
239 if (reconnect_need_retry(result, domain))
240 result = msrpc_methods.lookup_groupmem(domain, mem_ctx,
249 /* find the sequence number for a domain */
250 static NTSTATUS sequence_number(struct winbindd_domain *domain, uint32_t *seq)
254 result = msrpc_methods.sequence_number(domain, seq);
256 if (reconnect_need_retry(result, domain))
257 result = msrpc_methods.sequence_number(domain, seq);
262 /* find the lockout policy of a domain */
263 static NTSTATUS lockout_policy(struct winbindd_domain *domain,
265 struct samr_DomInfo12 *policy)
269 result = msrpc_methods.lockout_policy(domain, mem_ctx, policy);
271 if (reconnect_need_retry(result, domain))
272 result = msrpc_methods.lockout_policy(domain, mem_ctx, policy);
277 /* find the password policy of a domain */
278 static NTSTATUS password_policy(struct winbindd_domain *domain,
280 struct samr_DomInfo1 *policy)
284 result = msrpc_methods.password_policy(domain, mem_ctx, policy);
286 if (reconnect_need_retry(result, domain))
287 result = msrpc_methods.password_policy(domain, mem_ctx, policy);
292 /* get a list of trusted domains */
293 static NTSTATUS trusted_domains(struct winbindd_domain *domain,
295 struct netr_DomainTrustList *trusts)
299 result = msrpc_methods.trusted_domains(domain, mem_ctx, trusts);
301 if (reconnect_need_retry(result, domain))
302 result = msrpc_methods.trusted_domains(domain, mem_ctx,
308 /* the rpc backend methods are exposed via this structure */
309 struct winbindd_methods reconnect_methods = {