Exemplo n.º 1
0
        private void InternalProcessExchangeOutlookAnywhere(IMigrationDataProvider dataProvider)
        {
            ExchangeOutlookAnywhereEndpoint exchangeOutlookAnywhereEndpoint = new ExchangeOutlookAnywhereEndpoint();

            try
            {
                if (this.Autodiscover)
                {
                    TestMigrationServerAvailabilityOutcome testMigrationServerAvailabilityOutcome = null;
                    try
                    {
                        exchangeOutlookAnywhereEndpoint.InitializeFromAutoDiscover(this.EmailAddress, this.Credentials);
                    }
                    catch (AutoDiscoverFailedConfigurationErrorException exception)
                    {
                        testMigrationServerAvailabilityOutcome = this.CreateAutodsicoverFailedOutcome(exception);
                    }
                    catch (AutoDiscoverFailedInternalErrorException exception2)
                    {
                        testMigrationServerAvailabilityOutcome = this.CreateAutodsicoverFailedOutcome(exception2);
                    }
                    if (testMigrationServerAvailabilityOutcome != null)
                    {
                        MigrationLogger.Log(MigrationEventType.Information, testMigrationServerAvailabilityOutcome.ToString(), new object[0]);
                        base.WriteObject(testMigrationServerAvailabilityOutcome);
                        return;
                    }
                }
                else
                {
                    exchangeOutlookAnywhereEndpoint.RpcProxyServer       = this.RPCProxyServer;
                    exchangeOutlookAnywhereEndpoint.Credentials          = this.Credentials;
                    exchangeOutlookAnywhereEndpoint.ExchangeServer       = this.ExchangeServer;
                    exchangeOutlookAnywhereEndpoint.AuthenticationMethod = this.Authentication;
                }
                IMigrationNspiClient nspiClient = MigrationServiceFactory.Instance.GetNspiClient(null);
                exchangeOutlookAnywhereEndpoint.NspiServer        = nspiClient.GetNewDSA(exchangeOutlookAnywhereEndpoint);
                exchangeOutlookAnywhereEndpoint.MailboxPermission = this.MailboxPermission;
                NspiMigrationDataReader nspiDataReader = exchangeOutlookAnywhereEndpoint.GetNspiDataReader(null);
                nspiDataReader.Ping();
                ExchangeOutlookAnywhereEndpoint.ValidateEndpoint(exchangeOutlookAnywhereEndpoint);
            }
            catch (MigrationTransientException ex)
            {
                MigrationLogger.Log(MigrationEventType.Warning, MigrationLogger.GetDiagnosticInfo(ex, null), new object[0]);
                base.WriteObject(TestMigrationServerAvailabilityOutcome.Create(TestMigrationServerAvailabilityResult.Failed, this.SupportsCutover, ex.LocalizedString, ex.InternalError));
                return;
            }
            catch (MigrationPermanentException ex2)
            {
                MigrationLogger.Log(MigrationEventType.Error, MigrationLogger.GetDiagnosticInfo(ex2, null), new object[0]);
                base.WriteObject(TestMigrationServerAvailabilityOutcome.Create(TestMigrationServerAvailabilityResult.Failed, this.SupportsCutover, ex2.LocalizedString, ex2.InternalError));
                return;
            }
            TestMigrationServerAvailabilityOutcome testMigrationServerAvailabilityOutcome2;

            try
            {
                TestMigrationServerAvailability.VerifyExchangeOutlookAnywhereConnection(dataProvider, exchangeOutlookAnywhereEndpoint, (string)this.EmailAddress, this.SourceMailboxLegacyDN, this.targetMailbox, !this.IsFieldSet("MailboxPermission"));
                testMigrationServerAvailabilityOutcome2 = TestMigrationServerAvailabilityOutcome.Create(TestMigrationServerAvailabilityResult.Success, this.SupportsCutover, (ExchangeConnectionSettings)exchangeOutlookAnywhereEndpoint.ConnectionSettings);
            }
            catch (LocalizedException ex3)
            {
                string diagnosticInfo = MigrationLogger.GetDiagnosticInfo(ex3, null);
                MigrationLogger.Log(MigrationEventType.Error, diagnosticInfo, new object[0]);
                testMigrationServerAvailabilityOutcome2 = TestMigrationServerAvailabilityOutcome.Create(TestMigrationServerAvailabilityResult.Failed, this.SupportsCutover, ex3.LocalizedString, diagnosticInfo);
                testMigrationServerAvailabilityOutcome2.ConnectionSettings = (ExchangeConnectionSettings)exchangeOutlookAnywhereEndpoint.ConnectionSettings;
            }
            base.WriteObject(testMigrationServerAvailabilityOutcome2);
        }
