summaryrefslogtreecommitdiff
path: root/source4/dsdb
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2010-04-26 23:21:10 +1000
committerAndrew Tridgell <tridge@samba.org>2010-04-27 10:38:59 +1000
commitb0aa4769483a1d2084191b70b2ffa3b0c65696ff (patch)
treef9abc417e23c23a2104e05cfb3ea1175eae835d2 /source4/dsdb
parent3119296e425a4c640fe9bd2bb97f09bab8a9ccf0 (diff)
downloadsamba-b0aa4769483a1d2084191b70b2ffa3b0c65696ff.tar.gz
samba-b0aa4769483a1d2084191b70b2ffa3b0c65696ff.tar.bz2
samba-b0aa4769483a1d2084191b70b2ffa3b0c65696ff.zip
s4-drs: add entries to repsTo based on calculated repsFrom
This is based on the documentation: "the KCC will automatically create the Reps-To attributes on destination DSAs based on other DSAs Reps-From entries."
Diffstat (limited to 'source4/dsdb')
-rw-r--r--source4/dsdb/kcc/kcc_periodic.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/source4/dsdb/kcc/kcc_periodic.c b/source4/dsdb/kcc/kcc_periodic.c
index e05ac56fcc..6dab6b5ea8 100644
--- a/source4/dsdb/kcc/kcc_periodic.c
+++ b/source4/dsdb/kcc/kcc_periodic.c
@@ -106,8 +106,8 @@ static NTSTATUS kccsrv_add_repsFrom(struct kccsrv_service *s, TALLOC_CTX *mem_ct
/* update the repsFrom on all partitions */
for (p=s->partitions; p; p=p->next) {
- struct repsFromToBlob *old_reps;
- uint32_t old_count;
+ struct repsFromToBlob *old_reps, *reps_to;
+ uint32_t old_count, to_count;
WERROR werr;
uint32_t i;
bool modified = false;
@@ -150,6 +150,34 @@ static NTSTATUS kccsrv_add_repsFrom(struct kccsrv_service *s, TALLOC_CTX *mem_ct
return NT_STATUS_INTERNAL_DB_CORRUPTION;
}
}
+
+ werr = dsdb_loadreps(s->samdb, mem_ctx, p->dn, "repsTo", &reps_to, &to_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;
+ }
+
+ modified = false;
+ /* add any new ones */
+ for (i=0; i<old_count; i++) {
+ if (!reps_in_list(&old_reps[i], reps_to, to_count)) {
+ reps_to = talloc_realloc(mem_ctx, reps_to, struct repsFromToBlob, to_count+1);
+ NT_STATUS_HAVE_NO_MEMORY(reps_to);
+ reps_to[to_count] = old_reps[i];
+ to_count++;
+ modified = true;
+ }
+ }
+
+ if (modified) {
+ werr = dsdb_savereps(s->samdb, mem_ctx, p->dn, "repsTo", reps_to, to_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;
+ }
+ }
}
return NT_STATUS_OK;