summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/ldb/modules/ldb_map.c21
-rw-r--r--source4/lib/ldb/modules/ldb_map.h2
-rw-r--r--source4/lib/ldb/modules/ldb_map_outbound.c7
-rw-r--r--source4/lib/ldb/modules/ldb_map_private.h1
4 files changed, 26 insertions, 5 deletions
diff --git a/source4/lib/ldb/modules/ldb_map.c b/source4/lib/ldb/modules/ldb_map.c
index cdb9f5b4a9..8eff612d1b 100644
--- a/source4/lib/ldb/modules/ldb_map.c
+++ b/source4/lib/ldb/modules/ldb_map.c
@@ -798,7 +798,27 @@ static struct ldb_message_element *map_objectclass_generate_local(struct ldb_mod
return el;
}
+/* Mappings for searches on objectClass= assuming a one-to-one
+ * mapping. Needed because this is a generate operator for the
+ * add/modify code */
+static int map_objectclass_convert_operator(struct ldb_module *module, void *mem_ctx,
+ struct ldb_parse_tree **new, const struct ldb_parse_tree *tree)
+{
+
+ static const struct ldb_map_attribute objectclass_map = {
+ .local_name = "objectclass",
+ .type = MAP_CONVERT,
+ .u = {
+ .convert = {
+ .remote_name = "objectclass",
+ .convert_local = map_objectclass_convert_local,
+ .convert_remote = map_objectclass_convert_remote,
+ },
+ },
+ };
+ return map_subtree_collect_remote_simple(module, mem_ctx, new, tree, &objectclass_map);
+}
/* Auxiliary request construction
* ============================== */
@@ -1142,6 +1162,7 @@ static const struct ldb_map_attribute builtin_attribute_maps[] = {
{
.local_name = "objectclass",
.type = MAP_GENERATE,
+ .convert_operator = map_objectclass_convert_operator,
.u = {
.generate = {
.remote_names = { "objectclass", NULL },
diff --git a/source4/lib/ldb/modules/ldb_map.h b/source4/lib/ldb/modules/ldb_map.h
index f9e2086ee1..99231e61f1 100644
--- a/source4/lib/ldb/modules/ldb_map.h
+++ b/source4/lib/ldb/modules/ldb_map.h
@@ -68,7 +68,7 @@ struct ldb_map_attribute {
} type;
/* if set, will be called for search expressions that contain this attribute */
- struct ldb_parse_tree *(*convert_operator)(const struct ldb_map_context *, TALLOC_CTX *ctx, const struct ldb_parse_tree *);
+ int (*convert_operator)(struct ldb_module *, TALLOC_CTX *ctx, struct ldb_parse_tree **new, const struct ldb_parse_tree *);
union {
struct {
diff --git a/source4/lib/ldb/modules/ldb_map_outbound.c b/source4/lib/ldb/modules/ldb_map_outbound.c
index 046c92bb99..229299288c 100644
--- a/source4/lib/ldb/modules/ldb_map_outbound.c
+++ b/source4/lib/ldb/modules/ldb_map_outbound.c
@@ -679,7 +679,7 @@ static int map_subtree_collect_remote_list(struct ldb_module *module, void *mem_
}
/* Collect a simple subtree that queries attributes in the remote partition */
-static int map_subtree_collect_remote_simple(struct ldb_module *module, void *mem_ctx, struct ldb_parse_tree **new, const struct ldb_parse_tree *tree, const struct ldb_map_attribute *map)
+int map_subtree_collect_remote_simple(struct ldb_module *module, void *mem_ctx, struct ldb_parse_tree **new, const struct ldb_parse_tree *tree, const struct ldb_map_attribute *map)
{
const char *attr;
struct ldb_val val;
@@ -757,8 +757,7 @@ static int map_subtree_collect_remote(struct ldb_module *module, void *mem_ctx,
map = map_attr_find_local(data, tree->u.equality.attr);
if (map->convert_operator) {
- *new = map->convert_operator(data, mem_ctx, tree);
- return 0;
+ return map->convert_operator(module, mem_ctx, new, tree);
}
if (map->type == MAP_GENERATE) {
@@ -1084,7 +1083,7 @@ int map_search(struct ldb_module *module, struct ldb_request *req)
goto failed;
}
- if (((local_tree == NULL) ^ (remote_tree == NULL)) &&
+ if (((local_tree != NULL) && (remote_tree != NULL)) &&
(!ldb_parse_tree_check_splittable(req->op.search.tree))) {
/* The query can't safely be split, enumerate the remote partition */
local_tree = NULL;
diff --git a/source4/lib/ldb/modules/ldb_map_private.h b/source4/lib/ldb/modules/ldb_map_private.h
index 1b21fcf558..89d0fe0afe 100644
--- a/source4/lib/ldb/modules/ldb_map_private.h
+++ b/source4/lib/ldb/modules/ldb_map_private.h
@@ -92,6 +92,7 @@ struct ldb_request *map_search_base_req(struct map_context *ac, const struct ldb
struct ldb_request *map_search_self_req(struct map_context *ac, const struct ldb_dn *dn);
struct ldb_request *map_build_fixup_req(struct map_context *ac, const struct ldb_dn *olddn, const struct ldb_dn *newdn);
+int map_subtree_collect_remote_simple(struct ldb_module *module, void *mem_ctx, struct ldb_parse_tree **new, const struct ldb_parse_tree *tree, const struct ldb_map_attribute *map);
/* LDB Requests
* ============ */