diff options
author | Stefan Metzmacher <metze@samba.org> | 2014-12-17 08:40:49 +0000 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2014-12-19 13:15:13 +0100 |
commit | 995cf54b3177cd92b1bce5f34df134122a0200de (patch) | |
tree | 7042896bee72c4c3c58e02092df0efbf6486fa83 /source3/rpc_client | |
parent | 826b0f761e07987fbe067badde665c3d1c99e821 (diff) | |
download | samba-995cf54b3177cd92b1bce5f34df134122a0200de.tar.gz |
s3:cli_netlogon: add rpccli_{create,setup}_netlogon_creds_with_creds() helper functions
This simplifies the callers, then can just pass in a cli_credentials structure.
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'source3/rpc_client')
-rw-r--r-- | source3/rpc_client/cli_netlogon.c | 54 | ||||
-rw-r--r-- | source3/rpc_client/cli_netlogon.h | 11 |
2 files changed, 65 insertions, 0 deletions
diff --git a/source3/rpc_client/cli_netlogon.c b/source3/rpc_client/cli_netlogon.c index a5ea02cfa84..b08c10fb783 100644 --- a/source3/rpc_client/cli_netlogon.c +++ b/source3/rpc_client/cli_netlogon.c @@ -124,6 +124,32 @@ NTSTATUS rpccli_create_netlogon_creds(const char *server_computer, return NT_STATUS_OK; } +NTSTATUS rpccli_create_netlogon_creds_with_creds(struct cli_credentials *creds, + const char *server_computer, + struct messaging_context *msg_ctx, + TALLOC_CTX *mem_ctx, + struct netlogon_creds_cli_context **netlogon_creds) +{ + enum netr_SchannelType sec_chan_type; + const char *server_netbios_domain; + const char *client_account; + + sec_chan_type = cli_credentials_get_secure_channel_type(creds); + if (sec_chan_type == SEC_CHAN_NULL) { + return NT_STATUS_INVALID_PARAMETER_MIX; + } + + client_account = cli_credentials_get_username(creds); + server_netbios_domain = cli_credentials_get_domain(creds); + + return rpccli_create_netlogon_creds(server_computer, + server_netbios_domain, + client_account, + sec_chan_type, + msg_ctx, mem_ctx, + netlogon_creds); +} + NTSTATUS rpccli_setup_netlogon_creds(struct cli_state *cli, enum dcerpc_transport_t transport, struct netlogon_creds_cli_context *netlogon_creds, @@ -195,6 +221,34 @@ NTSTATUS rpccli_setup_netlogon_creds(struct cli_state *cli, return NT_STATUS_OK; } +NTSTATUS rpccli_setup_netlogon_creds_with_creds(struct cli_state *cli, + enum dcerpc_transport_t transport, + struct netlogon_creds_cli_context *netlogon_creds, + bool force_reauth, + struct cli_credentials *creds) +{ + struct samr_Password *current_nt_hash = NULL; + struct samr_Password *previous_nt_hash = NULL; + NTSTATUS status; + + current_nt_hash = cli_credentials_get_nt_hash(creds, talloc_tos()); + if (current_nt_hash == NULL) { + return NT_STATUS_NO_MEMORY; + } + + status = rpccli_setup_netlogon_creds(cli, transport, + netlogon_creds, + force_reauth, + *current_nt_hash, + previous_nt_hash); + TALLOC_FREE(current_nt_hash); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + return NT_STATUS_OK; +} + static NTSTATUS map_validation_to_info3(TALLOC_CTX *mem_ctx, uint16_t validation_level, union netr_Validation *validation, diff --git a/source3/rpc_client/cli_netlogon.h b/source3/rpc_client/cli_netlogon.h index cc4033e0804..b04f3a2a965 100644 --- a/source3/rpc_client/cli_netlogon.h +++ b/source3/rpc_client/cli_netlogon.h @@ -25,6 +25,7 @@ struct cli_state; struct messaging_context; +struct cli_credentials; struct netlogon_creds_cli_context; struct dcerpc_binding_handle; #include "librpc/rpc/rpc_common.h" @@ -39,12 +40,22 @@ NTSTATUS rpccli_create_netlogon_creds(const char *server_computer, struct messaging_context *msg_ctx, TALLOC_CTX *mem_ctx, struct netlogon_creds_cli_context **netlogon_creds); +NTSTATUS rpccli_create_netlogon_creds_with_creds(struct cli_credentials *creds, + const char *server_computer, + struct messaging_context *msg_ctx, + TALLOC_CTX *mem_ctx, + struct netlogon_creds_cli_context **netlogon_creds); NTSTATUS rpccli_setup_netlogon_creds(struct cli_state *cli, enum dcerpc_transport_t transport, struct netlogon_creds_cli_context *netlogon_creds, bool force_reauth, struct samr_Password current_nt_hash, const struct samr_Password *previous_nt_hash); +NTSTATUS rpccli_setup_netlogon_creds_with_creds(struct cli_state *cli, + enum dcerpc_transport_t transport, + struct netlogon_creds_cli_context *netlogon_creds, + bool force_reauth, + struct cli_credentials *creds); NTSTATUS rpccli_netlogon_password_logon(struct netlogon_creds_cli_context *creds, struct dcerpc_binding_handle *binding_handle, TALLOC_CTX *mem_ctx, |