]> git.samba.org - ira/wip.git/commitdiff
Move glue.set_credentials hack to samba.Ldb.
authorJelmer Vernooij <jelmer@samba.org>
Sat, 3 Apr 2010 23:51:04 +0000 (01:51 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Tue, 6 Apr 2010 11:12:43 +0000 (13:12 +0200)
source4/lib/ldb-samba/pyldb.c
source4/scripting/python/pyglue.c
source4/scripting/python/samba/__init__.py

index 662bfbaa76fa17f55a68b435f0c30d5718dc8dea..8b58f3f3f5f9cd95ff1ba4a14530f3ba92a2cc53 100644 (file)
@@ -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 },
 };
 
index e4a20f8d193e6e53f4df0e3330a79666ae726dc3..0aee9c3ea3d482e6159f20d44fa8af719a7c777c 100644 (file)
@@ -138,27 +138,6 @@ static PyObject *py_ldb_set_session_info(PyObject *self, PyObject *args)
        Py_RETURN_NONE;
 }
 
-static PyObject *py_ldb_set_credentials(PyObject *self, PyObject *args)
-{
-       PyObject *py_creds, *py_ldb;
-       struct cli_credentials *creds;
-       struct ldb_context *ldb;
-       if (!PyArg_ParseTuple(args, "OO", &py_ldb, &py_creds))
-               return NULL;
-
-       PyErr_LDB_OR_RAISE(py_ldb, ldb);
-       
-       creds = cli_credentials_from_py_object(py_creds);
-       if (creds == NULL) {
-               PyErr_SetString(PyExc_TypeError, "Expected credentials object");
-               return NULL;
-       }
-
-       ldb_set_opaque(ldb, "credentials", creds);
-
-       Py_RETURN_NONE;
-}
-
 static PyObject *py_ldb_set_utf8_casefold(PyObject *self, PyObject *args)
 {
        PyObject *py_ldb;
@@ -518,9 +497,6 @@ static PyMethodDef py_misc_methods[] = {
        { "ldb_set_session_info", (PyCFunction)py_ldb_set_session_info, METH_VARARGS,
                "ldb_set_session_info(ldb, session_info)\n"
                "Set session info 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." },
        { "samdb_set_domain_sid", (PyCFunction)py_samdb_set_domain_sid, METH_VARARGS,
                "samdb_set_domain_sid(samdb, sid)\n"
                "Set SID of domain to use." },
index 80c6df626a5a2df12a91cd48bc0a62384c35bfe1..64ad6470f2e9a85b80a4e085181d6a80c18bec00 100644 (file)
@@ -113,9 +113,6 @@ class Ldb(Ldb):
     def set_session_info(self, session_info):
         glue.ldb_set_session_info(self, session_info)
 
-    def set_credentials(self, credentials):
-        glue.ldb_set_credentials(self, credentials)
-
     def set_create_perms(self, perms=0600):
         # we usually want Samba databases to be private. If we later find we
         # need one public, we will have to change this here