コード例 #1
0
        private void InternalConfigureProviders(bool continueAfterConfiguringProviders)
        {
            RequestStatisticsBase cachedRequestJob = base.CachedRequestJob;
            bool flag = cachedRequestJob.RequestStyle == RequestStyle.CrossOrg;
            LocalMailboxFlags localMailboxFlags = LocalMailboxFlags.LegacyPublicFolders | LocalMailboxFlags.ParallelPublicFolderMigration;

            if (flag)
            {
                localMailboxFlags |= LocalMailboxFlags.PureMAPI;
            }
            this.sourceDatabases = new MapiSourceMailbox(localMailboxFlags);
            if (flag)
            {
                this.sourceDatabases.ConfigRPCHTTP(cachedRequestJob.RemoteMailboxLegacyDN, null, cachedRequestJob.RemoteMailboxServerLegacyDN, cachedRequestJob.OutlookAnywhereHostName, cachedRequestJob.RemoteCredential, true, cachedRequestJob.AuthenticationMethod != null && cachedRequestJob.AuthenticationMethod.Value == AuthenticationMethod.Ntlm);
            }
            else
            {
                ((IMailbox)this.sourceDatabases).Config(base.GetReservation(cachedRequestJob.SourceDatabase.ObjectGuid, ReservationFlags.Read), cachedRequestJob.SourceDatabase.ObjectGuid, cachedRequestJob.SourceDatabase.ObjectGuid, CommonUtils.GetPartitionHint(cachedRequestJob.OrganizationId), cachedRequestJob.SourceDatabase.ObjectGuid, MailboxType.SourceMailbox, null);
            }
            LocalizedString tracingId = flag ? MrsStrings.RPCHTTPPublicFoldersId(cachedRequestJob.RemoteMailboxLegacyDN) : MrsStrings.PublicFoldersId(cachedRequestJob.OrganizationId.ToString());

            this.sourceDatabases.ConfigPublicFolders(cachedRequestJob.SourceDatabase);
            this.SourceDatabasesWrapper = new SourceMailboxWrapper(this.sourceDatabases, MailboxWrapperFlags.Source, tracingId);
            this.publicFolderMailboxMigrator.SetSourceDatabasesWrapper(this.SourceDatabasesWrapper);
            base.ConfigureProviders(continueAfterConfiguringProviders);
            if (flag)
            {
                this.publicFolderMailboxMigrator.ConfigTranslators(new PrincipalTranslator(this.SourceDatabasesWrapper.PrincipalMapper, this.publicFolderMailboxMigrator.DestMailboxWrapper.PrincipalMapper), null);
            }
        }
コード例 #2
0
        public override void ConfigureProviders()
        {
            RequestStatisticsBase cachedRequestJob      = base.MRSJob.CachedRequestJob;
            PublicFolderRecipient localMailboxRecipient = this.publicFolderConfiguration.GetLocalMailboxRecipient(base.TargetMailboxGuid);

            if (localMailboxRecipient == null)
            {
                throw new RecipientNotFoundPermanentException(base.TargetMailboxGuid);
            }
            List <MRSProxyCapabilities> list = new List <MRSProxyCapabilities>();
            ProxyServerSettings         proxyServerSettings = CommonUtils.MapDatabaseToProxyServer(localMailboxRecipient.Database.ObjectGuid);

            list.Add(MRSProxyCapabilities.PublicFolderMigration);
            IDestinationMailbox destinationMailbox = this.GetDestinationMailbox(localMailboxRecipient.Database.ObjectGuid, proxyServerSettings.ExtraFlags | LocalMailboxFlags.Move, list);

            destinationMailbox.Config(base.MRSJob.GetReservation(localMailboxRecipient.Database.ObjectGuid, ReservationFlags.Write), base.TargetMailboxGuid, base.TargetMailboxGuid, CommonUtils.GetPartitionHint(cachedRequestJob.OrganizationId), localMailboxRecipient.Database.ObjectGuid, MailboxType.DestMailboxIntraOrg, null);
            base.ConfigDestinationMailbox(destinationMailbox);
            ADSessionSettings sessionSettings = ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(this.publicFolderConfiguration.OrganizationId);

            this.orgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(false, ConsistencyMode.PartiallyConsistent, sessionSettings, 170, "ConfigureProviders", "f:\\15.00.1497\\sources\\dev\\mrs\\src\\Service\\PublicFolderMailboxMigrator.cs");
            if (!CommonUtils.IsMultiTenantEnabled() && !base.Flags.HasFlag(MailboxCopierFlags.CrossOrg))
            {
                this.orgRecipientSession.EnforceDefaultScope = false;
                this.orgRecipientSession.UseGlobalCatalog    = true;
            }
            ArgumentValidator.ThrowIfNull("orgRecipientSession", this.orgRecipientSession);
        }
コード例 #3
0
        internal static RequestStatisticsBase CreateRequestStatistics(Type t, RequestJobXML rj, bool acceptBase)
        {
            RequestStatisticsBase requestStatisticsBase = null;

            if (t.Equals(typeof(MoveRequestStatistics)))
            {
                requestStatisticsBase = new MoveRequestStatistics(rj);
            }
            else if (t.Equals(typeof(MergeRequestStatistics)))
            {
                requestStatisticsBase = new MergeRequestStatistics(rj);
            }
            else if (t.Equals(typeof(MailboxImportRequestStatistics)))
            {
                requestStatisticsBase = new MailboxImportRequestStatistics(rj);
            }
            else if (t.Equals(typeof(MailboxExportRequestStatistics)))
            {
                requestStatisticsBase = new MailboxExportRequestStatistics(rj);
            }
            else if (t.Equals(typeof(MailboxRelocationRequestStatistics)))
            {
                requestStatisticsBase = new MailboxRelocationRequestStatistics(rj);
            }
            else if (t.Equals(typeof(MailboxRestoreRequestStatistics)))
            {
                requestStatisticsBase = new MailboxRestoreRequestStatistics(rj);
            }
            else if (t.Equals(typeof(PublicFolderMoveRequestStatistics)))
            {
                requestStatisticsBase = new PublicFolderMoveRequestStatistics(rj);
            }
            else if (t.Equals(typeof(PublicFolderMigrationRequestStatistics)))
            {
                requestStatisticsBase = new PublicFolderMigrationRequestStatistics(rj);
            }
            else if (t.Equals(typeof(PublicFolderMailboxMigrationRequestStatistics)))
            {
                requestStatisticsBase = new PublicFolderMailboxMigrationRequestStatistics(rj);
            }
            else if (t.Equals(typeof(SyncRequestStatistics)))
            {
                requestStatisticsBase = new SyncRequestStatistics(rj);
            }
            else if (t.Equals(typeof(FolderMoveRequestStatistics)))
            {
                requestStatisticsBase = new FolderMoveRequestStatistics(rj);
            }
            else if (acceptBase && t.Equals(typeof(RequestStatisticsBase)))
            {
                return(RequestJobProvider.CreateRequestStatistics(rj));
            }
            if (requestStatisticsBase != null)
            {
                rj.Retire();
            }
            return(requestStatisticsBase);
        }