Exemplo n.º 2
0
        internal static bool VerifyExchangeOutlookAnywhereConnection(IMigrationDataProvider dataProvider, ExchangeOutlookAnywhereEndpoint outlookAnywhereEndpoint, string emailAddress, string sourceMailboxLegacyDN, MailboxData targetMailbox, bool discoverAdminPrivilege)
        {
            string mailboxDN;

            if (!string.IsNullOrEmpty(sourceMailboxLegacyDN))
            {
                mailboxDN = sourceMailboxLegacyDN;
            }
            else if (!string.IsNullOrEmpty(emailAddress) && (!outlookAnywhereEndpoint.UseAutoDiscover || outlookAnywhereEndpoint.AutodiscoverResponse == null))
            {
                NspiMigrationDataReader nspiDataReader       = outlookAnywhereEndpoint.GetNspiDataReader(null);
                IMigrationDataRow       recipient            = nspiDataReader.GetRecipient(emailAddress);
                NspiMigrationDataRow    nspiMigrationDataRow = recipient as NspiMigrationDataRow;
                if (nspiMigrationDataRow == null)
                {
                    LocalizedString localizedErrorMessage = LocalizedString.Empty;
                    InvalidDataRow  invalidDataRow        = recipient as InvalidDataRow;
                    if (invalidDataRow != null && invalidDataRow.Error != null)
                    {
                        LocalizedString localizedErrorMessage2 = invalidDataRow.Error.LocalizedErrorMessage;
                        localizedErrorMessage = invalidDataRow.Error.LocalizedErrorMessage;
                    }
                    throw new MigrationPermanentException(localizedErrorMessage);
                }
                mailboxDN = nspiMigrationDataRow.Recipient.GetPropertyValue <string>(PropTag.EmailAddress);
            }
            else
            {
                mailboxDN = outlookAnywhereEndpoint.AutodiscoverResponse.MailboxDN;
            }
            ExchangeJobItemSubscriptionSettings subscriptionSettings = ExchangeJobItemSubscriptionSettings.CreateFromProperties(mailboxDN, outlookAnywhereEndpoint.ExchangeServer, outlookAnywhereEndpoint.ExchangeServer, outlookAnywhereEndpoint.RpcProxyServer);
            bool flag = false;

            try
            {
IL_C3:
                MRSMergeRequestAccessor mrsmergeRequestAccessor = new MRSMergeRequestAccessor(dataProvider, null, false);
                mrsmergeRequestAccessor.TestCreateSubscription(outlookAnywhereEndpoint, null, subscriptionSettings, targetMailbox, null, false);
            }
            catch (LocalizedException ex)
            {
                if (discoverAdminPrivilege && !flag && CommonUtils.GetExceptionSide(ex) == ExceptionSide.Source)
                {
                    Exception ex2 = ex;
                    while (ex2.InnerException != null)
                    {
                        ex2 = ex2.InnerException;
                    }
                    if (CommonUtils.ExceptionIs(ex2, new WellKnownException[]
                    {
                        WellKnownException.MapiLogonFailed
                    }))
                    {
                        if (outlookAnywhereEndpoint.MailboxPermission == MigrationMailboxPermission.Admin)
                        {
                            outlookAnywhereEndpoint.MailboxPermission = MigrationMailboxPermission.FullAccess;
                        }
                        else
                        {
                            outlookAnywhereEndpoint.MailboxPermission = MigrationMailboxPermission.Admin;
                        }
                        flag = true;
                        goto IL_C3;
                    }
                }
                throw;
            }
            return(flag);
        }
