Ejemplo n.º 1
0
        internal static MailboxData DiscoverTestMailbox(IIdentityParameter identity, IRecipientSession adSession, ADServerSettings serverSettings, DataAccessHelper.CategorizedGetDataObjectDelegate getDataObject, Task.TaskVerboseLoggingDelegate writeVerbose, Task.ErrorLoggerDelegate writeError)
        {
            if (identity == null)
            {
                MigrationADProvider migrationADProvider = new MigrationADProvider(adSession);
                return(migrationADProvider.GetMailboxDataForManagementMailbox());
            }
            ADUser      aduser      = RequestTaskHelper.ResolveADUser(adSession, adSession, serverSettings, identity, null, null, getDataObject, writeVerbose, writeError, true);
            MailboxData mailboxData = new MailboxData(aduser.ExchangeGuid, new Fqdn(aduser.ServerName), aduser.LegacyExchangeDN, aduser.Id, aduser.ExchangeObjectId);

            mailboxData.Update(identity.RawIdentity, aduser.OrganizationId);
            return(mailboxData);
        }
Ejemplo n.º 2
0
        internal static MailboxData DiscoverPublicFolderTestMailbox(IIdentityParameter identity, IConfigurationSession configurationSession, IRecipientSession recipientSession, ADServerSettings serverSettings, DataAccessHelper.CategorizedGetDataObjectDelegate getDataObject, Task.TaskVerboseLoggingDelegate writeVerbose, Task.ErrorLoggerDelegate writeError)
        {
            if (identity == null)
            {
                Organization orgContainer = configurationSession.GetOrgContainer();
                if (orgContainer.DefaultPublicFolderMailbox.HierarchyMailboxGuid != default(Guid))
                {
                    identity = new MailboxIdParameter(orgContainer.DefaultPublicFolderMailbox.HierarchyMailboxGuid.ToString());
                }
                else
                {
                    writeError(new MigrationPermanentException(Strings.ErrorUnableToFindValidPublicFolderMailbox), ExchangeErrorCategory.Client, null);
                }
            }
            ADUser aduser = RequestTaskHelper.ResolveADUser(recipientSession, recipientSession, serverSettings, identity, new OptionalIdentityData(), null, getDataObject, writeVerbose, writeError, true);

            if (aduser.RecipientTypeDetails != RecipientTypeDetails.PublicFolderMailbox)
            {
                writeError(new MigrationPermanentException(Strings.ErrorNotPublicFolderMailbox(identity.RawIdentity)), ExchangeErrorCategory.Client, null);
            }
            return(MailboxData.CreateFromADUser(aduser));
        }
