bool initialize_password_db(bool reload, struct tevent_context *tevent_ctx)
{
- pdb_tevent_ctx = tevent_ctx;
+ if (tevent_ctx) {
+ pdb_tevent_ctx = tevent_ctx;
+ }
return (pdb_get_methods_reload(reload) != NULL);
}
-
/***************************************************************************
Default implementations of some functions.
****************************************************************************/
return NULL;
}
+ talloc_free(frame);
Py_RETURN_NONE;
+}
+
+static PyObject *py_reload_static_pdb(PyObject *self, PyObject *args)
+{
+ TALLOC_CTX *frame = talloc_stackframe();
+
+ /* Initialize secrets database */
+ if (!initialize_password_db(true, NULL)) {
+ PyErr_Format(py_pdb_error, "Cannot re-open passdb backend %s", lp_passdb_backend());
+ talloc_free(frame);
+ return NULL;
+ }
+
talloc_free(frame);
+ Py_RETURN_NONE;
}
static PyObject *py_get_global_sam_sid(PyObject *self)
{ "get_global_sam_sid", (PyCFunction)py_get_global_sam_sid, METH_NOARGS,
"get_global_sam_sid() -> dom_sid\n\n \
Return domain SID." },
+ { "reload_static_pdb", (PyCFunction)py_reload_static_pdb, METH_NOARGS,
+ "reload_static_pdb() -> None\n\n \
+ Re-initalise the static pdb used internally. Needed if 'passdb backend' is changed." },
{ NULL },
};
s3conf.load(lp.configfile)
# ensure we are using the right samba4 passdb backend, no matter what
s3conf.set("passdb backend", "samba4:%s" % samdb.url)
+ passdb.reload_static_pdb()
+
# ensure that we init the samba4 backend, so the domain sid is marked in secrets.tdb
s4_passdb = passdb.PDB(s3conf.get("passdb backend"))