s4-pydsdb: expose samdb_partitions_dn() as get_partitions_dn() in python
authorAndrew Tridgell <tridge@samba.org>
Thu, 9 Sep 2010 07:34:55 +0000 (17:34 +1000)
committerAndrew Tridgell <tridge@samba.org>
Thu, 9 Sep 2010 11:39:24 +0000 (21:39 +1000)
Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>

source4/dsdb/pydsdb.c
source4/scripting/python/samba/samdb.py

index ecf89b1d8c6eececed056a2635414e82bfa824a8..5ba69d73884ba3592f459732948a307cba3aa3f4 100644 (file)
@@ -505,6 +505,35 @@ static PyObject *py_dsdb_write_prefixes_from_schema_to_ldb(PyObject *self, PyObj
 }
 
 
+static PyObject *py_dsdb_get_partitions_dn(PyObject *self, PyObject *args)
+{
+       struct ldb_context *ldb;
+       struct ldb_dn *dn;
+       PyObject *py_ldb, *ret;
+       TALLOC_CTX *tmp_ctx;
+       PyObject *mod;
+
+       mod = PyImport_ImportModule("ldb");
+
+       if (!PyArg_ParseTuple(args, "O", &py_ldb))
+               return NULL;
+
+       PyErr_LDB_OR_RAISE(py_ldb, ldb);
+
+       tmp_ctx = talloc_new(NULL);
+
+       dn = samdb_partitions_dn(ldb, tmp_ctx);
+
+       if (dn == NULL) {
+               talloc_free(tmp_ctx);
+               Py_RETURN_NONE;
+       }
+       ret = PyLdbDn_FromDn(dn);
+       talloc_free(tmp_ctx);
+       return ret;
+}
+
+
 
 static PyMethodDef py_dsdb_methods[] = {
        { "_samdb_server_site_name", (PyCFunction)py_samdb_server_site_name,
@@ -550,6 +579,7 @@ static PyMethodDef py_dsdb_methods[] = {
                NULL },
        { "_dsdb_write_prefixes_from_schema_to_ldb", (PyCFunction)py_dsdb_write_prefixes_from_schema_to_ldb, METH_VARARGS,
                NULL },
+       { "_dsdb_get_partitions_dn", (PyCFunction)py_dsdb_get_partitions_dn, METH_VARARGS, NULL },
        { NULL }
 };
 
index cc82e53907b93d12d2ccade1874e45dc09b5eba0..e2ac37a24024c95a5ee70da5a417c454c13dccb7 100644 (file)
@@ -595,3 +595,6 @@ accountExpires: %u
 
     def write_prefixes_from_schema(self):
         dsdb._dsdb_write_prefixes_from_schema_to_ldb(self)
+
+    def get_partitions_dn(self):
+        return dsdb._dsdb_get_partitions_dn(self)