2 Unix SMB/CIFS implementation.
4 Wrapper around winbindd_ads.c to centralize retry logic.
5 Copyright (C) Christof Schmitt 2016
7 Based on winbindd_reconnect.c
8 Copyright (C) Volker Lendecke 2005
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 3 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>.
30 #define DBGC_CLASS DBGC_WINBIND
32 extern struct winbindd_methods ads_methods;
35 static NTSTATUS query_user_list(struct winbindd_domain *domain,
37 uint32_t *num_entries,
38 struct wbint_userinfo **info)
42 result = ads_methods.query_user_list(domain, mem_ctx,
45 if (reconnect_need_retry(result, domain)) {
46 result = ads_methods.query_user_list(domain, mem_ctx,
53 /* list all domain groups */
54 static NTSTATUS enum_dom_groups(struct winbindd_domain *domain,
56 uint32_t *num_entries,
57 struct wb_acct_info **info)
61 result = ads_methods.enum_dom_groups(domain, mem_ctx,
64 if (reconnect_need_retry(result, domain)) {
65 result = ads_methods.enum_dom_groups(domain, mem_ctx,
72 /* List all domain groups */
73 static NTSTATUS enum_local_groups(struct winbindd_domain *domain,
75 uint32_t *num_entries,
76 struct wb_acct_info **info)
80 result = ads_methods.enum_local_groups(domain, mem_ctx,
83 if (reconnect_need_retry(result, domain)) {
84 result = ads_methods.enum_local_groups(domain, mem_ctx,
91 /* convert a single name to a sid in a domain */
92 static NTSTATUS name_to_sid(struct winbindd_domain *domain,
94 const char *domain_name,
98 enum lsa_SidType *type)
102 result = ads_methods.name_to_sid(domain, mem_ctx, domain_name, name,
105 if (reconnect_need_retry(result, domain)) {
106 result = ads_methods.name_to_sid(domain, mem_ctx,
107 domain_name, name, flags,
115 convert a domain SID to a user or group name
117 static NTSTATUS sid_to_name(struct winbindd_domain *domain,
119 const struct dom_sid *sid,
122 enum lsa_SidType *type)
126 result = ads_methods.sid_to_name(domain, mem_ctx, sid,
127 domain_name, name, type);
129 if (reconnect_need_retry(result, domain))
130 result = ads_methods.sid_to_name(domain, mem_ctx, sid,
131 domain_name, name, type);
136 static NTSTATUS rids_to_names(struct winbindd_domain *domain,
138 const struct dom_sid *sid,
143 enum lsa_SidType **types)
147 result = ads_methods.rids_to_names(domain, mem_ctx, sid,
149 domain_name, names, types);
150 if (reconnect_need_retry(result, domain)) {
151 result = ads_methods.rids_to_names(domain, mem_ctx, sid,
152 rids, num_rids, domain_name,
159 static NTSTATUS lookup_useraliases(struct winbindd_domain *domain,
162 const struct dom_sid *sids,
163 uint32_t *num_aliases, uint32_t **alias_rids)
167 result = ads_methods.lookup_useraliases(domain, mem_ctx, num_sids, sids,
168 num_aliases, alias_rids);
170 if (reconnect_need_retry(result, domain)) {
171 result = ads_methods.lookup_useraliases(domain, mem_ctx,
180 /* Lookup group membership given a rid. */
181 static NTSTATUS lookup_groupmem(struct winbindd_domain *domain,
183 const struct dom_sid *group_sid,
184 enum lsa_SidType type,
186 struct dom_sid **sid_mem, char ***names,
187 uint32_t **name_types)
191 result = ads_methods.lookup_groupmem(domain, mem_ctx, group_sid, type,
192 num_names, sid_mem, names,
195 if (reconnect_need_retry(result, domain)) {
196 result = ads_methods.lookup_groupmem(domain, mem_ctx, group_sid,
197 type, num_names, sid_mem,
204 /* find the sequence number for a domain */
205 static NTSTATUS sequence_number(struct winbindd_domain *domain, uint32_t *seq)
209 result = ads_methods.sequence_number(domain, seq);
211 if (reconnect_need_retry(result, domain)) {
212 result = ads_methods.sequence_number(domain, seq);
218 /* find the lockout policy of a domain */
219 static NTSTATUS lockout_policy(struct winbindd_domain *domain,
221 struct samr_DomInfo12 *policy)
225 result = ads_methods.lockout_policy(domain, mem_ctx, policy);
227 if (reconnect_need_retry(result, domain)) {
228 result = ads_methods.lockout_policy(domain, mem_ctx, policy);
234 /* find the password policy of a domain */
235 static NTSTATUS password_policy(struct winbindd_domain *domain,
237 struct samr_DomInfo1 *policy)
241 result = ads_methods.password_policy(domain, mem_ctx, policy);
243 if (reconnect_need_retry(result, domain)) {
244 result = ads_methods.password_policy(domain, mem_ctx, policy);
250 /* get a list of trusted domains */
251 static NTSTATUS trusted_domains(struct winbindd_domain *domain,
253 struct netr_DomainTrustList *trusts)
257 result = ads_methods.trusted_domains(domain, mem_ctx, trusts);
259 if (reconnect_need_retry(result, domain)) {
260 result = ads_methods.trusted_domains(domain, mem_ctx, trusts);
266 /* the rpc backend methods are exposed via this structure */
267 struct winbindd_methods reconnect_ads_methods = {