From 3119296e425a4c640fe9bd2bb97f09bab8a9ccf0 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 26 Apr 2010 22:51:11 +1000 Subject: s4-drepl: don't setup a repsFrom from a DC that isn't a master for a NC use hasMasterNCs to see what NCs we should be pulling from each DC --- source4/dsdb/kcc/kcc_periodic.c | 55 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 5 deletions(-) (limited to 'source4/dsdb/kcc') diff --git a/source4/dsdb/kcc/kcc_periodic.c b/source4/dsdb/kcc/kcc_periodic.c index 14e15e8aea..e05ac56fcc 100644 --- a/source4/dsdb/kcc/kcc_periodic.c +++ b/source4/dsdb/kcc/kcc_periodic.c @@ -52,12 +52,55 @@ static bool reps_in_list(struct repsFromToBlob *r, struct repsFromToBlob *reps, return false; } +/* + make sure we only add repsFrom entries for DCs who are masters for + the partition + */ +static bool check_MasterNC(struct kccsrv_partition *p, struct repsFromToBlob *r, + struct ldb_result *res) +{ + struct repsFromTo1 *r1; + r1 = &r->ctr.ctr1; + struct GUID invocation_id = r1->source_dsa_invocation_id; + int i, j; + + for (i=0; icount; i++) { + struct ldb_message *msg = res->msgs[i]; + struct ldb_message_element *el; + struct ldb_dn *dn; + + struct GUID id2 = samdb_result_guid(msg, "invocationID"); + if (!GUID_equal(&invocation_id, &id2)) { + continue; + } + + el = ldb_msg_find_element(msg, "hasMasterNCs"); + if (!el || el->num_values == 0) { + continue; + } + for (j=0; jnum_values; j++) { + dn = ldb_dn_from_ldb_val(p, p->service->samdb, &el->values[j]); + if (!ldb_dn_validate(dn)) { + talloc_free(dn); + continue; + } + if (ldb_dn_compare(dn, p->dn) == 0) { + talloc_free(dn); + return true; + } + talloc_free(dn); + } + } + return false; +} + /* * add any missing repsFrom structures to our partitions */ static NTSTATUS kccsrv_add_repsFrom(struct kccsrv_service *s, TALLOC_CTX *mem_ctx, - struct repsFromToBlob *reps, uint32_t count) + struct repsFromToBlob *reps, uint32_t count, + struct ldb_result *res) { struct kccsrv_partition *p; @@ -78,7 +121,8 @@ static NTSTATUS kccsrv_add_repsFrom(struct kccsrv_service *s, TALLOC_CTX *mem_ct /* add any new ones */ for (i=0; i