summaryrefslogtreecommitdiff
path: root/auth
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2016-07-12 09:57:16 +0200
committerStefan Metzmacher <metze@samba.org>2016-07-22 16:03:26 +0200
commit67404bac52c1b4d303c4b131efb168c805cdfd78 (patch)
treebf149dcebee485a4846fa5aca224e4f0acda63ba /auth
parenta5591e597dbcbd74a6cb76786f479d5962a41cfd (diff)
downloadsamba-67404bac52c1b4d303c4b131efb168c805cdfd78.tar.gz
pycredentials: add set_utf16_[old_]password()
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'auth')
-rw-r--r--auth/credentials/pycredentials.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/auth/credentials/pycredentials.c b/auth/credentials/pycredentials.c
index 1c0e4069e8e..43fba377609 100644
--- a/auth/credentials/pycredentials.c
+++ b/auth/credentials/pycredentials.c
@@ -78,6 +78,34 @@ static PyObject *py_creds_set_password(PyObject *self, PyObject *args)
return PyBool_FromLong(cli_credentials_set_password(PyCredentials_AsCliCredentials(self), newval, obt));
}
+static PyObject *py_creds_set_utf16_password(PyObject *self, PyObject *args)
+{
+ enum credentials_obtained obt = CRED_SPECIFIED;
+ int _obt = obt;
+ PyObject *newval = NULL;
+ DATA_BLOB blob = data_blob_null;
+ Py_ssize_t size = 0;
+ int result;
+ bool ok;
+
+ if (!PyArg_ParseTuple(args, "O|i", &newval, &_obt)) {
+ return NULL;
+ }
+ obt = _obt;
+
+ result = PyBytes_AsStringAndSize(newval, (char **)&blob.data, &size);
+ if (result != 0) {
+ PyErr_SetString(PyExc_RuntimeError, "Failed to convert passed value to Bytes");
+ return NULL;
+ }
+ blob.length = size;
+
+ ok = cli_credentials_set_utf16_password(PyCredentials_AsCliCredentials(self),
+ &blob, obt);
+
+ return PyBool_FromLong(ok);
+}
+
static PyObject *py_creds_get_old_password(PyObject *self, PyObject *unused)
{
return PyString_FromStringOrNULL(cli_credentials_get_old_password(PyCredentials_AsCliCredentials(self)));
@@ -97,6 +125,31 @@ static PyObject *py_creds_set_old_password(PyObject *self, PyObject *args)
return PyBool_FromLong(cli_credentials_set_old_password(PyCredentials_AsCliCredentials(self), oldval, obt));
}
+static PyObject *py_creds_set_old_utf16_password(PyObject *self, PyObject *args)
+{
+ PyObject *oldval = NULL;
+ DATA_BLOB blob = data_blob_null;
+ Py_ssize_t size = 0;
+ int result;
+ bool ok;
+
+ if (!PyArg_ParseTuple(args, "O", &oldval)) {
+ return NULL;
+ }
+
+ result = PyBytes_AsStringAndSize(oldval, (char **)&blob.data, &size);
+ if (result != 0) {
+ PyErr_SetString(PyExc_RuntimeError, "Failed to convert passed value to Bytes");
+ return NULL;
+ }
+ blob.length = size;
+
+ ok = cli_credentials_set_old_utf16_password(PyCredentials_AsCliCredentials(self),
+ &blob);
+
+ return PyBool_FromLong(ok);
+}
+
static PyObject *py_creds_get_domain(PyObject *self, PyObject *unused)
{
return PyString_FromStringOrNULL(cli_credentials_get_domain(PyCredentials_AsCliCredentials(self)));
@@ -416,12 +469,18 @@ static PyMethodDef py_creds_methods[] = {
{ "set_password", py_creds_set_password, METH_VARARGS,
"S.set_password(password, obtained=CRED_SPECIFIED) -> None\n"
"Change password." },
+ { "set_utf16_password", py_creds_set_utf16_password, METH_VARARGS,
+ "S.set_utf16_password(password, obtained=CRED_SPECIFIED) -> None\n"
+ "Change password." },
{ "get_old_password", py_creds_get_old_password, METH_NOARGS,
"S.get_old_password() -> password\n"
"Obtain old password." },
{ "set_old_password", py_creds_set_old_password, METH_VARARGS,
"S.set_old_password(password, obtained=CRED_SPECIFIED) -> None\n"
"Change old password." },
+ { "set_old_utf16_password", py_creds_set_old_utf16_password, METH_VARARGS,
+ "S.set_old_utf16_password(password, obtained=CRED_SPECIFIED) -> None\n"
+ "Change old password." },
{ "get_domain", py_creds_get_domain, METH_NOARGS,
"S.get_domain() -> domain\n"
"Obtain domain name." },