mirror of
https://github.com/samba-team/samba.git
synced 2025-02-26 21:57:41 +03:00
s4-dsdb: enable initial replication of partitions via DsReplicaSync
we need to create a temporary dsa object to allow the replication task to replicate a NC that is not listed in a repsFrom attribute
This commit is contained in:
parent
86f5ecdc0c
commit
2b929b0b51
@ -405,6 +405,48 @@ WERROR dreplsrv_partition_source_dsa_by_dns(const struct dreplsrv_partition *p,
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
create a temporary dsa structure for a replication. This is needed
|
||||
for the initial replication of a new partition, such as when a new
|
||||
domain NC is created and we are a global catalog server
|
||||
*/
|
||||
WERROR dreplsrv_partition_source_dsa_temporary(struct dreplsrv_partition *p,
|
||||
TALLOC_CTX *mem_ctx,
|
||||
const struct GUID *dsa_guid,
|
||||
struct dreplsrv_partition_source_dsa **_dsa)
|
||||
{
|
||||
struct dreplsrv_partition_source_dsa *dsa;
|
||||
WERROR werr;
|
||||
|
||||
dsa = talloc_zero(mem_ctx, struct dreplsrv_partition_source_dsa);
|
||||
W_ERROR_HAVE_NO_MEMORY(dsa);
|
||||
|
||||
dsa->partition = p;
|
||||
dsa->repsFrom1 = &dsa->_repsFromBlob.ctr.ctr1;
|
||||
dsa->repsFrom1->replica_flags = 0;
|
||||
dsa->repsFrom1->source_dsa_obj_guid = *dsa_guid;
|
||||
|
||||
dsa->repsFrom1->other_info = talloc_zero(dsa, struct repsFromTo1OtherInfo);
|
||||
W_ERROR_HAVE_NO_MEMORY(dsa->repsFrom1->other_info);
|
||||
|
||||
dsa->repsFrom1->other_info->dns_name = samdb_ntds_msdcs_dns_name(p->service->samdb,
|
||||
dsa->repsFrom1->other_info, dsa_guid);
|
||||
W_ERROR_HAVE_NO_MEMORY(dsa->repsFrom1->other_info->dns_name);
|
||||
|
||||
werr = dreplsrv_out_connection_attach(p->service, dsa->repsFrom1, &dsa->conn);
|
||||
if (!W_ERROR_IS_OK(werr)) {
|
||||
DEBUG(0,(__location__ ": Failed to attach connection to %s\n",
|
||||
ldb_dn_get_linearized(p->dn)));
|
||||
talloc_free(dsa);
|
||||
return werr;
|
||||
}
|
||||
|
||||
*_dsa = dsa;
|
||||
|
||||
return WERR_OK;
|
||||
}
|
||||
|
||||
|
||||
static WERROR dreplsrv_refresh_partition(struct dreplsrv_service *s,
|
||||
struct dreplsrv_partition *p)
|
||||
{
|
||||
|
@ -306,6 +306,16 @@ static NTSTATUS drepl_replica_sync(struct irpc_message *msg,
|
||||
werr = dreplsrv_partition_source_dsa_by_guid(p,
|
||||
&req1->source_dsa_guid,
|
||||
&dsa);
|
||||
if (W_ERROR_EQUAL(werr, WERR_DS_DRA_NO_REPLICA)) {
|
||||
/* we don't have this source setup as
|
||||
a replication partner. Create a
|
||||
temporary dsa structure for this
|
||||
replication */
|
||||
werr = dreplsrv_partition_source_dsa_temporary(p,
|
||||
msg,
|
||||
&req1->source_dsa_guid,
|
||||
&dsa);
|
||||
}
|
||||
}
|
||||
if (!W_ERROR_IS_OK(werr)) {
|
||||
REPLICA_SYNC_FAIL("Failed to locate source DSA for given NC",
|
||||
|
Loading…
x
Reference in New Issue
Block a user