summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/ldb/pyldb.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/source4/lib/ldb/pyldb.c b/source4/lib/ldb/pyldb.c
index eddc56f777..1f5bd1e58d 100644
--- a/source4/lib/ldb/pyldb.c
+++ b/source4/lib/ldb/pyldb.c
@@ -1428,8 +1428,9 @@ static int py_ldb_contains(PyLdbObject *self, PyObject *obj)
unsigned int count;
int ret;
- if (!PyObject_AsDn(ldb_ctx, obj, ldb_ctx, &dn))
+ if (!PyObject_AsDn(ldb_ctx, obj, ldb_ctx, &dn)) {
return -1;
+ }
ret = ldb_search(ldb_ctx, ldb_ctx, &result, dn, LDB_SCOPE_BASE, NULL,
NULL);
@@ -1442,11 +1443,15 @@ static int py_ldb_contains(PyLdbObject *self, PyObject *obj)
talloc_free(result);
- if (count == 0) {
- return 0;
+ if (count > 1) {
+ PyErr_Format(PyExc_RuntimeError,
+ "Searching for [%s] dn gave %u results!",
+ ldb_dn_get_linearized(dn),
+ count);
+ return -1;
}
- return 1;
+ return count;
}
static PySequenceMethods py_ldb_seq = {