svn commit: samba r17542 - in branches/SAMBA_4_0/source/lib/ldb/modules: .

abartlet at samba.org abartlet at samba.org
Mon Aug 14 23:25:05 GMT 2006


Author: abartlet
Date: 2006-08-14 23:25:04 +0000 (Mon, 14 Aug 2006)
New Revision: 17542

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=17542

Log:
In using ldb_map, I ran across some very odd behaviours when we search
for objectClass=xyz.  The code has been warning at me 'no
covert_operator set', and indeed this is the case.  (It then proceeds to
strip this as a search expression)

In this commit, I have implemented a convert_operator for objectClass,
by pretending it is a simple MAP_CONVERT operator for the search
requests.

I also have changed the logic for when we should bail out.  I can only
see reason to bail out on the search if we have both local and remote
trees.  How can a remote-only search be un-splittable?

Andrew Bartlett


Modified:
   branches/SAMBA_4_0/source/lib/ldb/modules/ldb_map.c
   branches/SAMBA_4_0/source/lib/ldb/modules/ldb_map.h
   branches/SAMBA_4_0/source/lib/ldb/modules/ldb_map_outbound.c
   branches/SAMBA_4_0/source/lib/ldb/modules/ldb_map_private.h


Changeset:
Modified: branches/SAMBA_4_0/source/lib/ldb/modules/ldb_map.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/modules/ldb_map.c	2006-08-14 16:53:14 UTC (rev 17541)
+++ branches/SAMBA_4_0/source/lib/ldb/modules/ldb_map.c	2006-08-14 23:25:04 UTC (rev 17542)
@@ -798,7 +798,27 @@
 	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 @@
 	{
 		.local_name = "objectclass",
 		.type = MAP_GENERATE,
+		.convert_operator = map_objectclass_convert_operator,
 		.u = {
 			.generate = {
 				 .remote_names = { "objectclass", NULL },

Modified: branches/SAMBA_4_0/source/lib/ldb/modules/ldb_map.h
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/modules/ldb_map.h	2006-08-14 16:53:14 UTC (rev 17541)
+++ branches/SAMBA_4_0/source/lib/ldb/modules/ldb_map.h	2006-08-14 23:25:04 UTC (rev 17542)
@@ -68,7 +68,7 @@
 	} 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 {

Modified: branches/SAMBA_4_0/source/lib/ldb/modules/ldb_map_outbound.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/modules/ldb_map_outbound.c	2006-08-14 16:53:14 UTC (rev 17541)
+++ branches/SAMBA_4_0/source/lib/ldb/modules/ldb_map_outbound.c	2006-08-14 23:25:04 UTC (rev 17542)
@@ -679,7 +679,7 @@
 }
 
 /* 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 @@
 
 	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 @@
 		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;

Modified: branches/SAMBA_4_0/source/lib/ldb/modules/ldb_map_private.h
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/modules/ldb_map_private.h	2006-08-14 16:53:14 UTC (rev 17541)
+++ branches/SAMBA_4_0/source/lib/ldb/modules/ldb_map_private.h	2006-08-14 23:25:04 UTC (rev 17542)
@@ -92,6 +92,7 @@
 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
  * ============ */



More information about the samba-cvs mailing list