コード例 #4
0
 public static void ProcessMoveRequestCreatedNotification(Guid requestGuid, Guid mdbGuid)
 {
     using (RequestJobProvider requestJobProvider = new RequestJobProvider(mdbGuid))
     {
         RequestStatisticsBase moveRequest = (RequestStatisticsBase)requestJobProvider.Read <RequestStatisticsBase>(new RequestJobObjectId(requestGuid, mdbGuid, null));
         if (moveRequest != null && !(moveRequest.ValidationResult != RequestJobBase.ValidationResultEnum.Valid))
         {
             if (moveRequest.RequestStyle == RequestStyle.CrossOrg && moveRequest.RequestType == MRSRequestType.Move)
             {
                 CommonUtils.CatchKnownExceptions(delegate
                 {
                     Guid physicalMailboxGuid            = moveRequest.ArchiveOnly ? (moveRequest.ArchiveGuid ?? Guid.Empty) : moveRequest.ExchangeGuid;
                     ProxyControlFlags proxyControlFlags = ProxyControlFlags.DoNotApplyProxyThrottling | moveRequest.GetProxyControlFlags();
                     IMailbox mailbox;
                     MailboxType mbxType;
                     Guid mdbGuid2;
                     if (moveRequest.Direction == RequestDirection.Pull)
                     {
                         if ((moveRequest.Flags & RequestFlags.RemoteLegacy) != RequestFlags.None)
                         {
                             mailbox = new MapiSourceMailbox(LocalMailboxFlags.None);
                             mailbox.ConfigADConnection(moveRequest.SourceDCName, moveRequest.SourceDCName, moveRequest.SourceCredential);
                         }
                         else
                         {
                             mailbox = new RemoteSourceMailbox(moveRequest.RemoteHostName, moveRequest.RemoteOrgName, moveRequest.RemoteCredential, proxyControlFlags, null, true, LocalMailboxFlags.None);
                         }
                         mbxType  = MailboxType.SourceMailbox;
                         mdbGuid2 = Guid.Empty;
                     }
                     else
                     {
                         if ((moveRequest.Flags & RequestFlags.RemoteLegacy) != RequestFlags.None)
                         {
                             mailbox = new MapiDestinationMailbox(LocalMailboxFlags.None);
                             mailbox.ConfigADConnection(moveRequest.TargetDCName, moveRequest.TargetDCName, moveRequest.TargetCredential);
                         }
                         else
                         {
                             mailbox = new RemoteDestinationMailbox(moveRequest.RemoteHostName, moveRequest.RemoteOrgName, moveRequest.RemoteCredential, proxyControlFlags, null, true, LocalMailboxFlags.None);
                         }
                         mbxType  = MailboxType.DestMailboxCrossOrg;
                         mdbGuid2 = ((moveRequest.ArchiveOnly ? moveRequest.RemoteArchiveDatabaseGuid : moveRequest.RemoteDatabaseGuid) ?? Guid.Empty);
                     }
                     using (mailbox)
                     {
                         mailbox.Config(null, moveRequest.ExchangeGuid, physicalMailboxGuid, null, mdbGuid2, mbxType, null);
                         mailbox.Connect(MailboxConnectFlags.None);
                         mailbox.UpdateRemoteHostName(moveRequest.UserOrgName);
                         mailbox.Disconnect();
                     }
                 }, null);
             }
         }
     }
 }
コード例 #5
0
        internal static RequestStatisticsBase CreateRequestStatistics(RequestJobXML rj)
        {
            RequestStatisticsBase requestStatisticsBase = null;

            switch (rj.RequestType)
            {
            case MRSRequestType.Move:
                requestStatisticsBase = new MoveRequestStatistics(rj);
                break;

            case MRSRequestType.Merge:
                requestStatisticsBase = new MergeRequestStatistics(rj);
                break;

            case MRSRequestType.MailboxImport:
                requestStatisticsBase = new MailboxImportRequestStatistics(rj);
                break;

            case MRSRequestType.MailboxExport:
                requestStatisticsBase = new MailboxExportRequestStatistics(rj);
                break;

            case MRSRequestType.MailboxRestore:
                requestStatisticsBase = new MailboxRestoreRequestStatistics(rj);
                break;

            case MRSRequestType.PublicFolderMove:
                requestStatisticsBase = new PublicFolderMoveRequestStatistics(rj);
                break;

            case MRSRequestType.PublicFolderMigration:
                requestStatisticsBase = new PublicFolderMigrationRequestStatistics(rj);
                break;

            case MRSRequestType.Sync:
                requestStatisticsBase = new SyncRequestStatistics(rj);
                break;

            case MRSRequestType.MailboxRelocation:
                requestStatisticsBase = new MailboxRelocationRequestStatistics(rj);
                break;

            case MRSRequestType.FolderMove:
                requestStatisticsBase = new FolderMoveRequestStatistics(rj);
                break;

            case MRSRequestType.PublicFolderMailboxMigration:
                requestStatisticsBase = new PublicFolderMailboxMigrationRequestStatistics(rj);
                break;
            }
            if (requestStatisticsBase != null)
            {
                rj.Retire();
            }
            return(requestStatisticsBase);
        }
コード例 #6
0
 private static void PerformLightJobAction(MapiStore systemMailbox, RequestStatisticsBase requestJobStats)
 {
     CommonUtils.CatchKnownExceptions(delegate
     {
         bool flag = false;
         LightJobBase lightJobBase;
         if (QuarantinedJobs.Contains(requestJobStats.IdentifyingGuid))
         {
             lightJobBase = new QuarantineJob(requestJobStats.IdentifyingGuid, requestJobStats.WorkItemQueueMdb.ObjectGuid, systemMailbox, requestJobStats.MessageId);
         }
         else if (requestJobStats.ShouldRehomeRequest)
         {
             lightJobBase = new RehomeJob(requestJobStats.IdentifyingGuid, requestJobStats.RequestQueue, requestJobStats.OptimalRequestQueue, systemMailbox, requestJobStats.MessageId);
         }
         else if (requestJobStats.ShouldClearRehomeRequest)
         {
             lightJobBase = new ClearRehomeJob(requestJobStats.IdentifyingGuid, requestJobStats.WorkItemQueueMdb.ObjectGuid, systemMailbox, requestJobStats.MessageId);
         }
         else if (requestJobStats.ShouldSuspendRequest)
         {
             lightJobBase = new SuspendJob(requestJobStats.IdentifyingGuid, requestJobStats.WorkItemQueueMdb.ObjectGuid, systemMailbox, requestJobStats.MessageId);
         }
         else
         {
             lightJobBase = new ResumeJob(requestJobStats.IdentifyingGuid, requestJobStats.WorkItemQueueMdb.ObjectGuid, systemMailbox, requestJobStats.MessageId);
             flag         = true;
         }
         using (lightJobBase)
         {
             lightJobBase.Run();
             if (flag)
             {
                 MRSService.Tickle(requestJobStats.IdentifyingGuid, requestJobStats.WorkItemQueueMdb.ObjectGuid, MoveRequestNotification.Created);
             }
         }
     }, delegate(Exception failure)
     {
         LocalizedString localizedString = CommonUtils.FullExceptionMessage(failure);
         MrsTracer.Service.Debug("Unexpected failure occurred trying to perform a light pipe action on MoveJob '{0}' from queue '{1}', skipping it. {2}", new object[]
         {
             requestJobStats.RequestGuid,
             requestJobStats.RequestQueue,
             localizedString
         });
         MailboxReplicationService.LogEvent(MRSEventLogConstants.Tuple_UnableToProcessRequest, new object[]
         {
             requestJobStats.RequestGuid.ToString(),
             requestJobStats.WorkItemQueueMdb.ObjectGuid.ToString(),
             localizedString
         });
     });
 }
