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); }
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); }