summaryrefslogtreecommitdiff
path: root/source4/lib/gendb.c
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2005-11-08 00:11:45 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:45:53 -0500
commit5c9590587197dcb95007fdc54318187d5716c7c6 (patch)
treed5161aa628d8a4bc4f11bf849d76a451ff44522c /source4/lib/gendb.c
parent14b59bcbec1a288810efee5c9442dff30f1a474a (diff)
downloadsamba-5c9590587197dcb95007fdc54318187d5716c7c6.tar.gz
samba-5c9590587197dcb95007fdc54318187d5716c7c6.tar.bz2
samba-5c9590587197dcb95007fdc54318187d5716c7c6.zip
r11567: Ldb API change patch.
This patch changes the way lsb_search is called and the meaning of the returned integer. The last argument of ldb_search is changed from struct ldb_message to struct ldb_result which contains a pointer to a struct ldb_message list and a count of the number of messages. The return is not the count of messages anymore but instead it is an ldb error value. I tryed to keep the patch as tiny as possible bu as you can guess I had to change a good amount of places. I also tried to double check all my changes being sure that the calling functions would still behave as before. But this patch is big enough that I fear some bug may have been introduced anyway even if it passes the test suite. So if you are currently working on any file being touched please give it a deep look and blame me for any error. Simo. (This used to be commit 22c8c97e6fb466b41859e090e959d7f1134be780)
Diffstat (limited to 'source4/lib/gendb.c')
-rw-r--r--source4/lib/gendb.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/source4/lib/gendb.c b/source4/lib/gendb.c
index e0fb9662bb..0aeacbe701 100644
--- a/source4/lib/gendb.c
+++ b/source4/lib/gendb.c
@@ -23,6 +23,7 @@
#include "includes.h"
#include "lib/ldb/include/ldb.h"
+#include "lib/ldb/include/ldb_errors.h"
/*
search the sam for the specified attributes - va_list variant
@@ -30,14 +31,15 @@
int gendb_search_v(struct ldb_context *ldb,
TALLOC_CTX *mem_ctx,
const struct ldb_dn *basedn,
- struct ldb_message ***res,
+ struct ldb_message ***msgs,
const char * const *attrs,
const char *format,
va_list ap) _PRINTF_ATTRIBUTE(6,0)
{
enum ldb_scope scope = LDB_SCOPE_SUBTREE;
+ struct ldb_result *res;
char *expr = NULL;
- int count;
+ int ret;
if (format) {
vasprintf(&expr, format, ap);
@@ -48,20 +50,28 @@ int gendb_search_v(struct ldb_context *ldb,
scope = LDB_SCOPE_BASE;
}
- *res = NULL;
+ res = NULL;
+
+ ret = ldb_search(ldb, basedn, scope, expr, attrs, &res);
+
+ if (ret == LDB_SUCCESS) {
+ talloc_steal(mem_ctx, res);
- count = ldb_search(ldb, basedn, scope, expr, attrs, res);
+ DEBUG(4,("gendb_search_v: %s %s -> %d\n",
+ basedn?ldb_dn_linearize(mem_ctx,basedn):"NULL",
+ expr?expr:"NULL", res->count));
- if (*res) talloc_steal(mem_ctx, *res);
+ ret = res->count;
+ *msgs = res->msgs;
- DEBUG(4,("gendb_search_v: %s %s -> %d (%s)\n",
- basedn?ldb_dn_linearize(mem_ctx,basedn):"NULL",
- expr?expr:"NULL", count,
- count==-1?ldb_errstring(ldb):"OK"));
+ } else {
+ DEBUG(4,("gendb_search_v: search failed: %s", ldb_errstring(ldb)));
+ ret = -1;
+ }
free(expr);
- return count;
+ return ret;
}
/*