コード例 #7
0
        internal static RequestStatisticsBase CreateRequestStatistics(TransactionalRequestJob rj)
        {
            RequestStatisticsBase result = null;

            switch (rj.RequestType)
            {
            case MRSRequestType.Move:
                result = new MoveRequestStatistics(rj);
                break;

            case MRSRequestType.Merge:
                result = new MergeRequestStatistics(rj);
                break;

            case MRSRequestType.MailboxImport:
                result = new MailboxImportRequestStatistics(rj);
                break;

            case MRSRequestType.MailboxExport:
                result = new MailboxExportRequestStatistics(rj);
                break;

            case MRSRequestType.MailboxRestore:
                result = new MailboxRestoreRequestStatistics(rj);
                break;

            case MRSRequestType.PublicFolderMove:
                result = new PublicFolderMoveRequestStatistics(rj);
                break;

            case MRSRequestType.PublicFolderMigration:
                result = new PublicFolderMigrationRequestStatistics(rj);
                break;

            case MRSRequestType.Sync:
                result = new SyncRequestStatistics(rj);
                break;

            case MRSRequestType.MailboxRelocation:
                result = new MailboxRelocationRequestStatistics(rj);
                break;

            case MRSRequestType.FolderMove:
                result = new FolderMoveRequestStatistics(rj);
                break;

            case MRSRequestType.PublicFolderMailboxMigration:
                result = new PublicFolderMailboxMigrationRequestStatistics(rj);
                break;
            }
            return(result);
        }
コード例 #8
0
        private void InternalConfigureProviders(bool continueAfterConfiguringProviders)
        {
            if (this.publicFolderConfiguration.GetHierarchyMailboxInformation().Type != PublicFolderInformation.HierarchyType.InTransitMailboxGuid)
            {
                throw new PublicFolderMailboxesNotProvisionedForMigrationException();
            }
            RequestStatisticsBase cachedRequestJob = base.CachedRequestJob;
            bool flag = cachedRequestJob.RequestStyle == RequestStyle.CrossOrg;
            LocalMailboxFlags localMailboxFlags = LocalMailboxFlags.LegacyPublicFolders;

            if (flag)
            {
                localMailboxFlags |= LocalMailboxFlags.PureMAPI;
            }
            this.sourceDatabases = new MapiSourceMailbox(localMailboxFlags);
            if (flag)
            {
                this.sourceDatabases.ConfigRPCHTTP(cachedRequestJob.RemoteMailboxLegacyDN, null, cachedRequestJob.RemoteMailboxServerLegacyDN, cachedRequestJob.OutlookAnywhereHostName, cachedRequestJob.RemoteCredential, true, cachedRequestJob.AuthenticationMethod != null && cachedRequestJob.AuthenticationMethod.Value == AuthenticationMethod.Ntlm);
            }
            else
            {
                ((IMailbox)this.sourceDatabases).Config(base.GetReservation(cachedRequestJob.SourceDatabase.ObjectGuid, ReservationFlags.Read), cachedRequestJob.SourceDatabase.ObjectGuid, cachedRequestJob.SourceDatabase.ObjectGuid, CommonUtils.GetPartitionHint(cachedRequestJob.OrganizationId), cachedRequestJob.SourceDatabase.ObjectGuid, MailboxType.SourceMailbox, null);
            }
            LocalizedString tracingId = flag ? MrsStrings.RPCHTTPPublicFoldersId(cachedRequestJob.RemoteMailboxLegacyDN) : MrsStrings.PublicFoldersId(cachedRequestJob.OrganizationId.ToString());

            this.sourceDatabases.ConfigPublicFolders(cachedRequestJob.SourceDatabase);
            this.SourceDatabasesWrapper = new SourceMailboxWrapper(this.sourceDatabases, MailboxWrapperFlags.Source, tracingId);
            foreach (MailboxCopierBase mailboxCopierBase in this.GetAllCopiers())
            {
                PublicFolderMigrator publicFolderMigrator = (PublicFolderMigrator)mailboxCopierBase;
                publicFolderMigrator.SetSourceDatabasesWrapper(this.SourceDatabasesWrapper);
            }
            base.ConfigureProviders(continueAfterConfiguringProviders);
            MailboxCopierBase rootMailboxContext = base.GetRootMailboxContext();

            foreach (MailboxCopierBase mailboxCopierBase2 in this.GetAllCopiers())
            {
                PublicFolderMigrator publicFolderMigrator2 = (PublicFolderMigrator)mailboxCopierBase2;
                if (!publicFolderMigrator2.IsRoot)
                {
                    publicFolderMigrator2.SetHierarchyMailbox(rootMailboxContext.DestMailbox);
                }
                if (flag)
                {
                    publicFolderMigrator2.ConfigTranslators(new PrincipalTranslator(this.SourceDatabasesWrapper.PrincipalMapper, publicFolderMigrator2.DestMailboxWrapper.PrincipalMapper), null);
                }
            }
        }
コード例 #9
0
        public override void ConfigureProviders()
        {
            RequestStatisticsBase cachedRequestJob      = base.MRSJob.CachedRequestJob;
            PublicFolderRecipient localMailboxRecipient = this.publicFolderConfiguration.GetLocalMailboxRecipient(base.TargetMailboxGuid);

            if (localMailboxRecipient == null)
            {
                throw new RecipientNotFoundPermanentException(base.TargetMailboxGuid);
            }
            List <MRSProxyCapabilities> list = new List <MRSProxyCapabilities>();
            ProxyServerSettings         proxyServerSettings = CommonUtils.MapDatabaseToProxyServer(localMailboxRecipient.Database.ObjectGuid);

            list.Add(MRSProxyCapabilities.PublicFolderMigration);
            IDestinationMailbox destinationMailbox = this.GetDestinationMailbox(localMailboxRecipient.Database.ObjectGuid, proxyServerSettings.ExtraFlags | LocalMailboxFlags.Move, list);

            destinationMailbox.Config(base.MRSJob.GetReservation(localMailboxRecipient.Database.ObjectGuid, ReservationFlags.Write), base.TargetMailboxGuid, base.TargetMailboxGuid, CommonUtils.GetPartitionHint(cachedRequestJob.OrganizationId), localMailboxRecipient.Database.ObjectGuid, MailboxType.DestMailboxIntraOrg, null);
            base.ConfigDestinationMailbox(destinationMailbox);
        }