Ejemplo n.º 3
0
        private void ValidateSchedulingParameters(MigrationJob migrationJob)
        {
            DateTime?     dateTime      = null;
            DateTime?     dateTime2     = null;
            bool          flag          = false;
            bool          flag2         = false;
            MigrationType migrationType = migrationJob.MigrationType;

            if (migrationType <= MigrationType.ExchangeOutlookAnywhere)
            {
                if (migrationType != MigrationType.IMAP)
                {
                    if (migrationType == MigrationType.ExchangeOutlookAnywhere)
                    {
                        ExchangeJobSubscriptionSettings exchangeJobSubscriptionSettings = migrationJob.SubscriptionSettings as ExchangeJobSubscriptionSettings;
                        if (exchangeJobSubscriptionSettings != null)
                        {
                            dateTime = (DateTime?)exchangeJobSubscriptionSettings.StartAfter;
                        }
                        flag = true;
                    }
                }
                else if (migrationJob.IsPAW)
                {
                    IMAPPAWJobSubscriptionSettings imappawjobSubscriptionSettings = migrationJob.SubscriptionSettings as IMAPPAWJobSubscriptionSettings;
                    if (imappawjobSubscriptionSettings != null)
                    {
                        dateTime  = (DateTime?)imappawjobSubscriptionSettings.StartAfter;
                        dateTime2 = (DateTime?)imappawjobSubscriptionSettings.CompleteAfter;
                    }
                    flag  = true;
                    flag2 = true;
                }
            }
            else if (migrationType == MigrationType.ExchangeRemoteMove || migrationType == MigrationType.ExchangeLocalMove)
            {
                MoveJobSubscriptionSettings moveJobSubscriptionSettings = migrationJob.SubscriptionSettings as MoveJobSubscriptionSettings;
                if (moveJobSubscriptionSettings != null)
                {
                    dateTime  = (DateTime?)moveJobSubscriptionSettings.StartAfter;
                    dateTime2 = (DateTime?)moveJobSubscriptionSettings.CompleteAfter;
                }
                flag  = true;
                flag2 = true;
            }
            if (base.IsFieldSet("StartAfter") && !flag)
            {
                base.WriteError(new LocalizedException(Strings.MigrationStartAfterIncorrectMigrationType));
            }
            if (base.IsFieldSet("CompleteAfter") && !flag2)
            {
                base.WriteError(new LocalizedException(Strings.MigrationCompleteAfterIncorrectMigrationType));
            }
            bool flag3 = !migrationJob.IsPAW && !migrationJob.AutoComplete;

            if (base.IsFieldSet("StartAfter") && flag3)
            {
                base.WriteError(new LocalizedException(Strings.MigrationStartAfterScheduledBatchesOnly));
            }
            if (base.IsFieldSet("CompleteAfter") && flag3)
            {
                base.WriteError(new LocalizedException(Strings.MigrationCompleteAfterScheduledBatchesOnly));
            }
            if (base.IsFieldSet("StartAfter"))
            {
                if (migrationJob.Status != MigrationJobStatus.Created && migrationJob.Status != MigrationJobStatus.Failed && !migrationJob.IsPAW)
                {
                    base.WriteError(new LocalizedException(Strings.MigrationStartAfterIncorrectState(migrationJob.Status.ToString())));
                }
                if (this.StartAfter != null)
                {
                    RequestTaskHelper.ValidateStartAfterTime(this.StartAfter.Value.ToUniversalTime(), new Task.TaskErrorLoggingDelegate(base.WriteError), DateTime.UtcNow);
                }
            }
            if (base.IsFieldSet("CompleteAfter"))
            {
                if (migrationJob.Status != MigrationJobStatus.Created && migrationJob.Status != MigrationJobStatus.Failed && migrationJob.Status != MigrationJobStatus.SyncInitializing && migrationJob.Status != MigrationJobStatus.SyncStarting && migrationJob.Status != MigrationJobStatus.SyncCompleting && migrationJob.Status != MigrationJobStatus.SyncCompleted && migrationJob.Status != MigrationJobStatus.ProvisionStarting && migrationJob.Status != MigrationJobStatus.Validating && migrationJob.Status != MigrationJobStatus.Stopped && !migrationJob.IsPAW)
                {
                    base.WriteError(new LocalizedException(Strings.MigrationCompleteAfterIncorrectState));
                }
                if (this.CompleteAfter != null)
                {
                    RequestTaskHelper.ValidateCompleteAfterTime(this.CompleteAfter.Value.ToUniversalTime(), new Task.TaskErrorLoggingDelegate(base.WriteError), DateTime.UtcNow);
                }
                if (dateTime2 != null && DateTime.UtcNow.AddHours(1.0) > dateTime2.Value.ToUniversalTime())
                {
                    this.WriteWarning(Strings.MigrationSettingCompeteAfterWithCurrentCompleteAfterInLessThanOneHour);
                }
                if (dateTime2 != null && this.CompleteAfter != null && this.CompleteAfter.Value.ToUniversalTime() < dateTime2.Value.ToUniversalTime())
                {
                    this.WriteWarning(Strings.MigrationCompleteAfterChangedToEarlierTime);
                }
            }
            if ((base.IsFieldSet("StartAfter") || base.IsFieldSet("CompleteAfter")) && (this.StartAfter != null || dateTime != null) && (this.CompleteAfter != null || dateTime2 != null))
            {
                DateTime?dateTime3 = this.StartAfter ?? dateTime;
                DateTime?dateTime4 = this.CompleteAfter ?? dateTime2;
                RequestTaskHelper.ValidateStartAfterComesBeforeCompleteAfter(new DateTime?(dateTime3.Value.ToUniversalTime()), new DateTime?(dateTime4.Value.ToUniversalTime()), new Task.TaskErrorLoggingDelegate(base.WriteError));
            }
        }