summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2008-06-10 21:35:34 +0200
committerGünther Deschner <gd@samba.org>2008-06-24 23:47:58 +0200
commit07f06eec2155268eb6b00e6edba0c17c13b723b9 (patch)
treebd6785339e49694daa153794206bb460ab7dd7bc
parenta8332b91ef461309121a909a59b1c1b46d8065c9 (diff)
downloadsamba-07f06eec2155268eb6b00e6edba0c17c13b723b9.tar.gz
samba-07f06eec2155268eb6b00e6edba0c17c13b723b9.tar.bz2
samba-07f06eec2155268eb6b00e6edba0c17c13b723b9.zip
rpc_client: add cli_get_session_key().
Guenther (This used to be commit 93b56755f739889da3a67b18a6430b14306d84f7)
-rw-r--r--source3/include/proto.h3
-rw-r--r--source3/rpc_client/cli_pipe.c31
2 files changed, 34 insertions, 0 deletions
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;
+}