From 521556ceed19fdba534e05859b7372c2422c7d98 Mon Sep 17 00:00:00 2001 From: Matthieu Patou Date: Tue, 24 May 2011 01:30:15 +0400 Subject: [PATCH] ldb-python: add a function to Dn object to compare the Dn with a base DN --- lib/ldb/pyldb.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/ldb/pyldb.c b/lib/ldb/pyldb.c index e2a2e7180e1..4c71569f052 100644 --- a/lib/ldb/pyldb.c +++ b/lib/ldb/pyldb.c @@ -522,6 +522,21 @@ 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_compare_base(PyLdbDnObject *self, PyObject *args) +{ + PyObject *py_base; + struct ldb_dn *dn, *base; + if (!PyArg_ParseTuple(args, "O", &py_base)) + return NULL; + + dn = PyLdbDn_AsDn((PyObject *)self); + + if (!PyObject_AsDn(NULL, py_base, dn_ldb_ctx(dn), &base)) + return NULL; + + return PyInt_FromLong(ldb_dn_compare_base(base, dn)); +} + static PyMethodDef py_ldb_dn_methods[] = { { "validate", (PyCFunction)py_ldb_dn_validate, METH_NOARGS, "S.validate() -> bool\n" @@ -540,6 +555,8 @@ static PyMethodDef py_ldb_dn_methods[] = { { "canonical_str", (PyCFunction)py_ldb_dn_canonical_str, METH_NOARGS, "S.canonical_str() -> string\n" "Canonical version of this DN (like a posix path)." }, + { "compare_base", (PyCFunction)py_ldb_dn_compare_base, METH_VARARGS, + "S.compare_base(basedn) -> int\n\n"}, { "canonical_ex_str", (PyCFunction)py_ldb_dn_canonical_ex_str, METH_NOARGS, "S.canonical_ex_str() -> string\n" "Canonical version of this DN (like a posix path, with terminating newline)." }, -- 2.34.1