コード例 #10
0
 protected MRSRequestIdParameter(RequestStatisticsBase requestStats)
 {
     if (requestStats == null)
     {
         throw new ArgumentNullException("requestStats");
     }
     if (requestStats.RequestType != this.RequestType)
     {
         throw new ArgumentException(MrsStrings.ImproperTypeForThisIdParameter, "requestStats");
     }
     this.indexToUse       = null;
     this.indexIds         = requestStats.IndexIds;
     this.requestGuid      = requestStats.RequestGuid;
     this.mailboxName      = null;
     this.mailboxId        = null;
     this.requestName      = null;
     this.organizationId   = requestStats.OrganizationId;
     this.organizationName = null;
     this.rawIdentity      = null;
 }
コード例 #11
0
        public override void ConfigureProviders()
        {
            base.ConfigureProviders();
            RequestStatisticsBase cachedRequestJob   = base.MRSJob.CachedRequestJob;
            LocalMailboxFlags     localMailboxFlags  = LocalMailboxFlags.None;
            LocalMailboxFlags     localMailboxFlags2 = LocalMailboxFlags.None;

            if (cachedRequestJob.RequestType != MRSRequestType.MailboxRestore && cachedRequestJob.IgnoreRuleLimitErrors)
            {
                localMailboxFlags |= LocalMailboxFlags.StripLargeRulesForDownlevelTargets;
            }
            if (cachedRequestJob.OrganizationId == null)
            {
                OrganizationId forestWideOrgId = OrganizationId.ForestWideOrgId;
            }
            switch (cachedRequestJob.RequestType)
            {
            case MRSRequestType.Merge:
                if (cachedRequestJob.SourceIsLocal)
                {
                    localMailboxFlags |= LocalMailboxFlags.UseHomeMDB;
                }
                else
                {
                    localMailboxFlags |= LocalMailboxFlags.PureMAPI;
                }
                if (cachedRequestJob.TargetIsLocal)
                {
                    localMailboxFlags2 |= LocalMailboxFlags.UseHomeMDB;
                }
                else
                {
                    localMailboxFlags2 |= LocalMailboxFlags.PureMAPI;
                }
                break;

            case MRSRequestType.MailboxImport:
                localMailboxFlags2 |= LocalMailboxFlags.UseHomeMDB;
                break;

            case MRSRequestType.MailboxExport:
                localMailboxFlags |= LocalMailboxFlags.UseHomeMDB;
                break;

            case MRSRequestType.MailboxRestore:
                localMailboxFlags2 |= LocalMailboxFlags.UseHomeMDB;
                localMailboxFlags  |= LocalMailboxFlags.Restore;
                break;

            case MRSRequestType.Sync:
                localMailboxFlags2 |= LocalMailboxFlags.UseHomeMDB;
                if (cachedRequestJob.Flags.HasFlag(RequestFlags.TargetIsAggregatedMailbox))
                {
                    localMailboxFlags2 |= LocalMailboxFlags.AggregatedMailbox;
                }
                if (cachedRequestJob.SyncProtocol == SyncProtocol.Olc)
                {
                    localMailboxFlags2 |= LocalMailboxFlags.OlcSync;
                }
                break;
            }
            ISourceMailbox      sourceMailbox      = null;
            IDestinationMailbox destinationMailbox = null;

            switch (cachedRequestJob.RequestType)
            {
            case MRSRequestType.Merge:
            case MRSRequestType.MailboxExport:
            case MRSRequestType.MailboxRestore:
            {
                Guid primaryMailboxGuid = base.SourceMailboxGuid;
                Guid guid = cachedRequestJob.SourceMDBGuid;
                if (cachedRequestJob.SourceUser != null)
                {
                    primaryMailboxGuid = cachedRequestJob.SourceUser.ExchangeGuid;
                    if (localMailboxFlags.HasFlag(LocalMailboxFlags.UseHomeMDB))
                    {
                        ADObjectId adobjectId = cachedRequestJob.SourceIsArchive ? cachedRequestJob.SourceUser.ArchiveDatabase : cachedRequestJob.SourceUser.Database;
                        if (adobjectId != null)
                        {
                            guid = adobjectId.ObjectGuid;
                        }
                    }
                }
                sourceMailbox = this.GetSourceMailbox(new ADObjectId(guid, PartitionId.LocalForest.ForestFQDN), localMailboxFlags, null);
                sourceMailbox.Config(base.MRSJob.GetReservation(cachedRequestJob.SourceMDBGuid, ReservationFlags.Read), primaryMailboxGuid, base.SourceMailboxGuid, CommonUtils.GetPartitionHint(cachedRequestJob.OrganizationId), guid, MailboxType.SourceMailbox, null);
                if (cachedRequestJob.RequestType == MRSRequestType.MailboxRestore)
                {
                    sourceMailbox.ConfigRestore((cachedRequestJob.MailboxRestoreFlags != null) ? cachedRequestJob.MailboxRestoreFlags.Value : MailboxRestoreType.None);
                }
                break;
            }

            case MRSRequestType.MailboxImport:
                sourceMailbox = this.GetSourceMailbox(new ADObjectId(Guid.Empty), localMailboxFlags, null);
                sourceMailbox.ConfigPst(cachedRequestJob.FilePath, cachedRequestJob.ContentCodePage);
                break;

            case MRSRequestType.Sync:
            {
                sourceMailbox = this.GetSourceMailbox(new ADObjectId(Guid.Empty), localMailboxFlags, null);
                SyncProtocol syncProtocol = cachedRequestJob.SyncProtocol;
                if (syncProtocol == SyncProtocol.Eas)
                {
                    sourceMailbox.ConfigEas(cachedRequestJob.RemoteCredential, cachedRequestJob.EmailAddress, cachedRequestJob.TargetExchangeGuid, cachedRequestJob.SourceServer);
                }
                break;
            }
            }
            switch (cachedRequestJob.RequestType)
            {
            case MRSRequestType.Merge:
            case MRSRequestType.MailboxImport:
            case MRSRequestType.MailboxRestore:
            case MRSRequestType.Sync:
            {
                Guid primaryMailboxGuid2 = base.TargetMailboxGuid;
                Guid mdbGuid             = cachedRequestJob.TargetMDBGuid;
                if (cachedRequestJob.TargetUser != null)
                {
                    primaryMailboxGuid2 = cachedRequestJob.TargetUser.ExchangeGuid;
                    ADObjectId adobjectId2 = cachedRequestJob.TargetIsArchive ? cachedRequestJob.TargetUser.ArchiveDatabase : cachedRequestJob.TargetUser.Database;
                    if (adobjectId2 != null)
                    {
                        mdbGuid = adobjectId2.ObjectGuid;
                    }
                }
                destinationMailbox = this.GetDestinationMailbox(mdbGuid, localMailboxFlags2, null);
                if (cachedRequestJob.RequestType == MRSRequestType.Sync && localMailboxFlags2.HasFlag(LocalMailboxFlags.AggregatedMailbox) && !string.IsNullOrEmpty(cachedRequestJob.DomainControllerToUpdate))
                {
                    destinationMailbox.ConfigPreferredADConnection(cachedRequestJob.DomainControllerToUpdate);
                }
                destinationMailbox.Config(base.MRSJob.GetReservation(cachedRequestJob.TargetMDBGuid, ReservationFlags.Write), primaryMailboxGuid2, base.TargetMailboxGuid, CommonUtils.GetPartitionHint(cachedRequestJob.OrganizationId), mdbGuid, cachedRequestJob.TargetIsLocal ? MailboxType.DestMailboxIntraOrg : MailboxType.DestMailboxCrossOrg, null);
                if (cachedRequestJob.IsPublicFolderMailboxRestore && cachedRequestJob.RequestType == MRSRequestType.MailboxRestore)
                {
                    MailboxRestoreType restoreFlags = (cachedRequestJob.MailboxRestoreFlags != null) ? (cachedRequestJob.MailboxRestoreFlags.Value & ~MailboxRestoreType.Recovery) : MailboxRestoreType.None;
                    destinationMailbox.ConfigRestore(restoreFlags);
                }
                break;
            }

            case MRSRequestType.MailboxExport:
                destinationMailbox = this.GetDestinationMailbox(Guid.Empty, localMailboxFlags2, null);
                destinationMailbox.ConfigPst(cachedRequestJob.FilePath, null);
                destinationMailbox.Config(null, Guid.Empty, Guid.Empty, cachedRequestJob.PartitionHint, Guid.Empty, cachedRequestJob.TargetIsLocal ? MailboxType.DestMailboxIntraOrg : MailboxType.DestMailboxCrossOrg, null);
                break;
            }
            if (cachedRequestJob.RequestType == MRSRequestType.Merge && cachedRequestJob.RequestStyle == RequestStyle.CrossOrg)
            {
                bool credentialIsAdmin = cachedRequestJob.IsAdministrativeCredential == null || cachedRequestJob.IsAdministrativeCredential.Value;
                bool useNTLMAuth       = cachedRequestJob.AuthenticationMethod != null && cachedRequestJob.AuthenticationMethod.Value == AuthenticationMethod.Ntlm;
                if (cachedRequestJob.Direction == RequestDirection.Pull)
                {
                    ((MapiSourceMailbox)sourceMailbox).ConfigRPCHTTP(cachedRequestJob.RemoteMailboxLegacyDN, cachedRequestJob.RemoteUserLegacyDN, cachedRequestJob.RemoteMailboxServerLegacyDN, cachedRequestJob.OutlookAnywhereHostName, cachedRequestJob.RemoteCredential, credentialIsAdmin, useNTLMAuth);
                }
                else
                {
                    ((MapiDestinationMailbox)destinationMailbox).ConfigRPCHTTP(cachedRequestJob.RemoteMailboxLegacyDN, cachedRequestJob.RemoteUserLegacyDN, cachedRequestJob.RemoteMailboxServerLegacyDN, cachedRequestJob.OutlookAnywhereHostName, cachedRequestJob.RemoteCredential, credentialIsAdmin, useNTLMAuth);
                }
            }
            base.Config(sourceMailbox, destinationMailbox);
            FolderHierarchyFlags folderHierarchyFlags = FolderHierarchyFlags.None;

            if (cachedRequestJob.IsPublicFolderMailboxRestore)
            {
                folderHierarchyFlags |= FolderHierarchyFlags.PublicFolderMailbox;
            }
            this.SourceHierarchy = new FolderHierarchy(folderHierarchyFlags, base.SourceMailboxWrapper);
            this.DestHierarchy   = new FolderHierarchy(folderHierarchyFlags, base.DestMailboxWrapper);
            FolderIdTranslator  folderIdTranslator = new FolderIdTranslator(this.SourceHierarchy, this.DestHierarchy);
            PrincipalTranslator principalTranslator;

            if (cachedRequestJob.RequestStyle == RequestStyle.CrossOrg)
            {
                principalTranslator = new PrincipalTranslator(base.SourceMailboxWrapper.PrincipalMapper, base.DestMailboxWrapper.PrincipalMapper);
            }
            else
            {
                principalTranslator = null;
            }
            base.ConfigTranslators(principalTranslator, folderIdTranslator);
        }
