s4-dsdb: update replPropertyMetaData on linked attribute source attributes
authorAndrew Tridgell <tridge@samba.org>
Sat, 26 Sep 2009 03:38:20 +0000 (20:38 -0700)
committerAndrew Tridgell <tridge@samba.org>
Mon, 28 Sep 2009 00:25:17 +0000 (10:25 +1000)
source4/dsdb/samdb/ldb_modules/repl_meta_data.c

index df5ae1a1c69f97854a4597cc7069d34f8ed0ba4a..253596ddeac5cca053eb0b76a6b09840470f1796 100644 (file)
@@ -2080,6 +2080,7 @@ static int replmd_process_linked_attribute(struct ldb_module *module,
        int ret;
        const struct dsdb_attribute *attr;
        struct ldb_dn *target_dn;
+       uint64_t seq_num = 0;
 
 /*
 linked_attributes[0]:                                                     
@@ -2186,6 +2187,28 @@ linked_attributes[0]:
        ret_el->values[0].data = (uint8_t *)ldb_dn_get_extended_linearized(tmp_ctx, target_dn, 1);
        ret_el->values[0].length = strlen((char *)ret_el->values[0].data);
 
+       ret = replmd_update_rpmd(module, msg, &seq_num);
+       if (ret != LDB_SUCCESS) {
+               talloc_free(tmp_ctx);
+               return ret;
+       }
+
+       /* we only change whenChanged and uSNChanged if the seq_num
+          has changed */
+       if (seq_num != 0) {
+               time_t t = time(NULL);
+
+               if (add_time_element(msg, "whenChanged", t) != LDB_SUCCESS) {
+                       talloc_free(tmp_ctx);
+                       return LDB_ERR_OPERATIONS_ERROR;
+               }
+
+               if (add_uint64_element(msg, "uSNChanged", seq_num) != LDB_SUCCESS) {
+                       talloc_free(tmp_ctx);
+                       return LDB_ERR_OPERATIONS_ERROR;
+               }
+       }
+
        ret = ldb_build_mod_req(&mod_req, ldb, tmp_ctx,
                                msg,
                                NULL,