From e30d009965a789e8a4495609f8d19adb621df6f4 Mon Sep 17 00:00:00 2001 From: Fernando J V da Silva Date: Thu, 7 Jan 2010 16:30:05 -0200 Subject: s4-drs: Store uSNUrgent for Urgent Replication When a object or attribute is created/updated/deleted, according to [MS-ADTS] 3.1.1.5.1.6, it stores the uSNUrgent on @REPLCHANGED for the partitions that it belongs. Signed-off-by: Andrew Tridgell --- source4/dsdb/common/util.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'source4/dsdb/common/util.c') diff --git a/source4/dsdb/common/util.c b/source4/dsdb/common/util.c index 652f1345d5..5dcbbd8d03 100644 --- a/source4/dsdb/common/util.c +++ b/source4/dsdb/common/util.c @@ -2655,10 +2655,11 @@ failed: /* - load the uSNHighest attribute from the @REPLCHANGED object for a - partition + load the uSNHighest and the uSNUrgent attributes from the @REPLCHANGED + object for a partition */ -int dsdb_load_partition_usn(struct ldb_context *ldb, struct ldb_dn *dn, uint64_t *uSN) +int dsdb_load_partition_usn(struct ldb_context *ldb, struct ldb_dn *dn, + uint64_t *uSN, uint64_t *urgent_uSN) { struct ldb_request *req; int ret; @@ -2723,8 +2724,14 @@ int dsdb_load_partition_usn(struct ldb_context *ldb, struct ldb_dn *dn, uint64_t if (res->count < 1) { *uSN = 0; + if (urgent_uSN) { + *urgent_uSN = 0; + } } else { *uSN = ldb_msg_find_attr_as_uint64(res->msgs[0], "uSNHighest", 0); + if (urgent_uSN) { + *urgent_uSN = ldb_msg_find_attr_as_uint64(res->msgs[0], "uSNUrgent", 0); + } } talloc_free(tmp_ctx); @@ -2733,10 +2740,11 @@ int dsdb_load_partition_usn(struct ldb_context *ldb, struct ldb_dn *dn, uint64_t } /* - save the uSNHighest attribute in the @REPLCHANGED object for a + save uSNHighest and uSNUrgent attributes in the @REPLCHANGED object for a partition */ -int dsdb_save_partition_usn(struct ldb_context *ldb, struct ldb_dn *dn, uint64_t uSN) +int dsdb_save_partition_usn(struct ldb_context *ldb, struct ldb_dn *dn, + uint64_t uSN, uint64_t urgent_uSN) { struct ldb_request *req; struct ldb_message *msg; @@ -2761,6 +2769,16 @@ int dsdb_save_partition_usn(struct ldb_context *ldb, struct ldb_dn *dn, uint64_t } msg->elements[0].flags = LDB_FLAG_MOD_REPLACE; + /* urgent_uSN is optional so may not be stored */ + if (urgent_uSN) { + ret = ldb_msg_add_fmt(msg, "uSNUrgent", "%llu", (unsigned long long)urgent_uSN); + if (ret != LDB_SUCCESS) { + talloc_free(msg); + return ret; + } + msg->elements[1].flags = LDB_FLAG_MOD_REPLACE; + } + p_ctrl = talloc(msg, struct dsdb_control_current_partition); if (p_ctrl == NULL) { -- cgit