From 5fd031c97daaa1bf09a7ad80550753acd434075f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 6 Oct 2005 05:24:46 +0000 Subject: r10753: don't require every ldb module to implement both a search_bytree() and a search() function, instead each module now only implements the bytree method, and the expression based search is handled generically by the modules code. This makes for more consistency and less code duplication. fixed the tdb backend to handle BASE searches much more efficiently. They now always only lookup one record, regardless of the search expression (This used to be commit 7e44f9153c5578624e2fca04cdc0a00af0fd9eb4) --- source4/lib/ldb/common/ldb.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'source4/lib/ldb/common/ldb.c') diff --git a/source4/lib/ldb/common/ldb.c b/source4/lib/ldb/common/ldb.c index a743b2f584..29ee323ad4 100644 --- a/source4/lib/ldb/common/ldb.c +++ b/source4/lib/ldb/common/ldb.c @@ -172,13 +172,23 @@ int ldb_search(struct ldb_context *ldb, const char *expression, const char * const *attrs, struct ldb_message ***res) { - ldb_reset_err_string(ldb); + struct ldb_parse_tree *tree; + int ret; + + tree = ldb_parse_tree(ldb, expression); + if (tree == NULL) { + ldb_set_errstring(ldb->modules, talloc_strdup(ldb, "Unable to parse search expression")); + return -1; + } + + ret = ldb_search_bytree(ldb, base, scope, tree, attrs, res); + talloc_free(tree); - return ldb->modules->ops->search(ldb->modules, base, scope, expression, attrs, res); + return ret; } /* - search the database given a LDAP-like search expression + search the database given a search tree return the number of records found, or -1 on error -- cgit