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
,
41 result
= ads_methods
.query_user_list(domain
, mem_ctx
, rids
);
43 if (reconnect_need_retry(result
, domain
)) {
44 result
= ads_methods
.query_user_list(domain
, mem_ctx
, rids
);
50 /* list all domain groups */
51 static NTSTATUS
enum_dom_groups(struct winbindd_domain
*domain
,
53 uint32_t *num_entries
,
54 struct wb_acct_info
**info
)
58 result
= ads_methods
.enum_dom_groups(domain
, mem_ctx
,
61 if (reconnect_need_retry(result
, domain
)) {
62 result
= ads_methods
.enum_dom_groups(domain
, mem_ctx
,
69 /* List all domain groups */
70 static NTSTATUS
enum_local_groups(struct winbindd_domain
*domain
,
72 uint32_t *num_entries
,
73 struct wb_acct_info
**info
)
77 result
= ads_methods
.enum_local_groups(domain
, mem_ctx
,
80 if (reconnect_need_retry(result
, domain
)) {
81 result
= ads_methods
.enum_local_groups(domain
, mem_ctx
,
88 /* convert a single name to a sid in a domain */
89 static NTSTATUS
name_to_sid(struct winbindd_domain
*domain
,
91 const char *domain_name
,
95 enum lsa_SidType
*type
)
99 result
= ads_methods
.name_to_sid(domain
, mem_ctx
, domain_name
, name
,
102 if (reconnect_need_retry(result
, domain
)) {
103 result
= ads_methods
.name_to_sid(domain
, mem_ctx
,
104 domain_name
, name
, flags
,
112 convert a domain SID to a user or group name
114 static NTSTATUS
sid_to_name(struct winbindd_domain
*domain
,
116 const struct dom_sid
*sid
,
119 enum lsa_SidType
*type
)
123 result
= ads_methods
.sid_to_name(domain
, mem_ctx
, sid
,
124 domain_name
, name
, type
);
126 if (reconnect_need_retry(result
, domain
))
127 result
= ads_methods
.sid_to_name(domain
, mem_ctx
, sid
,
128 domain_name
, name
, type
);
133 static NTSTATUS
rids_to_names(struct winbindd_domain
*domain
,
135 const struct dom_sid
*sid
,
140 enum lsa_SidType
**types
)
144 result
= ads_methods
.rids_to_names(domain
, mem_ctx
, sid
,
146 domain_name
, names
, types
);
147 if (reconnect_need_retry(result
, domain
)) {
148 result
= ads_methods
.rids_to_names(domain
, mem_ctx
, sid
,
149 rids
, num_rids
, domain_name
,
156 /* Lookup groups a user is a member of. I wish Unix had a call like this! */
157 static NTSTATUS
lookup_usergroups(struct winbindd_domain
*domain
,
159 const struct dom_sid
*user_sid
,
160 uint32_t *num_groups
,
161 struct dom_sid
**user_gids
)
165 result
= ads_methods
.lookup_usergroups(domain
, mem_ctx
, user_sid
,
166 num_groups
, user_gids
);
168 if (reconnect_need_retry(result
, domain
)) {
169 result
= ads_methods
.lookup_usergroups(domain
, mem_ctx
,
170 user_sid
, num_groups
,
177 static NTSTATUS
lookup_useraliases(struct winbindd_domain
*domain
,
180 const struct dom_sid
*sids
,
181 uint32_t *num_aliases
, uint32_t **alias_rids
)
185 result
= ads_methods
.lookup_useraliases(domain
, mem_ctx
, num_sids
, sids
,
186 num_aliases
, alias_rids
);
188 if (reconnect_need_retry(result
, domain
)) {
189 result
= ads_methods
.lookup_useraliases(domain
, mem_ctx
,
198 /* Lookup group membership given a rid. */
199 static NTSTATUS
lookup_groupmem(struct winbindd_domain
*domain
,
201 const struct dom_sid
*group_sid
,
202 enum lsa_SidType type
,
204 struct dom_sid
**sid_mem
, char ***names
,
205 uint32_t **name_types
)
209 result
= ads_methods
.lookup_groupmem(domain
, mem_ctx
, group_sid
, type
,
210 num_names
, sid_mem
, names
,
213 if (reconnect_need_retry(result
, domain
)) {
214 result
= ads_methods
.lookup_groupmem(domain
, mem_ctx
, group_sid
,
215 type
, num_names
, sid_mem
,
222 /* find the sequence number for a domain */
223 static NTSTATUS
sequence_number(struct winbindd_domain
*domain
, uint32_t *seq
)
227 result
= ads_methods
.sequence_number(domain
, seq
);
229 if (reconnect_need_retry(result
, domain
)) {
230 result
= ads_methods
.sequence_number(domain
, seq
);
236 /* find the lockout policy of a domain */
237 static NTSTATUS
lockout_policy(struct winbindd_domain
*domain
,
239 struct samr_DomInfo12
*policy
)
243 result
= ads_methods
.lockout_policy(domain
, mem_ctx
, policy
);
245 if (reconnect_need_retry(result
, domain
)) {
246 result
= ads_methods
.lockout_policy(domain
, mem_ctx
, policy
);
252 /* find the password policy of a domain */
253 static NTSTATUS
password_policy(struct winbindd_domain
*domain
,
255 struct samr_DomInfo1
*policy
)
259 result
= ads_methods
.password_policy(domain
, mem_ctx
, policy
);
261 if (reconnect_need_retry(result
, domain
)) {
262 result
= ads_methods
.password_policy(domain
, mem_ctx
, policy
);
268 /* get a list of trusted domains */
269 static NTSTATUS
trusted_domains(struct winbindd_domain
*domain
,
271 struct netr_DomainTrustList
*trusts
)
275 result
= ads_methods
.trusted_domains(domain
, mem_ctx
, trusts
);
277 if (reconnect_need_retry(result
, domain
)) {
278 result
= ads_methods
.trusted_domains(domain
, mem_ctx
, trusts
);
284 /* the rpc backend methods are exposed via this structure */
285 struct winbindd_methods reconnect_ads_methods
= {