mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
winbindd: add dcname arg to ChangeMachineAccount request
Existing callers will pass an empty string, later a new caller will pass an explicit DC name taken from the wbinfo command line. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
parent
4a74748d32
commit
eb1d1f19a2
@ -162,6 +162,7 @@ interface winbind
|
||||
);
|
||||
|
||||
NTSTATUS wbint_ChangeMachineAccount(
|
||||
[in,unique,string,charset(UTF8)] char *dcname
|
||||
);
|
||||
|
||||
NTSTATUS wbint_PingDc(
|
||||
|
@ -36,6 +36,7 @@ struct tevent_req *winbindd_change_machine_acct_send(TALLOC_CTX *mem_ctx,
|
||||
struct tevent_req *req, *subreq;
|
||||
struct winbindd_change_machine_acct_state *state;
|
||||
struct winbindd_domain *domain;
|
||||
const char *dcname = NULL;
|
||||
|
||||
req = tevent_req_create(mem_ctx, &state,
|
||||
struct winbindd_change_machine_acct_state);
|
||||
@ -43,6 +44,10 @@ struct tevent_req *winbindd_change_machine_acct_send(TALLOC_CTX *mem_ctx,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (request->data.init_conn.dcname[0] != '\0') {
|
||||
dcname = request->data.init_conn.dcname;
|
||||
}
|
||||
|
||||
domain = find_domain_from_name(request->domain_name);
|
||||
if (domain == NULL) {
|
||||
tevent_req_nterror(req, NT_STATUS_NO_SUCH_DOMAIN);
|
||||
@ -62,7 +67,8 @@ struct tevent_req *winbindd_change_machine_acct_send(TALLOC_CTX *mem_ctx,
|
||||
}
|
||||
|
||||
subreq = dcerpc_wbint_ChangeMachineAccount_send(state, ev,
|
||||
dom_child_handle(domain));
|
||||
dom_child_handle(domain),
|
||||
dcname);
|
||||
if (tevent_req_nomem(subreq, req)) {
|
||||
return tevent_req_post(req, ev);
|
||||
}
|
||||
|
@ -841,6 +841,22 @@ NTSTATUS _wbint_ChangeMachineAccount(struct pipes_struct *p,
|
||||
return NT_STATUS_REQUEST_NOT_ACCEPTED;
|
||||
}
|
||||
|
||||
if (r->in.dcname != NULL && r->in.dcname[0] != '\0') {
|
||||
invalidate_cm_connection(domain);
|
||||
TALLOC_FREE(domain->dcname);
|
||||
|
||||
domain->dcname = talloc_strdup(domain, r->in.dcname);
|
||||
if (domain->dcname == NULL) {
|
||||
status = NT_STATUS_NO_MEMORY;
|
||||
goto done;
|
||||
}
|
||||
domain->force_dc = true;
|
||||
|
||||
DBG_NOTICE("attempt connection to change trust account "
|
||||
"password for %s at %s\n",
|
||||
domain->name, domain->dcname);
|
||||
}
|
||||
|
||||
status = cm_connect_netlogon_secure(domain,
|
||||
&netlogon_pipe,
|
||||
&netlogon_creds_ctx);
|
||||
@ -863,9 +879,13 @@ NTSTATUS _wbint_ChangeMachineAccount(struct pipes_struct *p,
|
||||
NT_STATUS_IS_OK(status) ? "changed" : "unchanged"));
|
||||
|
||||
done:
|
||||
DEBUG(NT_STATUS_IS_OK(status) ? 5 : 2,
|
||||
("Changing the trust account password for domain %s returned %s\n",
|
||||
domain->name, nt_errstr(status)));
|
||||
DEBUG(NT_STATUS_IS_OK(status) ? 5 :
|
||||
domain->force_dc ? 0 : 2,
|
||||
("Changing the trust account password for domain %s at %s "
|
||||
"(forced: %s) returned %s\n",
|
||||
domain->name, domain->dcname, domain->force_dc ? "yes" : "no",
|
||||
nt_errstr(status)));
|
||||
domain->force_dc = false;
|
||||
|
||||
return status;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user