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