internal bool IsLockdownAllowed()
        {
            if (TenantRelocationStateCache.IgnoreRelocationTimeConstraints())
            {
                return(true);
            }
            DateTime utcNow = DateTime.UtcNow;

            if (this.RelocationSyncStartTime != null && this.RelocationSyncStartTime.Value.ToUniversalTime() + TimeSpan.FromHours((double)TenantRelocationRequest.MinTimeBetweenRelocationStartAndLockdownHours) > utcNow)
            {
                return(false);
            }
            if (this.SafeLockdownSchedule == null || this.SafeLockdownSchedule == Schedule.Always)
            {
                return(true);
            }
            int  num = 0;
            uint num2;

            if (TenantRelocationSyncCoordinator.GetInt32ValueFromRegistryValue("TimeZoneOffset", out num2))
            {
                num = (int)num2;
            }
            return(this.SafeLockdownSchedule.Contains(utcNow.AddHours((double)num)));
        }
        internal static bool IsInactiveRelocationNode(ExchangeConfigurationUnit cu)
        {
            TenantRelocationState tenantRelocationState;
            bool flag;

            return((!string.IsNullOrEmpty(cu.TargetForest) && cu.RelocationStatus == TenantRelocationStatus.Retired) || (!string.IsNullOrEmpty(cu.RelocationSourceForestRaw) && cu.RelocationStatusDetailsRaw != RelocationStatusDetails.Active && TenantRelocationStateCache.TryGetTenantRelocationStateByObjectId(cu.Id, out tenantRelocationState, out flag) && tenantRelocationState.SourceForestState != TenantRelocationStatus.Retired));
        }
