summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
Diffstat (limited to 'source4')
-rw-r--r--source4/dsdb/samdb/samdb.c4
-rw-r--r--source4/lib/gendb.c43
-rwxr-xr-xsource4/lib/ldb/tests/test-generic.sh2
3 files changed, 18 insertions, 31 deletions
diff --git a/source4/dsdb/samdb/samdb.c b/source4/dsdb/samdb/samdb.c
index 642cff1a7a..0cbb141d40 100644
--- a/source4/dsdb/samdb/samdb.c
+++ b/source4/dsdb/samdb/samdb.c
@@ -52,8 +52,8 @@ int samdb_search_domain(struct ldb_context *sam_ldb,
int i, count;
va_start(ap, format);
- count = gendb_search_v(sam_ldb, mem_ctx, basedn, res, attrs,
- format, ap);
+ count = gendb_search_v(sam_ldb, mem_ctx, basedn,
+ res, attrs, format, ap);
va_end(ap);
i=0;
diff --git a/source4/lib/gendb.c b/source4/lib/gendb.c
index dc5b7f39aa..de3e49e652 100644
--- a/source4/lib/gendb.c
+++ b/source4/lib/gendb.c
@@ -35,22 +35,27 @@ int gendb_search_v(struct ldb_context *ldb,
const char *format,
va_list ap) _PRINTF_ATTRIBUTE(6,0)
{
+ enum ldb_scope scope = LDB_SCOPE_SUBTREE;
char *expr = NULL;
int count;
- vasprintf(&expr, format, ap);
- if (expr == NULL) {
- return -1;
+ if (format) {
+ vasprintf(&expr, format, ap);
+ if (expr == NULL) {
+ return -1;
+ }
+ } else {
+ scope = LDB_SCOPE_BASE;
}
*res = NULL;
- count = ldb_search(ldb, basedn, LDB_SCOPE_SUBTREE, expr, attrs, res);
+ count = ldb_search(ldb, basedn, scope, expr, attrs, res);
if (*res) talloc_steal(mem_ctx, *res);
DEBUG(4,("gendb_search_v: %s %s -> %d (%s)\n",
- basedn?basedn:"NULL", expr, count,
+ basedn?basedn:"NULL", expr?expr:"NULL", count,
count==-1?ldb_errstring(ldb):"OK"));
free(expr);
@@ -79,31 +84,13 @@ int gendb_search(struct ldb_context *ldb,
}
int gendb_search_dn(struct ldb_context *ldb,
- TALLOC_CTX *mem_ctx,
- const char *dn,
- struct ldb_message ***res,
- const char * const *attrs)
+ TALLOC_CTX *mem_ctx,
+ const char *dn,
+ struct ldb_message ***res,
+ const char * const *attrs)
{
- va_list ap;
- int count;
-
- *res = NULL;
-
- count = ldb_search(ldb, dn, LDB_SCOPE_BASE, "", attrs, res);
-
- if (count > 1) {
- DEBUG(1, ("DB Corruption ? - Found more then one entry for dn: %s", dn));
- return -1;
- }
-
- if (*res) talloc_steal(mem_ctx, *res);
-
- DEBUG(4,("gendb_search_dn: %s -> %d (%s)\n",
- dn, count, count==-1?ldb_errstring(ldb):"OK"));
-
- return count;
+ return gendb_search(ldb, mem_ctx, dn, res, attrs, NULL);
}
-
/*
setup some initial ldif in a ldb
diff --git a/source4/lib/ldb/tests/test-generic.sh b/source4/lib/ldb/tests/test-generic.sh
index 7b5c24512e..7b82c672be 100755
--- a/source4/lib/ldb/tests/test-generic.sh
+++ b/source4/lib/ldb/tests/test-generic.sh
@@ -39,7 +39,7 @@ $VALGRIND bin/ldbsearch '(&(objectclass=person)(uid=uham)(!(uid=uhamxx)))' uid \
$VALGRIND bin/ldbsearch '(&(uid=uham)(uid=uha*)(title=*))' uid || exit 1
$VALGRIND bin/ldbsearch '((' uid && exit 1
$VALGRIND bin/ldbsearch '(objectclass=)' uid || exit 1
-$VALGRIND bin/ldbsearch 'dn=cn=Hampster Ursula,ou=Alumni Association,ou=People,o=University of Michigan,c=US' uid || exit 1
+$VALGRIND bin/ldbsearch -b 'cn=Hampster Ursula,ou=Alumni Association,ou=People,o=University of Michigan,c=US' -s base "" sn || exit 1
echo "Starting ldbtest indexed"
time $VALGRIND bin/ldbtest -r 1000 -s 5000 || exit 1