Пример #1
0
 private void TranslatePropValue(PropValueData pvd)
 {
     if (PrincipalTranslator.IsParticipantEntryIdTag(pvd.PropTag))
     {
         string text = PrincipalTranslator.LegDNFromParticipantEntryId(pvd.Value as byte[]);
         if (text != null)
         {
             string text2 = this.targetMapper.LookupLegDnByExProxy(text);
             pvd.Value = PrincipalTranslator.ParticipanEntryIdFromLegDN(pvd.Value as byte[], text2);
             MrsTracer.Service.Debug("Translating '{0}' to '{1}'", new object[]
             {
                 text,
                 text2
             });
             return;
         }
     }
     else if (PrincipalTranslator.IsSearchKeyTag(pvd.PropTag))
     {
         string text = PrincipalTranslator.LegDNFromSearchKey(pvd.Value as byte[]);
         if (text != null)
         {
             string text3 = this.targetMapper.LookupLegDnByExProxy(text);
             pvd.Value = PrincipalTranslator.SearchKeyFromLegDN(text3);
             MrsTracer.Service.Debug("Translating '{0}' to '{1}'", new object[]
             {
                 text,
                 text3
             });
         }
     }
 }
Пример #2
0
        private void EnumeratePropValue(PropValueData pvd)
        {
            string text = null;

            if (PrincipalTranslator.IsParticipantEntryIdTag(pvd.PropTag))
            {
                text = PrincipalTranslator.LegDNFromParticipantEntryId(pvd.Value as byte[]);
            }
            else if (PrincipalTranslator.IsSearchKeyTag(pvd.PropTag))
            {
                text = PrincipalTranslator.LegDNFromSearchKey(pvd.Value as byte[]);
            }
            if (!string.IsNullOrEmpty(text))
            {
                this.sourceMapper.AddLegDN(text);
            }
        }
Пример #3
0
 private void TranslateAdrEntry(AdrEntryData aed)
 {
     foreach (PropValueData propValueData in aed.Values)
     {
         PropTag propTag = (PropTag)propValueData.PropTag;
         if (propTag != PropTag.EntryId)
         {
             if (propTag == PropTag.SearchKey)
             {
                 string text = PrincipalTranslator.LegDNFromSearchKey(propValueData.Value as byte[]);
                 if (text != null)
                 {
                     string text2 = this.targetMapper.LookupLegDnByExProxy(text);
                     propValueData.Value = PrincipalTranslator.SearchKeyFromLegDN(text2);
                     MrsTracer.Service.Debug("Translating '{0}' to '{1}'", new object[]
                     {
                         text,
                         text2
                     });
                 }
             }
         }
         else
         {
             string text = PrincipalTranslator.LegDNFromParticipantEntryId(propValueData.Value as byte[]);
             if (text != null)
             {
                 string text3 = this.targetMapper.LookupLegDnByExProxy(text);
                 propValueData.Value = PrincipalTranslator.ParticipanEntryIdFromLegDN(propValueData.Value as byte[], text3);
                 MrsTracer.Service.Debug("Translating '{0}' to '{1}'", new object[]
                 {
                     text,
                     text3
                 });
             }
         }
     }
 }
Пример #4
0
 private void EnumerateAdrEntry(AdrEntryData aed)
 {
     foreach (PropValueData propValueData in aed.Values)
     {
         string  text    = null;
         PropTag propTag = (PropTag)propValueData.PropTag;
         if (propTag != PropTag.EntryId)
         {
             if (propTag == PropTag.SearchKey)
             {
                 text = PrincipalTranslator.LegDNFromSearchKey(propValueData.Value as byte[]);
             }
         }
         else
         {
             text = PrincipalTranslator.LegDNFromParticipantEntryId(propValueData.Value as byte[]);
         }
         if (!string.IsNullOrEmpty(text))
         {
             this.sourceMapper.AddLegDN(text);
         }
     }
 }
Пример #5
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);
        }