コード例 #12
0
        public override void ConfigureProviders()
        {
            base.ConfigureProviders();
            RequestStatisticsBase       cachedRequestJob  = base.MRSJob.CachedRequestJob;
            LocalMailboxFlags           localMailboxFlags = LocalMailboxFlags.Move;
            List <MRSProxyCapabilities> list = new List <MRSProxyCapabilities>();

            if (cachedRequestJob.IgnoreRuleLimitErrors)
            {
                localMailboxFlags |= LocalMailboxFlags.StripLargeRulesForDownlevelTargets;
            }
            if (cachedRequestJob.IsSplitPrimaryAndArchive)
            {
                list.Add(MRSProxyCapabilities.ArchiveSeparation);
            }
            if (cachedRequestJob.TargetContainerGuid != null)
            {
                list.Add(MRSProxyCapabilities.ContainerOperations);
            }
            LocalMailboxFlags localMailboxFlags2 = LocalMailboxFlags.Move;

            if (base.Flags.HasFlag(MailboxCopierFlags.ContainerAggregated))
            {
                localMailboxFlags  |= LocalMailboxFlags.AggregatedMailbox;
                localMailboxFlags2 |= LocalMailboxFlags.AggregatedMailbox;
            }
            if (cachedRequestJob.RequestType == MRSRequestType.Move && base.IsRoot && base.IsPrimary && base.TargetMailboxContainerGuid != null)
            {
                localMailboxFlags2 |= LocalMailboxFlags.CreateNewPartition;
            }
            ADObjectId adobjectId = base.IsRoot ? cachedRequestJob.SourceDatabase : cachedRequestJob.SourceArchiveDatabase;

            if (base.Flags.HasFlag(MailboxCopierFlags.SourceIsArchive) && cachedRequestJob.JobType >= MRSJobType.RequestJobE14R5_PrimaryOrArchiveExclusiveMoves)
            {
                MrsTracer.Service.Debug("Overwriting archive guid in Archive MailboxMover...", new object[0]);
                ADObjectId adobjectId2;
                if ((adobjectId2 = cachedRequestJob.SourceArchiveDatabase) == null)
                {
                    adobjectId2 = new ADObjectId(cachedRequestJob.RemoteArchiveDatabaseGuid ?? Guid.Empty);
                }
                adobjectId         = adobjectId2;
                base.SourceMdbGuid = adobjectId.ObjectGuid;
                base.DestMdbGuid   = ((cachedRequestJob.TargetArchiveDatabase != null) ? cachedRequestJob.TargetArchiveDatabase.ObjectGuid : (cachedRequestJob.RemoteArchiveDatabaseGuid ?? Guid.Empty));
            }
            ISourceMailbox      sourceMailbox      = this.GetSourceMailbox(adobjectId, localMailboxFlags, list);
            IDestinationMailbox destinationMailbox = this.GetDestinationMailbox(base.DestMdbGuid, localMailboxFlags2, list);

            if (cachedRequestJob.RequestStyle == RequestStyle.CrossOrg && (cachedRequestJob.Flags & RequestFlags.RemoteLegacy) != RequestFlags.None)
            {
                if (cachedRequestJob.Direction == RequestDirection.Push)
                {
                    destinationMailbox.ConfigADConnection(cachedRequestJob.TargetDCName, cachedRequestJob.TargetDCName, cachedRequestJob.TargetCredential);
                }
                else
                {
                    sourceMailbox.ConfigADConnection(cachedRequestJob.SourceDCName, cachedRequestJob.SourceDCName, cachedRequestJob.SourceCredential);
                }
            }
            TenantPartitionHint partitionHint  = (cachedRequestJob.SourceIsLocal || cachedRequestJob.CrossResourceForest) ? this.partitionHintToUse : null;
            TenantPartitionHint partitionHint2 = (cachedRequestJob.TargetIsLocal || cachedRequestJob.CrossResourceForest) ? this.partitionHintToUse : null;

            if (base.MRSJob.TestIntegration.RemoteExchangeGuidOverride != Guid.Empty)
            {
                if (!cachedRequestJob.SourceIsLocal)
                {
                    partitionHint = this.partitionHintToUse;
                }
                if (!cachedRequestJob.TargetIsLocal)
                {
                    partitionHint2 = this.partitionHintToUse;
                }
            }
            Guid primaryMailboxGuid = base.Flags.HasFlag(MailboxCopierFlags.ContainerOrg) ? base.SourceMailboxGuid : cachedRequestJob.ExchangeGuid;

            sourceMailbox.Config(base.MRSJob.GetReservation(base.SourceMdbGuid, ReservationFlags.Read), primaryMailboxGuid, base.SourceMailboxGuid, partitionHint, base.SourceMdbGuid, MailboxType.SourceMailbox, null);
            destinationMailbox.Config(base.MRSJob.GetReservation(base.DestMdbGuid, ReservationFlags.Write), primaryMailboxGuid, base.TargetMailboxGuid, partitionHint2, base.DestMdbGuid, (cachedRequestJob.RequestStyle == RequestStyle.CrossOrg) ? MailboxType.DestMailboxCrossOrg : MailboxType.DestMailboxIntraOrg, base.TargetMailboxContainerGuid);
            base.Config(sourceMailbox, destinationMailbox);
        }
