internal static RidMasterInfo GetRidMasterInfo(IConfigurationSession session) { bool useConfigNC = session.UseConfigNC; RidMasterInfo result; try { session.UseConfigNC = false; RidManagerContainer[] array = session.Find <RidManagerContainer>(null, QueryScope.SubTree, null, null, 1); if (array == null || array.Length != 1) { throw new RidMasterConfigException(Strings.ErrorCannotRetrieveRidManagerContainer((array == null) ? "0" : array.Length.ToString())); } session.UseConfigNC = true; ADObjectId fsmoRoleOwner = array[0].FsmoRoleOwner; if (fsmoRoleOwner == null) { throw new RidMasterConfigException(Strings.ErrorEmptyFsmoRoleOwnerAttribute); } ADServer adserver = session.Read <ADServer>(fsmoRoleOwner.Parent); if (adserver == null) { throw new RidMasterConfigException(Strings.ErrorCannotRetrieveServer(fsmoRoleOwner.Parent.ToString())); } string dnsHostName = adserver.DnsHostName; int fsmoRoleOwnerVersion = SyncDaemonArbitrationConfigHelper.GetFsmoRoleOwnerVersion(array[0].ReplicationAttributeMetadata); result = new RidMasterInfo(dnsHostName, fsmoRoleOwnerVersion); } finally { session.UseConfigNC = useConfigNC; } return(result); }
private void RefreshRidMasterInformation() { if (DateTime.UtcNow - this.lastRidMasterRefreshTime > FullSyncObjectRequestDataProvider.RidMasterRefreshInterval) { RidMasterInfo ridMasterInfo = SyncDaemonArbitrationConfigHelper.GetRidMasterInfo(this.configurationSession); this.configurationSession.DomainController = ridMasterInfo.RidMasterServer; this.lastRidMasterRefreshTime = DateTime.UtcNow; } }
internal static ArbitrationConfigFromAD GetArbitrationConfigFromAD(string serviceInstanceName) { IConfigurationSession configurationSession = ForwardSyncDataAccessHelper.CreateSession(true); RidMasterInfo ridMasterInfo = SyncDaemonArbitrationConfigHelper.GetRidMasterInfo(configurationSession); SyncServiceInstance[] array = configurationSession.Find <SyncServiceInstance>(SyncServiceInstance.GetMsoSyncRootContainer(), QueryScope.SubTree, new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.Name, serviceInstanceName), null, 1); if (array == null || array.Length != 1) { throw new SyncDaemonArbitrationConfigException(Strings.ErrorCannotRetrieveSyncDaemonArbitrationConfigContainer((array == null) ? "0" : array.Length.ToString())); } return(new ArbitrationConfigFromAD(array[0], ridMasterInfo)); }
public ArbitrationConfigFromAD(SyncServiceInstance syncDaemonArbitrationConfig, RidMasterInfo ridMasterInfo) { this.SyncDaemonArbitrationConfig = syncDaemonArbitrationConfig; this.RidMasterInfo = ridMasterInfo; this.PassiveInstanceSleepInterval = TimeSpan.FromSeconds((double)this.SyncDaemonArbitrationConfig.PassiveInstanceSleepInterval); this.ActiveInstanceSleepInterval = TimeSpan.FromSeconds((double)this.SyncDaemonArbitrationConfig.ActiveInstanceSleepInterval); }