From ef4861d9263d1a17396c58abc7ad0c5837a1b52c Mon Sep 17 00:00:00 2001 From: Matthias Dieter Wallnöfer Date: Sat, 6 Nov 2010 17:49:18 +0100 Subject: ldb:pyldb.c - "py_ldb_contains" - return only "0" not found, "1" found, "-1" error --- source4/lib/ldb/pyldb.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'source4') 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 = { -- cgit