コード例 #13
0
        private static void CleanADOrphanAndInconsistencyForNonMoves(IConfigurationSession configSession, MRSRequestType requestType, RequestJobProvider rjProvider, Guid dbGuid)
        {
            ADObjectId requestQueueId = new ADObjectId(dbGuid);
            RequestIndexEntryQueryFilter requestIndexEntryQueryFilter = new RequestIndexEntryQueryFilter();

            requestIndexEntryQueryFilter.IndexId        = new RequestIndexId(RequestIndexLocation.AD);
            requestIndexEntryQueryFilter.RequestType    = requestType;
            requestIndexEntryQueryFilter.RequestQueueId = requestQueueId;
            MRSRequestWrapper[] array = ADHandler.Find(configSession, requestIndexEntryQueryFilter, null, true, null);
            if (array != null && array.Length > 0)
            {
                bool needUpdateAD          = false;
                MRSRequestWrapper[] array2 = array;
                for (int i = 0; i < array2.Length; i++)
                {
                    MRSRequestWrapper request = array2[i];
                    CommonUtils.CatchKnownExceptions(delegate
                    {
                        needUpdateAD = false;
                        if (request.Status != RequestStatus.None)
                        {
                            RequestStatisticsBase requestStatisticsBase = (RequestStatisticsBase)rjProvider.Read <RequestStatisticsBase>(new RequestJobObjectId(request.RequestGuid, dbGuid, null));
                            if (requestStatisticsBase == null || (!requestStatisticsBase.IsFake && requestStatisticsBase.Status == RequestStatus.None))
                            {
                                MrsTracer.Service.Debug("CleanADOrphanAndInconsistencyForRequests():AD orphan {0} found for DB {1}", new object[]
                                {
                                    request.RequestGuid,
                                    dbGuid
                                });
                                ADHandler.Delete(configSession, request);
                                return;
                            }
                            if (requestStatisticsBase.IsFake)
                            {
                                MrsTracer.Service.Debug("CleanADOrphanAndInconsistencyForRequests():request {0} is uplevel/Fake, ignoring it", new object[]
                                {
                                    request.RequestGuid
                                });
                                return;
                            }
                            if (requestStatisticsBase.IndexEntries == null || requestStatisticsBase.IndexEntries.Count == 0)
                            {
                                MrsTracer.Service.Debug("CleanADOrphanAndInconsistencyForRequests():request {0} has been removed from AD, ignoring it", new object[]
                                {
                                    request.RequestGuid
                                });
                                return;
                            }
                            if (requestStatisticsBase.TimeTracker.GetCurrentDurationChunk() > ADInconsistencyCheck.updateLatencyThreshhold)
                            {
                                if (requestStatisticsBase.Status != requestStatisticsBase.IndexEntries[0].Status)
                                {
                                    MrsTracer.Service.Debug("CleanADOrphanAndInconsistencyForRequests():AD inconsistency {0} found for DB {1}, AD status is {2} but store status is {3}", new object[]
                                    {
                                        request.RequestGuid,
                                        dbGuid,
                                        request.Status,
                                        requestStatisticsBase.Status
                                    });
                                    request.Status = requestStatisticsBase.Status;
                                    needUpdateAD   = true;
                                }
                                if (requestStatisticsBase.Flags != requestStatisticsBase.IndexEntries[0].Flags)
                                {
                                    MrsTracer.Service.Debug("CleanADOrphanAndInconsistencyForRequests():AD inconsistency {0} found for DB {1}, AD flags is {2} but store flags is {3}", new object[]
                                    {
                                        request.RequestGuid,
                                        dbGuid,
                                        request.Flags,
                                        requestStatisticsBase.Flags
                                    });
                                    request.Flags = requestStatisticsBase.Flags;
                                    needUpdateAD  = true;
                                }
                                if (needUpdateAD)
                                {
                                    ADHandler.Save(configSession, request);
                                    return;
                                }
                            }
                        }
                        else
                        {
                            MrsTracer.Service.Debug("CleanADOrphanAndInconsistencyForRequests():request {0} for {1} has been removed from AD, store orphan will be handled by MRS pick up job logic", new object[]
                            {
                                request.RequestGuid,
                                dbGuid
                            });
                        }
                    }, delegate(Exception f)
                    {
                        MrsTracer.Service.Error("CleanADOrphanAndInconsistencyForRequests() failed for DB {0}. Request type {1} Request guid {2} Error: {3}", new object[]
                        {
                            dbGuid,
                            requestType.ToString(),
                            request.RequestGuid,
                            CommonUtils.FullExceptionMessage(f, true)
                        });
                        MRSService.LogEvent(MRSEventLogConstants.Tuple_ScanADInconsistencyRequestFailEvent, new object[]
                        {
                            dbGuid,
                            requestType.ToString(),
                            request.RequestGuid,
                            CommonUtils.FullExceptionMessage(f, true)
                        });
                    });
                }
                return;
            }
            MrsTracer.Service.Debug("CleanADOrphanAndInconsistencyForRequests(): No {0} requests found for DB {1}", new object[]
            {
                requestType,
                dbGuid
            });
        }
