public static TenantRelocationState GetTenantRelocationState(string tenantName, PartitionId partitionId, out bool isSourceTenant, bool readThrough = false) { if (string.IsNullOrEmpty(tenantName)) { throw new ArgumentNullException("tenantName"); } if (!ForestTenantRelocationsCache.IsTenantRelocationAllowed(partitionId.ForestFQDN)) { isSourceTenant = true; return(new TenantRelocationState(partitionId.ForestFQDN, TenantRelocationStatus.NotStarted)); } TenantRelocationStateCache tenantRelocationStateCache = TenantRelocationStateCache.GetInstance(); ExpiringTenantRelocationStateValue expiringTenantRelocationStateValue; if (!tenantRelocationStateCache.tenantRelocationStates.TryGetValue(tenantName, out expiringTenantRelocationStateValue) || expiringTenantRelocationStateValue.Expired || readThrough || TenantRelocationStateCache.IgnoreRelocationTimeConstraints()) { TenantRelocationState tenantRelocationState = TenantRelocationStateCache.LoadTenantRelocationState(tenantName, partitionId); ExTraceGlobals.TenantRelocationTracer.TraceDebug(0L, "TenantRelocationStateCache::GetTenantRelocationState(): Inserting new TenantRelocationState value for tenant {0} to the cache: SourceForestFQDN={1}, SourceForestState={2}, TargetForestFQDN={3}, TargetForestState={4}, TargetOrganizationId={5}", new object[] { tenantName, tenantRelocationState.SourceForestFQDN, tenantRelocationState.SourceForestState, tenantRelocationState.TargetForestFQDN, tenantRelocationState.TargetForestState, (tenantRelocationState.TargetOrganizationId != null) ? tenantRelocationState.TargetOrganizationId.ToString() : "<null>" }); expiringTenantRelocationStateValue = new ExpiringTenantRelocationStateValue(tenantRelocationState); tenantRelocationStateCache.AddOrUpdate(tenantName, expiringTenantRelocationStateValue); } if (expiringTenantRelocationStateValue.Value.TargetOrganizationId == null || expiringTenantRelocationStateValue.Value.TargetOrganizationId.OrganizationalUnit == null) { isSourceTenant = true; } else if (expiringTenantRelocationStateValue.Value.TargetOrganizationId.PartitionId != partitionId) { isSourceTenant = true; } else if (expiringTenantRelocationStateValue.Value.SourceForestFQDN == expiringTenantRelocationStateValue.Value.TargetForestFQDN) { isSourceTenant = (tenantName != expiringTenantRelocationStateValue.Value.TargetOrganizationId.OrganizationalUnit.Name); } else { isSourceTenant = false; } return(expiringTenantRelocationStateValue.Value); }
private static bool ReadIgnoreRelocationTimeConstraintsValue() { int intValueFromRegistry = Globals.GetIntValueFromRegistry("SOFTWARE\\Microsoft\\ExchangeLabs", "TenantRelocationIgnoreTimeConstraints", 0, TenantRelocationStateCache.GetInstance().GetHashCode()); return(intValueFromRegistry > 0); }