1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

s3:rpcclient: make use of rpccli_[create|setup]_netlogon_creds_with_creds()

This passing struct cli_credentials allows the usage of the previous password.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
This commit is contained in:
Stefan Metzmacher 2015-02-09 09:25:35 +01:00 committed by Günther Deschner
parent 6d31763de1
commit 9af336cce7

View File

@ -760,58 +760,39 @@ static NTSTATUS do_cmd(struct cli_state *cli,
if (rpcclient_netlogon_creds == NULL && ok) {
const char *dc_name = cmd_entry->rpc_pipe->desthost;
const char *domain = get_cmdline_auth_info_domain(auth_info);
enum netr_SchannelType sec_chan_type = 0;
const char *_account_name = NULL;
const char *account_name = NULL;
struct samr_Password current_nt_hash = {
.hash = { 0 },
};
struct samr_Password *previous_nt_hash = NULL;
struct cli_credentials *creds = NULL;
if (!get_trust_pw_hash(get_cmdline_auth_info_domain(auth_info),
current_nt_hash.hash, &_account_name,
&sec_chan_type))
{
DEBUG(0, ("Failed to fetch trust password for %s to connect to %s.\n",
get_cmdline_auth_info_domain(auth_info),
cmd_entry->table->name));
ntresult = pdb_get_trust_credentials(domain, NULL,
mem_ctx, &creds);
if (!NT_STATUS_IS_OK(ntresult)) {
DEBUG(0, ("Failed to fetch trust credentials for "
"%s to connect to %s: %s\n",
domain, cmd_entry->table->name,
nt_errstr(ntresult)));
TALLOC_FREE(cmd_entry->rpc_pipe);
talloc_free(mem_ctx);
return NT_STATUS_CANT_ACCESS_DOMAIN_INFO;
return ntresult;
}
account_name = talloc_asprintf(mem_ctx, "%s$", _account_name);
if (account_name == NULL) {
DEBUG(0, ("Out of memory creating account name to connect to %s.\n",
cmd_entry->table->name));
TALLOC_FREE(cmd_entry->rpc_pipe);
SAFE_FREE(previous_nt_hash);
TALLOC_FREE(mem_ctx);
return NT_STATUS_NO_MEMORY;
}
ntresult = rpccli_create_netlogon_creds(dc_name,
domain,
account_name,
sec_chan_type,
rpcclient_msg_ctx,
talloc_autofree_context(),
&rpcclient_netlogon_creds);
ntresult = rpccli_create_netlogon_creds_with_creds(creds,
dc_name,
rpcclient_msg_ctx,
talloc_autofree_context(),
&rpcclient_netlogon_creds);
if (!NT_STATUS_IS_OK(ntresult)) {
DEBUG(0, ("Could not initialise credentials for %s.\n",
cmd_entry->table->name));
TALLOC_FREE(cmd_entry->rpc_pipe);
SAFE_FREE(previous_nt_hash);
TALLOC_FREE(mem_ctx);
return ntresult;
}
ntresult = rpccli_setup_netlogon_creds(cli, NCACN_NP,
ntresult = rpccli_setup_netlogon_creds_with_creds(cli,
NCACN_NP,
rpcclient_netlogon_creds,
false, /* force_reauth */
current_nt_hash,
previous_nt_hash);
SAFE_FREE(previous_nt_hash);
creds);
TALLOC_FREE(creds);
if (!NT_STATUS_IS_OK(ntresult)) {
DEBUG(0, ("Could not initialise credentials for %s.\n",
cmd_entry->table->name));