summaryrefslogtreecommitdiff
path: root/source4/lib/gendb.c
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2005-06-15 17:15:01 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:18:14 -0500
commit4864c329c4633de2ccbefa7890651a92a5db0d4c (patch)
treeee0bc5cb5d8a84ce251495cc7671c7519185d73a /source4/lib/gendb.c
parent9378cca1aeda2f12a997cd6017d6d983a20e34bf (diff)
downloadsamba-4864c329c4633de2ccbefa7890651a92a5db0d4c.tar.gz
samba-4864c329c4633de2ccbefa7890651a92a5db0d4c.tar.bz2
samba-4864c329c4633de2ccbefa7890651a92a5db0d4c.zip
r7615: fix the build and simplify gendb_search_dn
(This used to be commit b38bb63175ae0bdcf833c017e5fbbfc2c0769506)
Diffstat (limited to 'source4/lib/gendb.c')
-rw-r--r--source4/lib/gendb.c43
1 files changed, 15 insertions, 28 deletions
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