From 07f06eec2155268eb6b00e6edba0c17c13b723b9 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 10 Jun 2008 21:35:34 +0200 Subject: rpc_client: add cli_get_session_key(). Guenther (This used to be commit 93b56755f739889da3a67b18a6430b14306d84f7) --- source3/include/proto.h | 3 +++ source3/rpc_client/cli_pipe.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/source3/include/proto.h b/source3/include/proto.h index 79a9251194..70ab390dc1 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -7130,6 +7130,9 @@ struct rpc_pipe_client *cli_rpc_pipe_open_krb5(struct cli_state *cli, const char *username, const char *password, NTSTATUS *perr); +NTSTATUS cli_get_session_key(struct rpc_pipe_client *cli, + DATA_BLOB *session_key); + /* The following definitions come from rpc_client/cli_reg.c */ diff --git a/source3/rpc_client/cli_pipe.c b/source3/rpc_client/cli_pipe.c index 2fd0a6e7eb..469142d146 100644 --- a/source3/rpc_client/cli_pipe.c +++ b/source3/rpc_client/cli_pipe.c @@ -3340,3 +3340,34 @@ struct rpc_pipe_client *cli_rpc_pipe_open_krb5(struct cli_state *cli, return NULL; #endif } + +NTSTATUS cli_get_session_key(struct rpc_pipe_client *cli, + DATA_BLOB *session_key) +{ + if (!session_key || !cli) { + return NT_STATUS_INVALID_PARAMETER; + } + + if (!cli->auth) { + return NT_STATUS_INVALID_PARAMETER; + } + + switch (cli->auth->auth_type) { + case PIPE_AUTH_TYPE_SCHANNEL: + *session_key = data_blob(cli->auth->a_u.schannel_auth->sess_key, 16); + break; + case PIPE_AUTH_TYPE_NTLMSSP: + case PIPE_AUTH_TYPE_SPNEGO_NTLMSSP: + *session_key = cli->auth->a_u.ntlmssp_state->session_key; + break; + case PIPE_AUTH_TYPE_KRB5: + case PIPE_AUTH_TYPE_SPNEGO_KRB5: + *session_key = cli->auth->a_u.kerberos_auth->session_key; + break; + case PIPE_AUTH_TYPE_NONE: + default: + return NT_STATUS_NO_USER_SESSION_KEY; + } + + return NT_STATUS_OK; +} -- cgit