add the partition_control control to replication requests
authorAndrew Tridgell <tridge@samba.org>
Wed, 2 Sep 2009 06:55:57 +0000 (16:55 +1000)
committerAndrew Tridgell <tridge@samba.org>
Wed, 2 Sep 2009 08:19:55 +0000 (18:19 +1000)
We know the partition DN from the DRS objects, we need to pass this
down the modules below us to ensure they operate on the right
partition

source4/dsdb/samdb/ldb_modules/repl_meta_data.c

index 4508882dd5ef0eaa7e7f1188210fb18c1ccec719..822bcb346807f7d687d24f6d7747909dcfa4e09d 100644 (file)
@@ -1423,6 +1423,7 @@ static int replmd_extended_replicated_objects(struct ldb_module *module, struct
        struct replmd_replicated_request *ar;
        struct ldb_control **ctrls;
        int ret;
+       struct dsdb_control_current_partition *partition_ctrl;
 
        ldb = ldb_module_get_ctx(module);
 
@@ -1465,6 +1466,27 @@ static int replmd_extended_replicated_objects(struct ldb_module *module, struct
                return ret;
        }
 
+       /*
+         add the DSDB_CONTROL_CURRENT_PARTITION_OID control. This
+         tells the partition module which partition this request is
+         directed at. That is important as the partition roots appear
+         twice in the directory, once as mount points in the top
+         level store, and once as the roots of each partition. The
+         replication code wants to operate on the root of the
+         partitions, not the top level mount points
+        */
+       partition_ctrl = talloc(req, struct dsdb_control_current_partition);
+       if (partition_ctrl == NULL) {
+               if (!partition_ctrl) return replmd_replicated_request_werror(ar, WERR_NOMEM);
+       }
+       partition_ctrl->version = DSDB_CONTROL_CURRENT_PARTITION_VERSION;
+       partition_ctrl->dn = objs->partition_dn;
+
+       ret = ldb_request_add_control(req, DSDB_CONTROL_CURRENT_PARTITION_OID, false, partition_ctrl);
+       if (ret != LDB_SUCCESS) {
+               return ret;
+       }
+
        ar->controls = req->controls;
        req->controls = ctrls;