示例#3
0
 protected override void InternalValidate()
 {
     TaskLogger.LogEnter();
     base.InternalValidate();
     if (string.IsNullOrEmpty(this.DataObject.TargetForest))
     {
         base.WriteError(new InvalidOperationException(Strings.ErrorTenantNotBeingRelocated(this.Identity.ToString())), ErrorCategory.InvalidOperation, this.DataObject.Identity);
     }
     if (this.DataObject.RelocationStatus == TenantRelocationStatus.Lockdown)
     {
         base.WriteError(new InvalidOperationException(Strings.ErrorTenantInLockdown(this.Identity.ToString())), ErrorCategory.InvalidOperation, this.DataObject.Identity);
     }
     this.isRelocationComplete = (this.DataObject.RelocationStatusDetailsSource == RelocationStatusDetailsSource.RetiredUpdatedTargetForest);
     if (this.isRelocationComplete && !this.Complete)
     {
         base.WriteError(new InvalidOperationException(Strings.ErrorCompleteFlagRequired(this.Identity.ToString())), ErrorCategory.InvalidOperation, this.DataObject.Identity);
     }
     if (!this.isRelocationComplete && this.Complete)
     {
         base.WriteError(new InvalidOperationException(Strings.ErrorCompleteFlagNotAllowed(this.Identity.ToString(), this.DataObject.RelocationStatusDetailsSource.ToString(), RelocationStatusDetailsSource.RetiredUpdatedTargetForest.ToString())), ErrorCategory.InvalidOperation, this.DataObject.Identity);
     }
     if (this.Complete)
     {
         if (!this.DataObject.IsRetiredSourceHoldTimedOut())
         {
             base.WriteError(new InvalidOperationException(Strings.ErrorSourceHoldNotTimedOut(this.Identity.ToString(), TenantRelocationRequest.WaitTimeBeforeRemoveSourceReplicaDays.ToString(), this.DataObject.RetiredStartTime.Value.ToUniversalTime().ToString())), ErrorCategory.InvalidOperation, this.DataObject.Identity);
         }
         if (this.DataObject.RelocationStateRequested != RelocationStateRequested.Cleanup)
         {
             base.WriteError(new InvalidOperationException(Strings.ErrorCleanupRequestedAtWrongRequestedState(this.Identity.ToString(), this.DataObject.RelocationStateRequested.ToString(), RelocationStateRequested.Cleanup.ToString())), ErrorCategory.InvalidOperation, this.DataObject.Identity);
         }
     }
     if (this.DeprovisionedTarget && !this.Complete)
     {
         base.WriteError(new InvalidOperationException(Strings.ErrorDeprovisionedTargetPassedWithoutComplete(this.Identity.ToString())), ErrorCategory.InvalidOperation, this.DataObject.Identity);
     }
     if (this.DataObject.RelocationStatusDetailsSource >= RelocationStatusDetailsSource.InitializationFinished)
     {
         Exception ex;
         TenantRelocationRequest.PopulatePresentationObject(this.DataObject, null, out ex);
         if (ex != null)
         {
             if (!(ex is CannotFindTargetTenantException))
             {
                 base.WriteError(ex, ErrorCategory.InvalidOperation, this.DataObject.Identity);
             }
             else if (!this.DeprovisionedTarget)
             {
                 base.WriteError(new InvalidOperationException(Strings.ErrorDeprovisionedTargetNotPassed(this.Identity.ToString())), ErrorCategory.InvalidOperation, this.DataObject.Identity);
             }
         }
         GetTenantRelocationRequest.PopulateGlsProperty(this.DataObject, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose));
         if (!ADSessionSettings.IsGlsDisabled)
         {
             if (!string.IsNullOrEmpty(this.DataObject.GLSResolvedForest) && this.DataObject.GLSResolvedForest != GetTenantRelocationRequest.GlsLookupFailed && this.DataObject.GLSResolvedForest != GetTenantRelocationRequest.GlsDisabled && ((this.Complete && !string.IsNullOrEmpty(this.DataObject.TargetForest) && !this.DataObject.TargetForest.Equals(this.DataObject.GLSResolvedForest, StringComparison.OrdinalIgnoreCase)) || (!this.Complete && !string.IsNullOrEmpty(this.DataObject.SourceForest) && !this.DataObject.SourceForest.Equals(this.DataObject.GLSResolvedForest, StringComparison.OrdinalIgnoreCase))))
             {
                 base.WriteError(new InvalidOperationException(Strings.ErrorInvalidTenantGlsRecord(this.Identity.ToString(), this.DataObject.GLSResolvedForest, this.DataObject.SourceForest, this.DataObject.TargetForest)), ErrorCategory.InvalidOperation, this.DataObject.Identity);
             }
             if (this.DataObject.GLSResolvedForest == GetTenantRelocationRequest.GlsLookupFailed && !this.DeprovisionedTarget)
             {
                 base.WriteError(new InvalidOperationException(Strings.ErrorNoTenantGlsRecord(this.Identity.ToString())), ErrorCategory.InvalidOperation, this.DataObject.Identity);
             }
         }
     }
     if (!TenantRelocationStateCache.IgnoreRelocationTimeConstraints() && this.DataObject.IsRelocationInProgress())
     {
         base.WriteError(new RelocationInProgressException(this.DataObject.OrganizationId.ToString(), this.DataObject.HasPermanentError().ToString(), this.DataObject.Suspended.ToString(), this.DataObject.AutoCompletionEnabled.ToString(), this.DataObject.RelocationStatusDetailsSource.ToString(), this.DataObject.AutoCompletionEnabled ? RelocationStatusDetailsSource.RetiredUpdatedTargetForest.ToString() : this.DataObject.RelocationStateRequested.ToString()), ErrorCategory.InvalidOperation, this.DataObject.Identity);
     }
     TaskLogger.LogExit();
 }
