diff options
author | Simo Sorce <idra@samba.org> | 2005-06-15 17:15:01 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:18:14 -0500 |
commit | 4864c329c4633de2ccbefa7890651a92a5db0d4c (patch) | |
tree | ee0bc5cb5d8a84ce251495cc7671c7519185d73a | |
parent | 9378cca1aeda2f12a997cd6017d6d983a20e34bf (diff) | |
download | samba-4864c329c4633de2ccbefa7890651a92a5db0d4c.tar.gz samba-4864c329c4633de2ccbefa7890651a92a5db0d4c.tar.xz samba-4864c329c4633de2ccbefa7890651a92a5db0d4c.zip |
r7615: fix the build and simplify gendb_search_dn
(This used to be commit b38bb63175ae0bdcf833c017e5fbbfc2c0769506)
-rw-r--r-- | source4/dsdb/samdb/samdb.c | 4 | ||||
-rw-r--r-- | source4/lib/gendb.c | 43 | ||||
-rwxr-xr-x | source4/lib/ldb/tests/test-generic.sh | 2 |
3 files changed, 18 insertions, 31 deletions
diff --git a/source4/dsdb/samdb/samdb.c b/source4/dsdb/samdb/samdb.c index 642cff1a7aa..0cbb141d40c 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 dc5b7f39aa6..de3e49e652b 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 7b5c24512e1..7b82c672be5 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 |