summaryrefslogtreecommitdiff
path: root/source4/dsdb/kcc
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2010-10-01 14:20:57 -0700
committerAndrew Tridgell <tridge@samba.org>2010-10-02 01:04:17 +0000
commit6e846ca1f3bd812bdba22101d8326987a0013858 (patch)
tree122984665f2d87953f47ca6aa550999d244e40a4 /source4/dsdb/kcc
parentfaa993d95c0cdd29b52d64000e0f0c0585ff01af (diff)
downloadsamba-6e846ca1f3bd812bdba22101d8326987a0013858.tar.gz
samba-6e846ca1f3bd812bdba22101d8326987a0013858.tar.bz2
samba-6e846ca1f3bd812bdba22101d8326987a0013858.zip
s4-kcc: remove stale repsTo entries in the KCC
Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'source4/dsdb/kcc')
-rw-r--r--source4/dsdb/kcc/kcc_periodic.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/source4/dsdb/kcc/kcc_periodic.c b/source4/dsdb/kcc/kcc_periodic.c
index b6db0a7308..d9ca618992 100644
--- a/source4/dsdb/kcc/kcc_periodic.c
+++ b/source4/dsdb/kcc/kcc_periodic.c
@@ -260,6 +260,38 @@ static NTSTATUS kccsrv_add_repsFrom(struct kccsrv_service *s, TALLOC_CTX *mem_ct
/* dreplsrv should refresh its state */
notify_dreplsrv = true;
}
+
+ /* remove stale repsTo entries */
+ modified = false;
+ werr = dsdb_loadreps(s->samdb, mem_ctx, p->dn, "repsTo", &our_reps, &our_count);
+ if (!W_ERROR_IS_OK(werr)) {
+ DEBUG(0,(__location__ ": Failed to load repsTo from %s - %s\n",
+ ldb_dn_get_linearized(p->dn), ldb_errstring(s->samdb)));
+ return NT_STATUS_INTERNAL_DB_CORRUPTION;
+ }
+
+ /* remove any stale ones */
+ for (i=0; i<our_count; i++) {
+ if (!reps_in_list(&our_reps[i], reps, count)) {
+ DEBUG(4,(__location__ ": Removed repsTo for %s\n",
+ our_reps[i].ctr.ctr1.other_info->dns_name));
+ memmove(&our_reps[i], &our_reps[i+1], (our_count-(i+1))*sizeof(our_reps[0]));
+ our_count--;
+ i--;
+ modified = true;
+ }
+ }
+
+ if (modified) {
+ werr = dsdb_savereps(s->samdb, mem_ctx, p->dn, "repsTo", our_reps, our_count);
+ if (!W_ERROR_IS_OK(werr)) {
+ DEBUG(0,(__location__ ": Failed to save repsTo to %s - %s\n",
+ ldb_dn_get_linearized(p->dn), ldb_errstring(s->samdb)));
+ return NT_STATUS_INTERNAL_DB_CORRUPTION;
+ }
+ /* dreplsrv should refresh its state */
+ notify_dreplsrv = true;
+ }
}
/* notify dreplsrv toplogy has changed */