summaryrefslogtreecommitdiff
path: root/source4/lib/ldb-samba
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2010-04-04 01:51:04 +0200
committerJelmer Vernooij <jelmer@samba.org>2010-04-06 13:12:43 +0200
commitb72a5c033670a84423d1099aedbcfa5047ac47e6 (patch)
treee6f9d54e99996ad17cb37b058a137f02765e47d3 /source4/lib/ldb-samba
parent099fc00b601fe7775f5fdb18d8473031b8a7ce27 (diff)
downloadsamba-b72a5c033670a84423d1099aedbcfa5047ac47e6.tar.gz
samba-b72a5c033670a84423d1099aedbcfa5047ac47e6.tar.bz2
samba-b72a5c033670a84423d1099aedbcfa5047ac47e6.zip
Move glue.set_credentials hack to samba.Ldb.
Diffstat (limited to 'source4/lib/ldb-samba')
-rw-r--r--source4/lib/ldb-samba/pyldb.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/source4/lib/ldb-samba/pyldb.c b/source4/lib/ldb-samba/pyldb.c
index 662bfbaa76..8b58f3f3f5 100644
--- a/source4/lib/ldb-samba/pyldb.c
+++ b/source4/lib/ldb-samba/pyldb.c
@@ -24,6 +24,7 @@
#include <ldb.h>
#include "lib/ldb/pyldb.h"
#include "param/pyparam.h"
+#include "auth/credentials/pycredentials.h"
static PyObject *pyldb_module;
staticforward PyTypeObject PySambaLdb;
@@ -50,10 +51,35 @@ static PyObject *py_ldb_set_loadparm(PyObject *self, PyObject *args)
Py_RETURN_NONE;
}
+static PyObject *py_ldb_set_credentials(PyObject *self, PyObject *args)
+{
+ PyObject *py_creds;
+ struct cli_credentials *creds;
+ struct ldb_context *ldb;
+
+ if (!PyArg_ParseTuple(args, "O", &py_creds))
+ return NULL;
+
+ creds = cli_credentials_from_py_object(py_creds);
+ if (creds == NULL) {
+ PyErr_SetString(PyExc_TypeError, "Expected credentials object");
+ return NULL;
+ }
+
+ ldb = PyLdb_AsLdbContext(self);
+
+ ldb_set_opaque(ldb, "credentials", creds);
+
+ Py_RETURN_NONE;
+}
+
static PyMethodDef py_samba_ldb_methods[] = {
{ "set_loadparm", (PyCFunction)py_ldb_set_loadparm, METH_VARARGS,
"ldb_set_loadparm(ldb, session_info)\n"
"Set loadparm context to use when connecting." },
+ { "ldb_set_credentials", (PyCFunction)py_ldb_set_credentials, METH_VARARGS,
+ "ldb_set_credentials(ldb, credentials)\n"
+ "Set credentials to use when connecting." },
{ NULL },
};