コード例 #14
0
        private List <T> InternalFind <T>(QueryFilter filter, ObjectId rootId, bool deepSearch, SortBy sortBy, int pageSize) where T : IConfigurable, new()
        {
            if (!RequestJobProvider.IsRequestStatistics(typeof(T), false))
            {
                throw new ArgumentException("RequestJobProvider can only find *RequestStatistics objects.");
            }
            List <T> list = new List <T>();
            RequestJobQueryFilter requestJobQueryFilter = filter as RequestJobQueryFilter;

            if (requestJobQueryFilter != null)
            {
                MRSRequestType?requestType = requestJobQueryFilter.RequestType;
                Guid           mdbGuid     = requestJobQueryFilter.MdbGuid;
                Guid           requestGuid = requestJobQueryFilter.RequestGuid;
                this.EnsureStoreConnectionExists(mdbGuid);
                Restriction restriction = null;
                if (requestType != null)
                {
                    RequestJobNamedPropertySet requestJobNamedPropertySet = RequestJobNamedPropertySet.Get(this.SystemMailbox);
                    restriction = Restriction.EQ(requestJobNamedPropertySet.PropTags[14], requestType.Value);
                    if (requestType.Value == MRSRequestType.Move)
                    {
                        restriction = Restriction.Or(new Restriction[]
                        {
                            Restriction.Not(Restriction.Exist(requestJobNamedPropertySet.PropTags[14])),
                            restriction
                        });
                    }
                }
                byte[] searchKey = null;
                if (requestGuid != Guid.Empty)
                {
                    searchKey = RequestJobXML.CreateMessageSearchKey(requestGuid);
                }
                List <RequestJobXML> list2 = MoveObjectInfo <RequestJobXML> .LoadAll(searchKey, restriction, mdbGuid, this.store, RequestJobXML.RequestJobsFolderName, new MoveObjectInfo <RequestJobXML> .IsSupportedObjectTypeDelegate(RequestJobXML.IsMessageTypeSupported), new MoveObjectInfo <RequestJobXML> .EmptyTDelegate(this.CreateDummyFromSearchKey));

                if (list2 == null || list2.Count == 0)
                {
                    MrsTracer.Common.Debug("No RequestJob messages found.", new object[0]);
                }
                else
                {
                    foreach (RequestJobXML requestJobXML in list2)
                    {
                        RequestJobProvider.FixTenantInfo(requestJobXML);
                        RequestStatisticsBase requestStatisticsBase = RequestJobProvider.CreateRequestStatistics(typeof(T), requestJobXML, true);
                        requestStatisticsBase.OriginatingMDBGuid = mdbGuid;
                        if (requestStatisticsBase.Identity == null)
                        {
                            requestStatisticsBase.Identity = new RequestJobObjectId(requestStatisticsBase.IdentifyingGuid, mdbGuid, null);
                        }
                        if (!requestStatisticsBase.IsFake)
                        {
                            using (this.IndexProvider.RescopeTo(requestStatisticsBase.DomainControllerToUpdate, requestStatisticsBase.OrganizationId))
                            {
                                if (requestStatisticsBase.UserId != null)
                                {
                                    requestStatisticsBase.User = this.IndexProvider.ReadADUser(requestStatisticsBase.UserId, requestStatisticsBase.ExchangeGuid);
                                }
                                if (requestStatisticsBase.SourceUserId != null)
                                {
                                    requestStatisticsBase.SourceUser = this.IndexProvider.ReadADUser(requestStatisticsBase.SourceUserId, requestStatisticsBase.SourceExchangeGuid);
                                }
                                if (requestStatisticsBase.TargetUserId != null)
                                {
                                    requestStatisticsBase.TargetUser = this.IndexProvider.ReadADUser(requestStatisticsBase.TargetUserId, requestStatisticsBase.TargetExchangeGuid);
                                }
                                if (!typeof(T).Equals(typeof(MoveRequestStatistics)) && requestStatisticsBase.RequestType != MRSRequestType.Move)
                                {
                                    List <IRequestIndexEntry> list3 = new List <IRequestIndexEntry>();
                                    if (requestStatisticsBase.IndexIds != null && requestStatisticsBase.IndexIds.Count > 0)
                                    {
                                        foreach (RequestIndexId indexId in requestStatisticsBase.IndexIds)
                                        {
                                            IRequestIndexEntry requestIndexEntry;
                                            try
                                            {
                                                requestIndexEntry = this.IndexProvider.Read(new RequestIndexEntryObjectId(requestStatisticsBase.RequestGuid, requestStatisticsBase.TargetExchangeGuid, requestStatisticsBase.RequestType, requestStatisticsBase.OrganizationId, indexId, null));
                                            }
                                            catch (TenantOrgContainerNotFoundException)
                                            {
                                                requestIndexEntry = null;
                                            }
                                            if (requestIndexEntry != null)
                                            {
                                                list3.Add(requestIndexEntry);
                                            }
                                        }
                                    }
                                    requestStatisticsBase.IndexEntries = list3;
                                }
                                if (this.IndexProvider.DomainController == null && !string.IsNullOrEmpty(requestStatisticsBase.DomainControllerToUpdate))
                                {
                                    requestStatisticsBase.DomainControllerToUpdate = null;
                                }
                            }
                        }
                        requestStatisticsBase.ValidateRequestJob();
                        if (this.LoadReport)
                        {
                            ReportData reportData = new ReportData(requestStatisticsBase.IdentifyingGuid, requestStatisticsBase.ReportVersion);
                            reportData.Load(this.SystemMailbox);
                            requestStatisticsBase.Report = reportData.ToReport();
                        }
                        if (requestStatisticsBase != null && requestStatisticsBase.GetType().Equals(typeof(T)))
                        {
                            list.Add((T)((object)requestStatisticsBase));
                        }
                    }
                }
            }
            return(list);
        }
