rpc_client: add cli_get_session_key().
authorGünther Deschner <gd@samba.org>
Tue, 10 Jun 2008 19:35:34 +0000 (21:35 +0200)
committerGünther Deschner <gd@samba.org>
Tue, 24 Jun 2008 21:47:58 +0000 (23:47 +0200)
Guenther
(This used to be commit 93b56755f739889da3a67b18a6430b14306d84f7)

source3/include/proto.h
source3/rpc_client/cli_pipe.c

index 79a9251194fef023b1c69686b2cfba7ae80df7ee..70ab390dc17438762c78aa2b52d153fbeba1e94b 100644 (file)
@@ -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  */
 
index 2fd0a6e7ebf91e7c6a184000e65b2f29d6086866..469142d146c76951b7b370877065c75a5185699e 100644 (file)
@@ -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;
+}