summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/common/ldb_modules.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-10-06 05:24:46 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:39:26 -0500
commit5fd031c97daaa1bf09a7ad80550753acd434075f (patch)
tree8221ef256c17f138b11d22d9da26ae95db5618c4 /source4/lib/ldb/common/ldb_modules.c
parent92da5aa6b8d5141b22d781442583c9f3ad94d3af (diff)
downloadsamba-5fd031c97daaa1bf09a7ad80550753acd434075f.tar.gz
samba-5fd031c97daaa1bf09a7ad80550753acd434075f.tar.bz2
samba-5fd031c97daaa1bf09a7ad80550753acd434075f.zip
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)
Diffstat (limited to 'source4/lib/ldb/common/ldb_modules.c')
-rw-r--r--source4/lib/ldb/common/ldb_modules.c34
1 files changed, 22 insertions, 12 deletions
diff --git a/source4/lib/ldb/common/ldb_modules.c b/source4/lib/ldb/common/ldb_modules.c
index 9c536789b9..2885d46b37 100644
--- a/source4/lib/ldb/common/ldb_modules.c
+++ b/source4/lib/ldb/common/ldb_modules.c
@@ -133,6 +133,7 @@ int ldb_load_modules(struct ldb_context *ldb, const char *options[])
{ "objectguid", objectguid_module_init },
{ "samldb", samldb_module_init },
{ "samba3sam", ldb_samba3sam_module_init },
+ { "proxy", proxy_module_init },
#endif
{ NULL, NULL }
};
@@ -170,7 +171,7 @@ int ldb_load_modules(struct ldb_context *ldb, const char *options[])
return -1;
}
if (ret > 1) {
- ldb_debug(ldb, LDB_DEBUG_FATAL, "Too many records found, bailing out\n");
+ ldb_debug(ldb, LDB_DEBUG_FATAL, "Too many records found (%d), bailing out\n", ret);
talloc_free(msg);
return -1;
}
@@ -215,6 +216,17 @@ int ldb_load_modules(struct ldb_context *ldb, const char *options[])
/*
helper functions to call the next module in chain
*/
+int ldb_next_search_bytree(struct ldb_module *module,
+ const struct ldb_dn *base,
+ enum ldb_scope scope,
+ struct ldb_parse_tree *tree,
+ const char * const *attrs, struct ldb_message ***res)
+{
+ if (!module->next) {
+ return -1;
+ }
+ return module->next->ops->search_bytree(module->next, base, scope, tree, attrs, res);
+}
int ldb_next_search(struct ldb_module *module,
const struct ldb_dn *base,
@@ -222,24 +234,22 @@ int ldb_next_search(struct ldb_module *module,
const char *expression,
const char * const *attrs, struct ldb_message ***res)
{
+ struct ldb_parse_tree *tree;
+ int ret;
if (!module->next) {
return -1;
}
- return module->next->ops->search(module->next, base, scope, expression, attrs, res);
-}
-
-int ldb_next_search_bytree(struct ldb_module *module,
- const struct ldb_dn *base,
- enum ldb_scope scope,
- struct ldb_parse_tree *tree,
- const char * const *attrs, struct ldb_message ***res)
-{
- if (!module->next) {
+ tree = ldb_parse_tree(module, expression);
+ if (tree == NULL) {
+ ldb_set_errstring(module, talloc_strdup(module, "Unable to parse search expression"));
return -1;
}
- return module->next->ops->search_bytree(module->next, base, scope, tree, attrs, res);
+ ret = module->next->ops->search_bytree(module->next, base, scope, tree, attrs, res);
+ talloc_free(tree);
+ return ret;
}
+
int ldb_next_add_record(struct ldb_module *module, const struct ldb_message *message)
{
if (!module->next) {