コード例 #15
0
        public IConfigurable Read <T>(ObjectId identity, ReadJobFlags readJobFlags) where T : IConfigurable, new()
        {
            if (identity == null)
            {
                throw new ArgumentNullException("identity", "The identity of the object to be read must be specified.");
            }
            if (!(identity is RequestJobObjectId))
            {
                throw new ArgumentException("RequestJobProvider can only identify RequestJobs based on RequestJobObjectIds.", "identity");
            }
            if (!typeof(T).Equals(typeof(TransactionalRequestJob)) && !RequestJobProvider.IsRequestStatistics(typeof(T), true))
            {
                throw new ArgumentException("RequestJobProvider can only Read *RequestStatistics or TransactionalRequestJob objects.");
            }
            bool flag = false;

            if (typeof(T).Equals(typeof(TransactionalRequestJob)))
            {
                flag = true;
            }
            RequestJobObjectId requestJobObjectId = (RequestJobObjectId)identity;
            Guid requestGuid = requestJobObjectId.RequestGuid;
            Guid mdbGuid     = requestJobObjectId.MdbGuid;

            byte[]                    messageId  = requestJobObjectId.MessageId;
            ADUser                    aduser     = requestJobObjectId.User;
            ADUser                    aduser2    = requestJobObjectId.SourceUser;
            ADUser                    aduser3    = requestJobObjectId.TargetUser;
            IRequestIndexEntry        indexEntry = requestJobObjectId.IndexEntry;
            List <IRequestIndexEntry> list       = new List <IRequestIndexEntry>();

            if (requestGuid == Guid.Empty || mdbGuid == Guid.Empty)
            {
                throw new NotEnoughInformationToFindMoveRequestPermanentException();
            }
            this.EnsureStoreConnectionExists(mdbGuid);
            MoveObjectInfo <RequestJobXML> moveObjectInfo = null;
            IConfigurable result;

            try
            {
                moveObjectInfo = new MoveObjectInfo <RequestJobXML>(mdbGuid, this.store, messageId, RequestJobXML.RequestJobsFolderName, RequestJobXML.RequestJobsMessageClass, RequestJobXML.CreateMessageSubject(requestGuid), RequestJobXML.CreateMessageSearchKey(requestGuid));
                RequestJobXML requestJobXML = null;
                if (moveObjectInfo.OpenMessage())
                {
                    if (moveObjectInfo.CheckObjectType(new MoveObjectInfo <RequestJobXML> .IsSupportedObjectTypeDelegate(RequestJobXML.IsMessageTypeSupported)))
                    {
                        requestJobXML = moveObjectInfo.ReadObject(ReadObjectFlags.DontThrowOnCorruptData);
                    }
                    else
                    {
                        MrsTracer.Common.Warning("Found unexpected JobType for move job {0}", new object[]
                        {
                            requestJobObjectId.ToString()
                        });
                    }
                    if (requestJobXML == null)
                    {
                        if (!this.AllowInvalid)
                        {
                            return(null);
                        }
                        requestJobXML              = RequestJobBase.CreateDummyObject <RequestJobXML>();
                        requestJobXML.RequestGuid  = requestGuid;
                        requestJobXML.ExchangeGuid = requestGuid;
                    }
                    requestJobXML.OriginatingMDBGuid = mdbGuid;
                    if (requestJobXML.Identity == null)
                    {
                        requestJobXML.Identity = requestJobObjectId;
                    }
                    requestJobXML.Identity.MessageId = moveObjectInfo.MessageId;
                    RequestJobProvider.FixTenantInfo(requestJobXML);
                    if (!requestJobXML.IsFake)
                    {
                        using (this.IndexProvider.RescopeTo(requestJobXML.DomainControllerToUpdate, requestJobXML.OrganizationId))
                        {
                            if (aduser == null && requestJobXML.UserId != null)
                            {
                                aduser = this.IndexProvider.ReadADUser(requestJobXML.UserId, requestJobXML.ExchangeGuid);
                            }
                            if (aduser2 == null && requestJobXML.SourceUserId != null)
                            {
                                aduser2 = this.IndexProvider.ReadADUser(requestJobXML.SourceUserId, requestJobXML.SourceExchangeGuid);
                            }
                            if (aduser3 == null && requestJobXML.TargetUserId != null)
                            {
                                aduser3 = this.IndexProvider.ReadADUser(requestJobXML.TargetUserId, requestJobXML.TargetExchangeGuid);
                            }
                            if (!typeof(T).Equals(typeof(MoveRequestStatistics)) && requestJobXML.RequestType != MRSRequestType.Move && requestJobXML.IndexIds != null && requestJobXML.IndexIds.Count > 0)
                            {
                                int  capacity = requestJobXML.IndexIds.Count - 1;
                                bool flag2    = false;
                                List <RequestIndexEntryObjectId> list2 = new List <RequestIndexEntryObjectId>(capacity);
                                foreach (RequestIndexId requestIndexId in requestJobXML.IndexIds)
                                {
                                    if (indexEntry != null && requestIndexId.Equals(indexEntry.RequestIndexId))
                                    {
                                        if (!flag2)
                                        {
                                            list.Add(indexEntry);
                                        }
                                        flag2 = true;
                                    }
                                    else if (readJobFlags.HasFlag(ReadJobFlags.SkipReadingMailboxRequestIndexEntries) && requestIndexId.Location == RequestIndexLocation.Mailbox)
                                    {
                                        MrsTracer.Common.Debug("Skipping loading of an IRequestIndexEntry found in a mailbox.", new object[0]);
                                    }
                                    else
                                    {
                                        list2.Add(new RequestIndexEntryObjectId(requestJobXML.RequestGuid, requestJobXML.TargetExchangeGuid, requestJobXML.RequestType, requestJobXML.OrganizationId, requestIndexId, null));
                                    }
                                }
                                foreach (RequestIndexEntryObjectId objectId in list2)
                                {
                                    IRequestIndexEntry requestIndexEntry = this.IndexProvider.Read(objectId);
                                    if (requestIndexEntry != null)
                                    {
                                        list.Add(requestIndexEntry);
                                    }
                                }
                            }
                            if (this.IndexProvider.DomainController == null && !string.IsNullOrEmpty(requestJobXML.DomainControllerToUpdate))
                            {
                                requestJobXML.DomainControllerToUpdate = null;
                            }
                        }
                    }
                    requestJobXML.User         = aduser;
                    requestJobXML.SourceUser   = aduser2;
                    requestJobXML.TargetUser   = aduser3;
                    requestJobXML.IndexEntries = list;
                    if (!readJobFlags.HasFlag(ReadJobFlags.SkipValidation))
                    {
                        requestJobXML.ValidateRequestJob();
                    }
                    if (this.AllowInvalid)
                    {
                        ValidationError[] array = requestJobXML.Validate();
                        if (array != null && array.Length > 0)
                        {
                            requestJobXML.IsFake = true;
                        }
                    }
                    if (flag)
                    {
                        TransactionalRequestJob transactionalRequestJob = new TransactionalRequestJob(requestJobXML);
                        requestJobXML.Retire();
                        transactionalRequestJob.Provider   = this;
                        transactionalRequestJob.MoveObject = moveObjectInfo;
                        moveObjectInfo = null;
                        result         = transactionalRequestJob;
                    }
                    else
                    {
                        RequestStatisticsBase requestStatisticsBase = RequestJobProvider.CreateRequestStatistics(typeof(T), requestJobXML, true);
                        if (requestStatisticsBase == null)
                        {
                            requestStatisticsBase = new MoveRequestStatistics(requestJobXML);
                            requestJobXML.Retire();
                        }
                        if (this.LoadReport)
                        {
                            ReportData reportData = new ReportData(requestStatisticsBase.IdentifyingGuid, requestStatisticsBase.ReportVersion);
                            reportData.Load(this.SystemMailbox);
                            requestStatisticsBase.Report = reportData.ToReport();
                        }
                        result = requestStatisticsBase;
                    }
                }
                else
                {
                    result = null;
                }
            }
            finally
            {
                if (moveObjectInfo != null)
                {
                    moveObjectInfo.Dispose();
                    moveObjectInfo = null;
                }
            }
            return(result);
        }