summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Dieter Wallnöfer <mdw@samba.org>2010-11-06 17:49:18 +0100
committerMatthias Dieter Wallnöfer <mdw@samba.org>2010-11-08 10:39:05 +0000
commitef4861d9263d1a17396c58abc7ad0c5837a1b52c (patch)
treea9207da3fb005b4f62864ee357ba47fc169f3a59
parent7bdbfc96037640dbd352e9ddab9c5e1ded9502fa (diff)
downloadsamba-ef4861d9263d1a17396c58abc7ad0c5837a1b52c.tar.gz
samba-ef4861d9263d1a17396c58abc7ad0c5837a1b52c.tar.bz2
samba-ef4861d9263d1a17396c58abc7ad0c5837a1b52c.zip
ldb:pyldb.c - "py_ldb_contains" - return only "0" not found, "1" found, "-1" error
-rw-r--r--source4/lib/ldb/pyldb.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/source4/lib/ldb/pyldb.c b/source4/lib/ldb/pyldb.c
index 2f87b8cdc3..40d7204c35 100644
--- a/source4/lib/ldb/pyldb.c
+++ b/source4/lib/ldb/pyldb.c
@@ -1425,13 +1425,14 @@ static int py_ldb_contains(PyLdbObject *self, PyObject *obj)
struct ldb_context *ldb_ctx = PyLdb_AsLdbContext(self);
struct ldb_dn *dn;
struct ldb_result *result;
+ unsigned int count;
int ret;
- int count;
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);
+ ret = ldb_search(ldb_ctx, ldb_ctx, &result, dn, LDB_SCOPE_BASE, NULL,
+ NULL);
if (ret != LDB_SUCCESS) {
PyErr_SetLdbError(PyExc_LdbError, ret, ldb_ctx);
return -1;
@@ -1441,7 +1442,13 @@ static int py_ldb_contains(PyLdbObject *self, PyObject *obj)
talloc_free(result);
- return count;
+ if (count == 1) {
+ return 1;
+ } else if (count == 0) {
+ return 0;
+ }
+
+ return -1;
}
static PySequenceMethods py_ldb_seq = {