示例#4
0
 protected override void InternalProcessRecord()
 {
     TaskLogger.LogEnter();
     if (this.isRelocationComplete)
     {
         ITenantConfigurationSession tenantConfigurationSession = this.CreateAllTenantsScopedConfigSession(this.DataObject.OrganizationId);
         ITenantRecipientSession     recipientSession           = this.CreateRecipientSession(this.DataObject.OrganizationId.OrganizationalUnit);
         Container            container            = tenantConfigurationSession.Read <Container>(this.DataObject.OrganizationId.ConfigurationUnit.Parent);
         ADOrganizationalUnit adorganizationalUnit = null;
         bool useConfigNC = tenantConfigurationSession.UseConfigNC;
         try
         {
             tenantConfigurationSession.UseConfigNC = false;
             adorganizationalUnit = tenantConfigurationSession.Read <ADOrganizationalUnit>(this.DataObject.OrganizationId.OrganizationalUnit);
         }
         finally
         {
             tenantConfigurationSession.UseConfigNC = useConfigNC;
         }
         if (adorganizationalUnit != null)
         {
             this.CleanupRecipients(this.DataObject.OrganizationId.OrganizationalUnit, recipientSession);
             tenantConfigurationSession.DeleteTree(adorganizationalUnit, null);
         }
         if (container != null)
         {
             this.RemoveExternalDirOrgIdFromCU(tenantConfigurationSession, this.DataObject.OrganizationId.ConfigurationUnit);
             tenantConfigurationSession.DeleteTree(container, null);
         }
         if (!this.DeprovisionedTarget)
         {
             ITenantConfigurationSession tenantConfigurationSession2 = this.CreateAllTenantsScopedConfigSession(this.DataObject.TargetOrganizationId);
             ExchangeConfigurationUnit   exchangeConfigurationUnit   = tenantConfigurationSession2.Read <ExchangeConfigurationUnit>(this.DataObject.TargetOrganizationId.ConfigurationUnit);
             exchangeConfigurationUnit.RelocationSourceForestRaw              = null;
             exchangeConfigurationUnit.RelocationStatusDetailsRaw             = RelocationStatusDetails.NotStarted;
             exchangeConfigurationUnit.TenantRelocationCompletionTargetVector = null;
             tenantConfigurationSession2.Save(exchangeConfigurationUnit);
         }
     }
     else
     {
         ITenantConfigurationSession tenantConfigurationSession3 = this.CreateAllTenantsScopedConfigSession(this.DataObject.TargetOrganizationId);
         if (this.DataObject.TargetOrganizationId != null)
         {
             if (!TenantRelocationStateCache.IgnoreRelocationTimeConstraints() && !this.WaitForReplicationConvergenceInTargetForest(this.DataObject.TargetOriginatingServer, new TimeSpan(0, 5, 0)))
             {
                 base.WriteError(new ReplicationNotCompleteException(this.DataObject.TargetForest, this.DataObject.TargetOriginatingServer), ErrorCategory.InvalidOperation, this.DataObject.Identity);
             }
             ITenantRecipientSession recipientSession2  = this.CreateRecipientSession(this.DataObject.TargetOrganizationId.OrganizationalUnit);
             Container            container2            = tenantConfigurationSession3.Read <Container>(this.DataObject.TargetOrganizationId.ConfigurationUnit.Parent);
             ADOrganizationalUnit adorganizationalUnit2 = null;
             if (this.DataObject.TargetOrganizationId.OrganizationalUnit != null)
             {
                 bool useConfigNC2 = tenantConfigurationSession3.UseConfigNC;
                 try
                 {
                     tenantConfigurationSession3.UseConfigNC = false;
                     adorganizationalUnit2 = tenantConfigurationSession3.Read <ADOrganizationalUnit>(this.DataObject.TargetOrganizationId.OrganizationalUnit);
                 }
                 finally
                 {
                     tenantConfigurationSession3.UseConfigNC = useConfigNC2;
                 }
             }
             if (adorganizationalUnit2 != null)
             {
                 this.CleanupRecipients(this.DataObject.TargetOrganizationId.OrganizationalUnit, recipientSession2);
                 tenantConfigurationSession3.DeleteTree(adorganizationalUnit2, null);
             }
             if (container2 != null)
             {
                 this.RemoveExternalDirOrgIdFromCU(tenantConfigurationSession3, this.DataObject.TargetOrganizationId.ConfigurationUnit);
                 tenantConfigurationSession3.DeleteTree(container2, null);
             }
         }
         this.DataObject.RelocationSyncStartTime = null;
         this.DataObject.LockdownStartTime       = null;
         this.DataObject.RetiredStartTime        = null;
         this.DataObject.TransitionCounter       = null;
         this.DataObject.TargetForest            = null;
         this.DataObject.SafeLockdownSchedule    = null;
         this.DataObject[TenantRelocationRequestSchema.RelocationStatusDetailsRaw] = null;
         this.DataObject[TenantRelocationRequestSchema.RelocationSourceForestRaw]  = null;
         this.DataObject[TenantRelocationRequestSchema.TenantRelocationFlags]      = 0;
         base.InternalProcessRecord();
     }
     TaskLogger.LogExit();
 }
 internal bool IsRetiredSourceHoldTimedOut()
 {
     return(TenantRelocationStateCache.IgnoreRelocationTimeConstraints() || (this.RetiredStartTime != null && this.RetiredStartTime.Value.ToUniversalTime() + TimeSpan.FromDays((double)TenantRelocationRequest.WaitTimeBeforeRemoveSourceReplicaDays) < DateTime.UtcNow));
 }
 internal bool IsLockdownTimedOut()
 {
     return(!this.Suspended && this.InLockdown() && this.LockdownStartTime != null && this.LockdownStartTime.Value.ToUniversalTime() + TimeSpan.FromMinutes((double)TenantRelocationRequest.MaxLockdownTimeMinutes) < DateTime.UtcNow && !TenantRelocationStateCache.IgnoreRelocationTimeConstraints());
 }