diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ldb/pyldb.c | 15 | ||||
-rwxr-xr-x | lib/ldb/tests/python/api.py | 5 |
2 files changed, 20 insertions, 0 deletions
diff --git a/lib/ldb/pyldb.c b/lib/ldb/pyldb.c index 9c8a70b529..8c9d6b9599 100644 --- a/lib/ldb/pyldb.c +++ b/lib/ldb/pyldb.c @@ -529,6 +529,18 @@ static PyObject *py_ldb_dn_add_base(PyLdbDnObject *self, PyObject *args) return ldb_dn_add_base(dn, other)?Py_True:Py_False; } +static PyObject *py_ldb_dn_remove_base_components(PyLdbDnObject *self, PyObject *args) +{ + struct ldb_dn *dn; + int i; + if (!PyArg_ParseTuple(args, "i", &i)) + return NULL; + + dn = pyldb_Dn_AsDn((PyObject *)self); + + return ldb_dn_remove_base_components(dn, i)?Py_True:Py_False; +} + static PyObject *py_ldb_dn_is_child_of(PyLdbDnObject *self, PyObject *args) { PyObject *py_base; @@ -579,6 +591,9 @@ static PyMethodDef py_ldb_dn_methods[] = { { "add_base", (PyCFunction)py_ldb_dn_add_base, METH_VARARGS, "S.add_base(dn) -> None\n" "Add a base DN to this DN." }, + { "remove_base_components", (PyCFunction)py_ldb_dn_remove_base_components, METH_VARARGS, + "S.remove_base_components(int) -> bool\n" + "Remove a number of DN components from the base of this DN." }, { "check_special", (PyCFunction)py_ldb_dn_check_special, METH_VARARGS, "S.check_special(name) -> bool\n\n" "Check if name is a special DN name"}, diff --git a/lib/ldb/tests/python/api.py b/lib/ldb/tests/python/api.py index d04d0cc5ed..7df40e4a5a 100755 --- a/lib/ldb/tests/python/api.py +++ b/lib/ldb/tests/python/api.py @@ -416,6 +416,11 @@ class DnTests(TestCase): y = ldb.Dn(self.ldb, "bar=bla") self.assertEquals("dc=foo24,bar=bla", str(x + y)) + def test_remove_base_components(self): + x = ldb.Dn(self.ldb, "dc=foo24,dc=samba,dc=org") + x.remove_base_components(len(x)-1) + self.assertEquals("dc=foo24", str(x)) + def test_parse_ldif(self): msgs = self.ldb.parse_ldif("dn: foo=bar\n") msg = msgs.next() |