Exemplo n.º 3
0
        protected override void InternalValidate()
        {
            base.InternalValidate();
            bool          flag         = false;
            MigrationType endpointType = this.DataObject.EndpointType;

            if (endpointType <= MigrationType.ExchangeOutlookAnywhere)
            {
                if (endpointType == MigrationType.IMAP)
                {
                    this.WriteParameterErrorIfSet("Credentials");
                    this.WriteParameterErrorIfSet("MailboxPermission");
                    this.WriteParameterErrorIfSet("ExchangeServer");
                    this.WriteParameterErrorIfSet("RPCProxyServer");
                    this.WriteParameterErrorIfSet("NspiServer");
                    this.WriteParameterErrorIfSet("PublicFolderDatabaseServerLegacyDN");
                    this.WriteParameterErrorIfSet("TestMailbox", new LocalizedString?(Strings.ErrorInvalidEndpointParameterReasonUsedForConnectionTest));
                    this.WriteParameterErrorIfSet("SourceMailboxLegacyDN", new LocalizedString?(Strings.ErrorInvalidEndpointParameterReasonUsedForConnectionTest));
                    this.WriteParameterErrorIfSet("EmailAddress", new LocalizedString?(Strings.ErrorInvalidEndpointParameterReasonUsedForConnectionTest));
                    goto IL_2B4;
                }
                if (endpointType == MigrationType.ExchangeOutlookAnywhere)
                {
                    this.WriteParameterErrorIfSet("Port");
                    this.WriteParameterErrorIfSet("Security");
                    this.WriteParameterErrorIfSet("PublicFolderDatabaseServerLegacyDN");
                    goto IL_2B4;
                }
            }
            else
            {
                if (endpointType == MigrationType.ExchangeRemoteMove)
                {
                    this.WriteParameterErrorIfSet("ExchangeServer");
                    this.WriteParameterErrorIfSet("RPCProxyServer");
                    this.WriteParameterErrorIfSet("Port");
                    this.WriteParameterErrorIfSet("MailboxPermission");
                    this.WriteParameterErrorIfSet("Authentication");
                    this.WriteParameterErrorIfSet("Security");
                    this.WriteParameterErrorIfSet("NspiServer");
                    this.WriteParameterErrorIfSet("PublicFolderDatabaseServerLegacyDN");
                    this.WriteParameterErrorIfSet("TestMailbox", new LocalizedString?(Strings.ErrorInvalidEndpointParameterReasonUsedForConnectionTest));
                    this.WriteParameterErrorIfSet("SourceMailboxLegacyDN", new LocalizedString?(Strings.ErrorInvalidEndpointParameterReasonUsedForConnectionTest));
                    this.WriteParameterErrorIfSet("EmailAddress", new LocalizedString?(Strings.ErrorInvalidEndpointParameterReasonUsedForConnectionTest));
                    goto IL_2B4;
                }
                if (endpointType == MigrationType.PSTImport)
                {
                    this.WriteParameterErrorIfSet("ExchangeServer");
                    this.WriteParameterErrorIfSet("RPCProxyServer");
                    this.WriteParameterErrorIfSet("Port");
                    this.WriteParameterErrorIfSet("MailboxPermission");
                    this.WriteParameterErrorIfSet("Authentication");
                    this.WriteParameterErrorIfSet("Security");
                    this.WriteParameterErrorIfSet("NspiServer");
                    this.WriteParameterErrorIfSet("PublicFolderDatabaseServerLegacyDN");
                    this.WriteParameterErrorIfSet("TestMailbox", new LocalizedString?(Strings.ErrorInvalidEndpointParameterReasonUsedForConnectionTest));
                    this.WriteParameterErrorIfSet("SourceMailboxLegacyDN", new LocalizedString?(Strings.ErrorInvalidEndpointParameterReasonUsedForConnectionTest));
                    this.WriteParameterErrorIfSet("EmailAddress", new LocalizedString?(Strings.ErrorInvalidEndpointParameterReasonUsedForConnectionTest));
                    goto IL_2B4;
                }
                if (endpointType == MigrationType.PublicFolder)
                {
                    this.WriteParameterErrorIfSet("RemoteServer");
                    this.WriteParameterErrorIfSet("ExchangeServer");
                    this.WriteParameterErrorIfSet("Port");
                    this.WriteParameterErrorIfSet("MailboxPermission");
                    this.WriteParameterErrorIfSet("Security");
                    this.WriteParameterErrorIfSet("NspiServer");
                    this.WriteParameterErrorIfSet("EmailAddress", new LocalizedString?(Strings.ErrorInvalidEndpointParameterReasonUsedForConnectionTest));
                    goto IL_2B4;
                }
            }
            base.WriteError(new InvalidEndpointTypeException(this.Identity.RawIdentity, this.DataObject.EndpointType.ToString()));
IL_2B4:
            if (base.IsFieldSet("MaxConcurrentMigrations") || base.IsFieldSet("MaxConcurrentIncrementalSyncs"))
            {
                Unlimited <int> unlimited  = base.IsFieldSet("MaxConcurrentMigrations") ? this.MaxConcurrentMigrations : this.DataObject.MaxConcurrentMigrations;
                Unlimited <int> unlimited2 = base.IsFieldSet("MaxConcurrentIncrementalSyncs") ? this.MaxConcurrentIncrementalSyncs : this.DataObject.MaxConcurrentIncrementalSyncs;
                if (unlimited2 > unlimited)
                {
                    base.WriteError(new MigrationMaxConcurrentIncrementalSyncsVerificationFailedException(unlimited2, unlimited));
                }
            }
            if (base.IsFieldSet("MaxConcurrentMigrations") && !this.MaxConcurrentMigrations.Equals(this.DataObject.MaxConcurrentMigrations))
            {
                this.DataObject.MaxConcurrentMigrations = this.MaxConcurrentMigrations;
                this.changed = true;
            }
            if (base.IsFieldSet("MaxConcurrentIncrementalSyncs") && !this.MaxConcurrentIncrementalSyncs.Equals(this.DataObject.MaxConcurrentIncrementalSyncs))
            {
                this.DataObject.MaxConcurrentIncrementalSyncs = this.MaxConcurrentIncrementalSyncs;
                this.changed = true;
            }
            if (base.IsFieldSet("Credentials") && (this.Credentials == null || !this.Credentials.Equals(this.DataObject.Credentials)))
            {
                this.DataObject.Credentials = this.Credentials;
                this.changed = true;
                flag         = true;
            }
            if (base.IsFieldSet("MailboxPermission") && this.MailboxPermission != this.DataObject.MailboxPermission)
            {
                this.DataObject.MailboxPermission = this.MailboxPermission;
                this.changed = true;
                flag         = true;
            }
            if (base.IsFieldSet("ExchangeServer") && !this.ExchangeServer.Equals(this.DataObject.ExchangeServer))
            {
                this.DataObject.ExchangeServer = this.ExchangeServer;
                this.changed = true;
                flag         = true;
            }
            if (base.IsFieldSet("RPCProxyServer") && !this.RpcProxyServer.Equals(this.DataObject.RpcProxyServer))
            {
                this.DataObject.RpcProxyServer = this.RpcProxyServer;
                this.changed = true;
                flag         = true;
            }
            if (base.IsFieldSet("Port") && !this.Port.Equals(this.DataObject.Port))
            {
                this.DataObject.Port = new int?(this.Port);
                this.changed         = true;
                flag = true;
            }
            if (base.IsFieldSet("Authentication") && !this.Authentication.Equals(this.DataObject.Authentication))
            {
                this.DataObject.Authentication = new AuthenticationMethod?(this.Authentication);
                this.changed = true;
                flag         = true;
            }
            if (base.IsFieldSet("Security") && !this.Security.Equals(this.DataObject.Security))
            {
                this.DataObject.Security = new IMAPSecurityMechanism?(this.Security);
                this.changed             = true;
                flag = true;
            }
            if (base.IsFieldSet("RemoteServer") && !this.RemoteServer.Equals(this.DataObject.RemoteServer))
            {
                this.DataObject.RemoteServer = this.RemoteServer;
                this.changed = true;
                flag         = true;
            }
            if (base.IsFieldSet("NspiServer") && !this.NspiServer.Equals(this.DataObject.NspiServer))
            {
                this.DataObject.NspiServer = this.NspiServer;
                this.changed = true;
                flag         = true;
            }
            if (this.DataObject.EndpointType == MigrationType.PublicFolder && base.IsFieldSet("SourceMailboxLegacyDN") && !this.SourceMailboxLegacyDN.Equals(this.DataObject.SourceMailboxLegacyDN))
            {
                if (!LegacyDN.IsValidLegacyDN(this.SourceMailboxLegacyDN))
                {
                    base.WriteError(new InvalidLegacyExchangeDnValueException("SourceMailboxLegacyDN"));
                }
                this.DataObject.SourceMailboxLegacyDN = this.SourceMailboxLegacyDN;
                this.changed = true;
                flag         = true;
            }
            if (base.IsFieldSet("PublicFolderDatabaseServerLegacyDN") && !this.PublicFolderDatabaseServerLegacyDN.Equals(this.DataObject.PublicFolderDatabaseServerLegacyDN))
            {
                if (!LegacyDN.IsValidLegacyDN(this.PublicFolderDatabaseServerLegacyDN))
                {
                    base.WriteError(new InvalidLegacyExchangeDnValueException("PublicFolderDatabaseServerLegacyDN"));
                }
                this.DataObject.PublicFolderDatabaseServerLegacyDN = this.PublicFolderDatabaseServerLegacyDN;
                this.changed = true;
                flag         = true;
            }
            if (flag)
            {
                this.DataObject.LastModifiedTime = (DateTime)ExDateTime.UtcNow;
            }
            if (!this.SkipVerification)
            {
                MigrationEndpointBase migrationEndpointBase = MigrationEndpointBase.CreateFrom(this.DataObject);
                migrationEndpointBase.VerifyConnectivity();
                if (this.DataObject.EndpointType == MigrationType.ExchangeOutlookAnywhere)
                {
                    ExchangeOutlookAnywhereEndpoint exchangeOutlookAnywhereEndpoint = (ExchangeOutlookAnywhereEndpoint)migrationEndpointBase;
                    if (!string.IsNullOrEmpty(this.SourceMailboxLegacyDN) || this.EmailAddress != SmtpAddress.Empty || !string.IsNullOrEmpty(exchangeOutlookAnywhereEndpoint.EmailAddress))
                    {
                        MailboxData targetMailbox = TestMigrationServerAvailability.DiscoverTestMailbox(this.TestMailbox, ((MigrationADProvider)this.DataProvider.ADProvider).RecipientSession, base.ServerSettings, new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ADUser>), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError));
                        string      text          = (string)this.EmailAddress;
                        if (string.IsNullOrEmpty(text))
                        {
                            text = exchangeOutlookAnywhereEndpoint.EmailAddress;
                        }
                        TestMigrationServerAvailability.VerifyExchangeOutlookAnywhereConnection(this.DataProvider, exchangeOutlookAnywhereEndpoint, text, this.SourceMailboxLegacyDN, targetMailbox, false);
                        return;
                    }
                }
                else if (this.DataObject.EndpointType == MigrationType.PublicFolder)
                {
                    MailboxData mailboxData = TestMigrationServerAvailability.DiscoverPublicFolderTestMailbox(this.TestMailbox, this.ConfigurationSession, ((MigrationADProvider)this.DataProvider.ADProvider).RecipientSession, base.ServerSettings, new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ADUser>), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError));
                    TestMigrationServerAvailability.VerifyPublicFolderConnection(this.DataProvider, (PublicFolderEndpoint)migrationEndpointBase, this.SourceMailboxLegacyDN, this.PublicFolderDatabaseServerLegacyDN, mailboxData);
                }
            }
        }