diff options
author | Matthieu Patou <mat@matws.net> | 2011-05-24 01:30:15 +0400 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2011-07-21 11:44:34 +1000 |
commit | 521556ceed19fdba534e05859b7372c2422c7d98 (patch) | |
tree | 3237f08f2fe5a8fddcb392d7eee4c06acffd75e7 /lib | |
parent | 930fa1ee46c8c129a31639ca2eb73be28ae6d0dd (diff) | |
download | samba-521556ceed19fdba534e05859b7372c2422c7d98.tar.gz samba-521556ceed19fdba534e05859b7372c2422c7d98.tar.bz2 samba-521556ceed19fdba534e05859b7372c2422c7d98.zip |
ldb-python: add a function to Dn object to compare the Dn with a base DN
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ldb/pyldb.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/ldb/pyldb.c b/lib/ldb/pyldb.c index e2a2e7180e..4c71569f05 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)." }, |