summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/common
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib/ldb/common')
-rw-r--r--source4/lib/ldb/common/ldb.c16
-rw-r--r--source4/lib/ldb/common/ldb_modules.c34
-rw-r--r--source4/lib/ldb/common/ldb_parse.c5
3 files changed, 37 insertions, 18 deletions
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
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) {
diff --git a/source4/lib/ldb/common/ldb_parse.c b/source4/lib/ldb/common/ldb_parse.c
index f43d7a7c7a..95110bfd00 100644
--- a/source4/lib/ldb/common/ldb_parse.c
+++ b/source4/lib/ldb/common/ldb_parse.c
@@ -620,9 +620,8 @@ static struct ldb_parse_tree *ldb_parse_filter(void *mem_ctx, const char **s)
*/
struct ldb_parse_tree *ldb_parse_tree(void *mem_ctx, const char *s)
{
- /* allowing NULL makes the _bytree() searches easier */
- if (s == NULL) {
- return NULL;
+ if (s == NULL || *s == 0) {
+ s = "(|(objectClass=*)(dn=*))";
}
while (isspace((unsigned char)*s)) s++;