From 7ffcf90bb9b7214e30b82a0e8e371207409052eb Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 20 Sep 2010 20:36:36 -0700 Subject: s4-drepl: use the partition UDV and hwm for extended getncchanges ops we find the NC root then load the uptodateness vector and highwater mark, if available, from there --- source4/dsdb/repl/drepl_extended.c | 39 +++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'source4/dsdb/repl/drepl_extended.c') diff --git a/source4/dsdb/repl/drepl_extended.c b/source4/dsdb/repl/drepl_extended.c index de56cb5ac5..2c9d1f04e6 100644 --- a/source4/dsdb/repl/drepl_extended.c +++ b/source4/dsdb/repl/drepl_extended.c @@ -48,6 +48,8 @@ static WERROR drepl_create_extended_source_dsa(struct dreplsrv_service *service, struct ldb_context *ldb = service->samdb; int ret; WERROR werr; + struct ldb_dn *nc_root; + struct dreplsrv_partition *p; sdsa = talloc_zero(service, struct dreplsrv_partition_source_dsa); W_ERROR_HAVE_NO_MEMORY(sdsa); @@ -100,7 +102,9 @@ static WERROR drepl_create_extended_source_dsa(struct dreplsrv_service *service, return WERR_NOMEM; } - sdsa->repsFrom1->highwatermark.highest_usn = min_usn; + if (!service->am_rodc) { + sdsa->repsFrom1->replica_flags = DRSUAPI_DRS_WRIT_REP; + } werr = dreplsrv_out_connection_attach(service, sdsa->repsFrom1, &sdsa->conn); if (!W_ERROR_IS_OK(werr)) { @@ -110,6 +114,39 @@ static WERROR drepl_create_extended_source_dsa(struct dreplsrv_service *service, return werr; } + ret = dsdb_find_nc_root(service->samdb, sdsa, nc_dn, &nc_root); + if (ret != LDB_SUCCESS) { + DEBUG(0,(__location__ ": Failed to find nc_root for %s\n", + ldb_dn_get_linearized(nc_dn))); + talloc_free(sdsa); + return WERR_DS_DRA_INTERNAL_ERROR; + } + + /* use the partition uptodateness vector */ + ret = dsdb_load_udv_v2(service->samdb, nc_root, sdsa->partition, + &sdsa->partition->uptodatevector.cursors, + &sdsa->partition->uptodatevector.count); + if (ret != LDB_SUCCESS) { + DEBUG(0,(__location__ ": Failed to load UDV for %s\n", + ldb_dn_get_linearized(nc_root))); + talloc_free(sdsa); + return WERR_DS_DRA_INTERNAL_ERROR; + } + + /* find the highwatermark from the partitions list */ + for (p=service->partitions; p; p=p->next) { + if (ldb_dn_compare(p->dn, nc_root) == 0) { + struct dreplsrv_partition_source_dsa *s; + for (s=p->sources; s; s=s->next) { + if (GUID_equal(&s->repsFrom1->source_dsa_obj_guid, + &sdsa->repsFrom1->source_dsa_obj_guid)) { + sdsa->repsFrom1->highwatermark = s->repsFrom1->highwatermark; + } + } + } + } + + *_sdsa = sdsa; return WERR_OK; } -- cgit