summaryrefslogtreecommitdiff
path: root/source4/librpc/rpc
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2011-12-16 10:55:46 +0100
committerStefan Metzmacher <metze@samba.org>2012-01-04 22:31:52 +0100
commit1b45f2aed86dda9fda6e6bcf1c9c7cbdc471c18d (patch)
treedae8487ed63205b6af35ce4814e5e74ede24bf3f /source4/librpc/rpc
parent9465b9ce6f26d5db0477110a59da1a9306567d7b (diff)
downloadsamba-1b45f2aed86dda9fda6e6bcf1c9c7cbdc471c18d.tar.gz
samba-1b45f2aed86dda9fda6e6bcf1c9c7cbdc471c18d.tar.bz2
samba-1b45f2aed86dda9fda6e6bcf1c9c7cbdc471c18d.zip
s4:pyrpc: add 'user_session_key' getter to the connection object
This gets the session key from gensec for usage in DRSUAPI. metze Autobuild-User: Stefan Metzmacher <metze@samba.org> Autobuild-Date: Wed Jan 4 22:31:52 CET 2012 on sn-devel-104
Diffstat (limited to 'source4/librpc/rpc')
-rw-r--r--source4/librpc/rpc/pyrpc.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/source4/librpc/rpc/pyrpc.c b/source4/librpc/rpc/pyrpc.c
index 7aa5ff5868..23961e7a07 100644
--- a/source4/librpc/rpc/pyrpc.c
+++ b/source4/librpc/rpc/pyrpc.c
@@ -26,6 +26,7 @@
#include "librpc/rpc/dcerpc.h"
#include "librpc/rpc/pyrpc_util.h"
#include "auth/credentials/pycredentials.h"
+#include "auth/gensec/gensec.h"
void initbase(void);
@@ -128,6 +129,47 @@ static PyObject *py_iface_session_key(PyObject *obj, void *closure)
return PyString_FromStringAndSize((const char *)session_key.data, session_key.length);
}
+static PyObject *py_iface_user_session_key(PyObject *obj, void *closure)
+{
+ dcerpc_InterfaceObject *iface = (dcerpc_InterfaceObject *)obj;
+ TALLOC_CTX *mem_ctx;
+ NTSTATUS status;
+ struct gensec_security *security = NULL;
+ DATA_BLOB session_key = data_blob_null;
+ static PyObject *session_key_obj = NULL;
+
+ if (iface->pipe == NULL) {
+ PyErr_SetNTSTATUS(NT_STATUS_NO_USER_SESSION_KEY);
+ return NULL;
+ }
+
+ if (iface->pipe->conn == NULL) {
+ PyErr_SetNTSTATUS(NT_STATUS_NO_USER_SESSION_KEY);
+ return NULL;
+ }
+
+ if (iface->pipe->conn->security_state.generic_state == NULL) {
+ PyErr_SetNTSTATUS(NT_STATUS_NO_USER_SESSION_KEY);
+ return NULL;
+ }
+
+ security = iface->pipe->conn->security_state.generic_state;
+
+ mem_ctx = talloc_new(NULL);
+
+ status = gensec_session_key(security, mem_ctx, &session_key);
+ if (!NT_STATUS_IS_OK(status)) {
+ talloc_free(mem_ctx);
+ PyErr_SetNTSTATUS(status);
+ return NULL;
+ }
+
+ session_key_obj = PyString_FromStringAndSize((const char *)session_key.data,
+ session_key.length);
+ talloc_free(mem_ctx);
+ return session_key_obj;
+}
+
static PyGetSetDef dcerpc_interface_getsetters[] = {
{ discard_const_p(char, "server_name"), py_iface_server_name, NULL,
discard_const_p(char, "name of the server, if connected over SMB") },
@@ -137,6 +179,8 @@ static PyGetSetDef dcerpc_interface_getsetters[] = {
discard_const_p(char, "syntax id of the transfersyntax") },
{ discard_const_p(char, "session_key"), py_iface_session_key, NULL,
discard_const_p(char, "session key (as used for blob encryption on LSA and SAMR)") },
+ { discard_const_p(char, "user_session_key"), py_iface_user_session_key, NULL,
+ discard_const_p(char, "user_session key (as used for blob encryption on DRSUAPI)") },
{ NULL }
};