summaryrefslogtreecommitdiff
path: root/source4/dsdb
diff options
context:
space:
mode:
Diffstat (limited to 'source4/dsdb')
-rw-r--r--source4/dsdb/config.mk2
-rw-r--r--source4/dsdb/pydsdb.c49
-rw-r--r--source4/dsdb/wscript_build2
3 files changed, 51 insertions, 2 deletions
diff --git a/source4/dsdb/config.mk b/source4/dsdb/config.mk
index 69b7227d62..2bd19e987d 100644
--- a/source4/dsdb/config.mk
+++ b/source4/dsdb/config.mk
@@ -109,6 +109,6 @@ DNS_UPDATE_SRV_OBJ_FILES = $(addprefix $(dsdbsrcdir)/dns/, \
[PYTHON::python_dsdb]
LIBRARY_REALNAME = samba/dsdb.$(SHLIBEXT)
-PRIVATE_DEPENDENCIES = SAMDB
+PRIVATE_DEPENDENCIES = SAMDB pyldb
python_dsdb_OBJ_FILES = $(dsdbsrcdir)/pydsdb.o
diff --git a/source4/dsdb/pydsdb.c b/source4/dsdb/pydsdb.c
index cc75472a45..1d71c6b7de 100644
--- a/source4/dsdb/pydsdb.c
+++ b/source4/dsdb/pydsdb.c
@@ -251,6 +251,52 @@ static PyObject *py_dsdb_set_global_schema(PyObject *self, PyObject *args)
Py_RETURN_NONE;
}
+static PyObject *py_dsdb_load_partition_usn(PyObject *self, PyObject *args)
+{
+ PyObject *py_dn, *py_ldb, *result;
+ struct ldb_dn *dn;
+ uint64_t highest_uSN, urgent_uSN;
+ struct ldb_context *ldb;
+ TALLOC_CTX *mem_ctx;
+ int ret;
+
+ mem_ctx = talloc_new(NULL);
+ if (mem_ctx == NULL) {
+ PyErr_NoMemory();
+ return NULL;
+ }
+
+ if (!PyArg_ParseTuple(args, "OO", &py_ldb, &py_dn)) {
+ talloc_free(mem_ctx);
+ return NULL;
+ }
+
+ PyErr_LDB_OR_RAISE(py_ldb, ldb);
+
+ if (!PyObject_AsDn(mem_ctx, py_dn, ldb, &dn)) {
+ talloc_free(mem_ctx);
+ return NULL;
+ }
+
+ ret = dsdb_load_partition_usn(ldb, dn, &highest_uSN, &urgent_uSN);
+ if (ret != LDB_SUCCESS) {
+ char *errstr = talloc_asprintf(mem_ctx, "Failed to load partition uSN - %s", ldb_errstring(ldb));
+ PyErr_SetString(PyExc_RuntimeError, errstr);
+ talloc_free(mem_ctx);
+ return NULL;
+ }
+
+ talloc_free(mem_ctx);
+
+ result = PyDict_New();
+
+ PyDict_SetItemString(result, "uSNHighest", PyInt_FromLong((uint64_t)highest_uSN));
+ PyDict_SetItemString(result, "uSNUrgent", PyInt_FromLong((uint64_t)urgent_uSN));
+
+
+ return result;
+}
+
static PyMethodDef py_dsdb_methods[] = {
{ "samdb_server_site_name", (PyCFunction)py_samdb_server_site_name,
METH_VARARGS, "Get the server site name as a string"},
@@ -275,6 +321,9 @@ static PyMethodDef py_dsdb_methods[] = {
METH_VARARGS, "get the NTDS objectGUID as a string"},
{ "dsdb_set_global_schema", (PyCFunction)py_dsdb_set_global_schema,
METH_VARARGS, NULL },
+ { "dsdb_load_partition_usn", (PyCFunction)py_dsdb_load_partition_usn,
+ METH_VARARGS,
+ "get uSNHighest and uSNUrgent from the partition @REPLCHANGED"},
{ NULL }
};
diff --git a/source4/dsdb/wscript_build b/source4/dsdb/wscript_build
index 581c8ef4d0..59672e03df 100644
--- a/source4/dsdb/wscript_build
+++ b/source4/dsdb/wscript_build
@@ -51,6 +51,6 @@ bld.SAMBA_MODULE('DNS_UPDATE_SRV',
bld.SAMBA_PYTHON('python_dsdb',
source='pydsdb.c',
- deps='SAMDB',
+ deps='SAMDB pyldb',
realname='samba/dsdb.so'
)