#include <Python.h>
#include "includes.h"
#include <ldb.h>
-#include "lib/ldb/pyldb.h"
+#include <pyldb.h>
#include "param/pyparam.h"
#include "auth/credentials/pycredentials.h"
#include "ldb_wrap.h"
#include "lib/ldb-samba/ldif_handlers.h"
+#include "auth/pyauth.h"
+
+void init_ldb(void);
static PyObject *pyldb_module;
static PyObject *py_ldb_error;
ldb_ctx == NULL?ldb_strerror(ret):ldb_errstring(ldb_ctx)));
}
-
-
static PyObject *py_ldb_set_loadparm(PyObject *self, PyObject *args)
{
PyObject *py_lp_ctx;
if (!PyArg_ParseTuple(args, "O", &py_lp_ctx))
return NULL;
- lp_ctx = lp_from_py_object(py_lp_ctx);
+ ldb = PyLdb_AsLdbContext(self);
+
+ lp_ctx = lpcfg_from_py_object(ldb, py_lp_ctx);
if (lp_ctx == NULL) {
PyErr_SetString(PyExc_TypeError, "Expected loadparm object");
return NULL;
}
- ldb = PyLdb_AsLdbContext(self);
-
ldb_set_opaque(ldb, "loadparm", lp_ctx);
Py_RETURN_NONE;
if (old_val) {
*old_val = value;
Py_RETURN_NONE;
- }
+ }
tmp_ctx = talloc_new(ldb);
if (tmp_ctx == NULL) {
PyErr_NoMemory();
return NULL;
}
-
+
new_val = talloc(tmp_ctx, int);
if (new_val == NULL) {
talloc_free(tmp_ctx);
PyErr_NoMemory();
return NULL;
}
-
+
opaque_name_talloc = talloc_strdup(tmp_ctx, py_opaque_name);
if (opaque_name_talloc == NULL) {
talloc_free(tmp_ctx);
PyErr_NoMemory();
return NULL;
}
-
+
*new_val = value;
/* cache the domain_sid in the ldb */
ret = ldb_set_opaque(ldb, opaque_name_talloc, new_val);
-
+
if (ret != LDB_SUCCESS) {
talloc_free(tmp_ctx);
PyErr_SetLdbError(py_ldb_error, ret, ldb);
Py_RETURN_NONE;
}
+static PyObject *py_ldb_set_session_info(PyObject *self, PyObject *args)
+{
+ PyObject *py_session_info;
+ struct auth_session_info *info;
+ struct ldb_context *ldb;
+ PyObject *mod_samba_auth;
+ PyObject *PyAuthSession_Type;
+ bool ret;
+
+ mod_samba_auth = PyImport_ImportModule("samba.dcerpc.auth");
+ if (mod_samba_auth == NULL)
+ return NULL;
+
+ PyAuthSession_Type = PyObject_GetAttrString(mod_samba_auth, "session_info");
+ if (PyAuthSession_Type == NULL)
+ return NULL;
+
+ ret = PyArg_ParseTuple(args, "O!", PyAuthSession_Type, &py_session_info);
+
+ Py_DECREF(PyAuthSession_Type);
+ Py_DECREF(mod_samba_auth);
+
+ if (!ret)
+ return NULL;
+
+ ldb = PyLdb_AsLdbContext(self);
+
+ info = PyAuthSession_AsSession(py_session_info);
+
+ ldb_set_opaque(ldb, "sessionInfo", info);
+
+ Py_RETURN_NONE;
+}
+
static PyObject *py_ldb_register_samba_handlers(PyObject *self)
{
struct ldb_context *ldb;
METH_NOARGS,
"register_samba_handlers()\n"
"Register Samba-specific LDB modules and schemas." },
+ { "set_session_info", (PyCFunction)py_ldb_set_session_info, METH_VARARGS,
+ "set_session_info(session_info)\n"
+ "Set session info to use when connecting." },
{ NULL },
};
static PyTypeObject PySambaLdb = {
- .tp_name = "samba.Ldb",
+ .tp_name = "samba._ldb.Ldb",
.tp_doc = "Connection to a LDB database.",
.tp_methods = py_samba_ldb_methods,
.tp_flags = Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE,
};
-
void init_ldb(void)
{
PyObject *m;