diff options
author | Gary Lockyer <gary@catalyst.net.nz> | 2017-06-15 15:55:43 +1200 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2017-06-22 08:56:22 +0200 |
commit | b68a3374a56c7117aa1d9fedf56940b6a1ed1cae (patch) | |
tree | 6bf3b3098190c45300061b74f264277763c8f0e1 /auth/credentials | |
parent | 7539595c4807a0396feb90b2dedb1001162dda74 (diff) | |
download | samba-b68a3374a56c7117aa1d9fedf56940b6a1ed1cae.tar.gz |
pycredentials: add function to return the netr_Authenticator
Add method new_client_authenticator that returns data to allow a
netr_Authenticator to be constructed.
Allows python to make netr_LogonSamLogonWithFlags,
netr_LogonGetDomainInfo and similar calls
Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'auth/credentials')
-rw-r--r-- | auth/credentials/pycredentials.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/auth/credentials/pycredentials.c b/auth/credentials/pycredentials.c index fee9556b180..30698d49dc5 100644 --- a/auth/credentials/pycredentials.c +++ b/auth/credentials/pycredentials.c @@ -26,6 +26,8 @@ #include "libcli/util/pyerrors.h" #include "param/pyparam.h" #include <tevent.h> +#include "libcli/auth/libcli_auth.h" +#include "auth/credentials/credentials_internal.h" void initcredentials(void); @@ -584,6 +586,39 @@ static PyObject *py_creds_get_gensec_features(PyObject *self, PyObject *args) return PyInt_FromLong(gensec_features); } +static PyObject *py_creds_new_client_authenticator(PyObject *self, + PyObject *args) +{ + struct netr_Authenticator auth; + struct cli_credentials *creds = NULL; + struct netlogon_creds_CredentialState *nc = NULL; + PyObject *ret = NULL; + + creds = PyCredentials_AsCliCredentials(self); + if (creds == NULL) { + PyErr_SetString(PyExc_RuntimeError, + "Failed to get credentials from python"); + return NULL; + } + + nc = creds->netlogon_creds; + if (nc == NULL) { + PyErr_SetString(PyExc_ValueError, + "No netlogon credentials cannot make " + "client authenticator"); + return NULL; + } + + netlogon_creds_client_authenticator( + nc, + &auth); + ret = Py_BuildValue("{ss#si}", + "credential", + (const char *) &auth.cred, sizeof(auth.cred), + "timestamp", auth.timestamp); + return ret; +} + static PyObject *py_creds_set_secure_channel_type(PyObject *self, PyObject *args) { unsigned int channel_type; @@ -700,6 +735,11 @@ static PyMethodDef py_creds_methods[] = { { "set_forced_sasl_mech", py_creds_set_forced_sasl_mech, METH_VARARGS, "S.set_forced_sasl_mech(name) -> None\n" "Set forced SASL mechanism." }, + { "new_client_authenticator", + py_creds_new_client_authenticator, + METH_NOARGS, + "S.new_client_authenticator() -> Authenticator\n" + "Get a new client NETLOGON_AUTHENTICATOR"}, { "set_secure_channel_type", py_creds_set_secure_channel_type, METH_VARARGS, NULL }, { NULL } |