예제 #1
0
        void IMailbox.UpdateMovedMailbox(UpdateMovedMailboxOperation op, ADUser remoteRecipientData, string domainController, out ReportEntry[] entries, Guid newDatabaseGuid, Guid newArchiveDatabaseGuid, string archiveDomain, ArchiveStatusFlags archiveStatus, UpdateMovedMailboxFlags updateMovedMailboxFlags, Guid?newMailboxContainerGuid, CrossTenantObjectId newUnifiedMailboxId)
        {
            entries = null;
            MrsTracer.ProxyClient.Function("RemoteMailbox.UpdateMovedMailbox", new object[0]);
            this.VerifyMailboxConnection();
            string remoteRecipientData2 = ConfigurableObjectXML.Serialize <ADUser>(remoteRecipientData);
            string text = null;

            if (base.ServerVersion[46])
            {
                byte[] newUnifiedMailboxIdData = (newUnifiedMailboxId == null) ? null : newUnifiedMailboxId.GetBytes();
                base.MrsProxy.IMailbox_UpdateMovedMailbox4(base.Handle, op, remoteRecipientData2, domainController, out text, newDatabaseGuid, newArchiveDatabaseGuid, archiveDomain, (int)archiveStatus, (int)updateMovedMailboxFlags, newMailboxContainerGuid, newUnifiedMailboxIdData);
            }
            else if (base.ServerVersion[36])
            {
                base.MrsProxy.IMailbox_UpdateMovedMailbox3(base.Handle, op, remoteRecipientData2, domainController, out text, newDatabaseGuid, newArchiveDatabaseGuid, archiveDomain, (int)archiveStatus, (int)updateMovedMailboxFlags);
            }
            else if (base.ServerVersion[9])
            {
                base.MrsProxy.IMailbox_UpdateMovedMailbox2(base.Handle, op, remoteRecipientData2, domainController, out text, newDatabaseGuid, newArchiveDatabaseGuid, archiveDomain, (int)archiveStatus);
            }
            else
            {
                base.MrsProxy.IMailbox_UpdateMovedMailbox(base.Handle, op, remoteRecipientData2, domainController, out text);
            }
            if (text != null)
            {
                List <ReportEntry> list = XMLSerializableBase.Deserialize <List <ReportEntry> >(text, false);
                entries = ((list != null) ? list.ToArray() : null);
            }
        }
예제 #2
0
 public void Append(LocalizedString msg, ConfigurableObjectXML configObject, ReportEntryFlags flags)
 {
     this.Append(new ReportEntry(msg)
     {
         ConfigObject = configObject,
         Flags        = (flags | ReportEntryFlags.ConfigObject)
     });
 }
예제 #3
0
        ADUser IMailbox.GetADUser()
        {
            MrsTracer.ProxyClient.Function("RemoteMailbox.GetADUser", new object[0]);
            this.VerifyMailboxConnection();
            string xml = base.MrsProxy.IMailbox_GetADUser(base.Handle);

            return(ConfigurableObjectXML.Deserialize <ADUser>(xml));
        }
        internal static string Serialize <T>(T obj) where T : ConfigurableObject
        {
            ConfigurableObjectXML configurableObjectXML = ConfigurableObjectXML.Create(obj);

            if (configurableObjectXML == null)
            {
                return(null);
            }
            return(configurableObjectXML.Serialize(false));
        }
        internal static T Deserialize <T>(string xml) where T : ConfigurableObject, new()
        {
            ConfigurableObjectXML configurableObjectXML = ConfigurableObjectXML.Parse(xml);

            if (configurableObjectXML == null)
            {
                return(default(T));
            }
            T t = Activator.CreateInstance <T>();

            configurableObjectXML.Populate(t);
            return(t);
        }
예제 #6
0
        protected override void UpdateMovedMailbox()
        {
            if (CommonUtils.IsImplicitSplit(base.CachedRequestJob.Flags, base.GetRootMailboxContext().SourceMailbox.GetADUser()))
            {
                throw new ImplicitSplitPermanentException();
            }
            ReportEntry[]         entries   = null;
            ADUser                adUser    = base.GetRootMailboxContext().DestMailbox.GetADUser();
            ConfigurableObjectXML configObj = ConfigurableObjectXML.Create(adUser);

            base.Report.Append(MrsStrings.ReportMailboxBeforeFinalization2(adUser.ToString(), adUser.OriginatingServer), configObj, ReportEntryFlags.Source | ReportEntryFlags.Before);
            try
            {
                MrsTracer.Service.Debug("Updating destination mailbox only (local move)...", new object[0]);
                UpdateMovedMailboxOperation op = base.CachedRequestJob.ArchiveOnly ? UpdateMovedMailboxOperation.UpdateArchiveOnly : UpdateMovedMailboxOperation.UpdateMailbox;
                Guid newArchiveDatabaseGuid;
                if (base.CachedRequestJob.ArchiveIsMoving)
                {
                    newArchiveDatabaseGuid = base.CachedRequestJob.TargetArchiveMDBGuid;
                }
                else
                {
                    newArchiveDatabaseGuid = ((adUser.ArchiveDatabase != null) ? adUser.ArchiveDatabase.ObjectGuid : Guid.Empty);
                }
                UpdateMovedMailboxFlags updateMovedMailboxFlags = UpdateMovedMailboxFlags.None;
                if (base.CachedRequestJob.SkipMailboxReleaseCheck)
                {
                    updateMovedMailboxFlags |= UpdateMovedMailboxFlags.SkipMailboxReleaseCheck;
                }
                if (base.CachedRequestJob.SkipProvisioningCheck)
                {
                    updateMovedMailboxFlags |= UpdateMovedMailboxFlags.SkipProvisioningCheck;
                }
                base.GetRootMailboxContext().DestMailbox.UpdateMovedMailbox(op, null, base.CachedRequestJob.DestDomainControllerToUpdate, out entries, base.CachedRequestJob.TargetMDBGuid, newArchiveDatabaseGuid, (adUser.ArchiveDomain != null) ? adUser.ArchiveDomain.ToString() : null, adUser.ArchiveStatus, updateMovedMailboxFlags, base.CachedRequestJob.TargetContainerGuid, base.CachedRequestJob.TargetUnifiedMailboxId);
            }
            finally
            {
                base.AppendReportEntries(entries);
            }
            CommonUtils.CatchKnownExceptions(delegate
            {
                adUser    = this.GetRootMailboxContext().DestMailbox.GetADUser();
                configObj = ConfigurableObjectXML.Create(adUser);
                this.Report.Append(MrsStrings.ReportMailboxAfterFinalization2(adUser.ToString(), adUser.OriginatingServer), configObj, ReportEntryFlags.Target | ReportEntryFlags.After);
            }, null);
        }
        internal static ConfigurableObjectXML Create(ConfigurableObject obj)
        {
            if (obj == null)
            {
                return(null);
            }
            ConfigurableObjectXML configurableObjectXML = new ConfigurableObjectXML();

            configurableObjectXML.ClassName = obj.GetType().Name;
            foreach (PropertyDefinition propertyDefinition in obj.ObjectSchema.AllProperties)
            {
                ProviderPropertyDefinition providerPropertyDefinition = propertyDefinition as ProviderPropertyDefinition;
                if (providerPropertyDefinition != null && !ConfigurableObjectXML.PropertiesNotToSerialize.ContainsKey(propertyDefinition))
                {
                    object      value       = obj[providerPropertyDefinition];
                    PropertyXML propertyXML = PropertyXML.Create(providerPropertyDefinition, value);
                    if (propertyXML != null)
                    {
                        configurableObjectXML.properties[providerPropertyDefinition.Name] = propertyXML;
                    }
                }
            }
            return(configurableObjectXML);
        }
        MailboxInformation IMailboxReplicationService.GetMailboxInformation4(string requestJobXml, Guid primaryMailboxGuid, Guid physicalMailboxGuid, byte[] partitionHint, Guid targetMdbGuid, string targetMdbName, string remoteHostName, string remoteOrgName, string remoteDCName, string username, string password, string domain)
        {
            MailboxInformation info = null;

            this.ForwardKnownExceptions(delegate
            {
                TenantPartitionHint partitionHint2 = (partitionHint != null) ? TenantPartitionHint.FromPersistablePartitionHint(partitionHint) : null;
                bool flag = string.IsNullOrEmpty(targetMdbName) && targetMdbGuid == Guid.Empty;
                NetworkCredential networkCredential = (!string.IsNullOrEmpty(username)) ? new NetworkCredential(username, password, domain) : null;
                MailboxType mbxType;
                IMailbox mailbox;
                if (string.IsNullOrEmpty(remoteHostName))
                {
                    if (!string.IsNullOrEmpty(remoteDCName))
                    {
                        if (flag)
                        {
                            mbxType = MailboxType.SourceMailbox;
                            mailbox = new MapiSourceMailbox(LocalMailboxFlags.Move);
                        }
                        else
                        {
                            mbxType = MailboxType.DestMailboxIntraOrg;
                            mailbox = new MapiDestinationMailbox(LocalMailboxFlags.None);
                        }
                        mailbox.ConfigADConnection(remoteDCName, remoteDCName, networkCredential);
                    }
                    else
                    {
                        ProxyServerSettings proxyServerSettings;
                        if (targetMdbGuid != Guid.Empty)
                        {
                            proxyServerSettings = CommonUtils.MapDatabaseToProxyServer(targetMdbGuid);
                        }
                        else
                        {
                            proxyServerSettings = CommonUtils.MapMailboxToProxyServer(new Guid?(physicalMailboxGuid), new Guid?(primaryMailboxGuid), partitionHint);
                        }
                        if (flag)
                        {
                            if (proxyServerSettings.Scenario == ProxyScenarios.LocalMdbAndProxy)
                            {
                                mailbox = new StorageSourceMailbox(LocalMailboxFlags.Move);
                            }
                            else
                            {
                                mailbox = new RemoteSourceMailbox(proxyServerSettings.Fqdn, null, null, ProxyControlFlags.DoNotApplyProxyThrottling, null, false, LocalMailboxFlags.Move);
                            }
                            mbxType = MailboxType.SourceMailbox;
                        }
                        else
                        {
                            if (proxyServerSettings.Scenario == ProxyScenarios.LocalMdbAndProxy)
                            {
                                mailbox = new StorageDestinationMailbox(LocalMailboxFlags.Move);
                            }
                            else
                            {
                                mailbox = new RemoteDestinationMailbox(proxyServerSettings.Fqdn, null, null, ProxyControlFlags.DoNotApplyProxyThrottling, null, false, LocalMailboxFlags.Move);
                            }
                            mbxType = MailboxType.DestMailboxIntraOrg;
                        }
                    }
                }
                else
                {
                    ProxyControlFlags proxyControlFlags = ProxyControlFlags.DoNotApplyProxyThrottling;
                    RequestJobXML requestJobXML         = XMLSerializableBase.Deserialize <RequestJobXML>(requestJobXml, true);
                    if (requestJobXML != null)
                    {
                        using (TransactionalRequestJob transactionalRequestJob = new TransactionalRequestJob(requestJobXML))
                        {
                            transactionalRequestJob.IsFake = true;
                            proxyControlFlags |= transactionalRequestJob.GetProxyControlFlags();
                        }
                    }
                    if (flag)
                    {
                        mailbox = new RemoteSourceMailbox(remoteHostName, remoteOrgName, networkCredential, proxyControlFlags, null, true, LocalMailboxFlags.Move);
                        mbxType = MailboxType.SourceMailbox;
                    }
                    else
                    {
                        mailbox = new RemoteDestinationMailbox(remoteHostName, remoteOrgName, networkCredential, proxyControlFlags, null, true, LocalMailboxFlags.Move);
                        mbxType = MailboxType.DestMailboxCrossOrg;
                    }
                }
                using (mailbox)
                {
                    mailbox.Config(null, primaryMailboxGuid, physicalMailboxGuid, partitionHint2, targetMdbGuid, mbxType, null);
                    if (!string.IsNullOrEmpty(targetMdbName))
                    {
                        mailbox.ConfigMDBByName(targetMdbName);
                    }
                    mailbox.Connect(MailboxConnectFlags.None);
                    using (SettingsContextBase.ActivateContext(mailbox as ISettingsContextProvider))
                    {
                        info          = mailbox.GetMailboxInformation();
                        ADUser aduser = mailbox.GetADUser();
                        if (!this.clientVersion[2] && aduser.HasSeparatedArchive)
                        {
                            throw new UnsupportedClientVersionPermanentException(this.clientVersion.ComputerName, this.clientVersion.ToString(), "ArchiveSeparation");
                        }
                        info.UserDataXML       = ConfigurableObjectXML.Serialize <ADUser>(aduser);
                        info.ServerInformation = mailbox.GetMailboxServerInformation();
                        mailbox.Disconnect();
                    }
                }
            }, null);
            return(info);
        }
예제 #9
0
        protected override void UpdateSourceMailbox()
        {
            ReportEntry[]         entries  = null;
            MailboxCopierBase     rootCtx  = base.GetRootMailboxContext();
            ADUser                srcUser  = rootCtx.SourceMailbox.GetADUser();
            ADUser                destUser = null;
            ConfigurableObjectXML configObj;

            CommonUtils.CatchKnownExceptions(delegate
            {
                destUser  = rootCtx.DestMailbox.GetADUser();
                configObj = ConfigurableObjectXML.Create(destUser);
                this.Report.Append(MrsStrings.ReportTargetMailboxAfterFinalization2(destUser.ToString(), destUser.OriginatingServer), configObj, ReportEntryFlags.Target | ReportEntryFlags.After);
            }, delegate(Exception failure)
            {
                this.Report.Append(MrsStrings.ReportUnableToLoadDestinationUser(CommonUtils.GetFailureType(failure)), failure, ReportEntryFlags.Cleanup | ReportEntryFlags.Target);
                FailureLog.Write(this.RequestJobGuid, failure, false, RequestState.Cleanup, SyncStage.CleanupUnableToLoadTargetMailbox, null, null);
                destUser = (ADUser)srcUser.Clone();
            });
            if (base.CachedRequestJob.PrimaryIsMoving)
            {
                SmtpAddress?smtpAddress = null;
                foreach (ProxyAddress proxyAddress in destUser.EmailAddresses)
                {
                    SmtpProxyAddress smtpProxyAddress = proxyAddress as SmtpProxyAddress;
                    if (smtpProxyAddress != null)
                    {
                        SmtpAddress value = new SmtpAddress(smtpProxyAddress.SmtpAddress);
                        if (StringComparer.OrdinalIgnoreCase.Equals(value.Domain, base.CachedRequestJob.TargetDeliveryDomain))
                        {
                            smtpAddress = new SmtpAddress?(value);
                            break;
                        }
                    }
                }
                if (smtpAddress == null)
                {
                    LocalizedString localizedString = MrsStrings.ReportUnableToComputeTargetAddress(base.CachedRequestJob.TargetDeliveryDomain, destUser.PrimarySmtpAddress.ToString());
                    base.Report.Append(localizedString);
                    base.Warnings.Add(localizedString);
                    FailureLog.Write(base.RequestJobGuid, new MailboxReplicationTransientException(localizedString), false, RequestState.Cleanup, SyncStage.CleanupUnableToComputeTargetAddress, null, null);
                    smtpAddress = new SmtpAddress?(destUser.PrimarySmtpAddress);
                }
                SmtpProxyAddress smtpProxyAddress2 = new SmtpProxyAddress(smtpAddress.Value.ToString(), true);
                destUser.ExternalEmailAddress = smtpProxyAddress2;
                List <PropertyUpdateXML> list = new List <PropertyUpdateXML>();
                PropertyUpdateXML.Add(list, ADRecipientSchema.ExternalEmailAddress, smtpProxyAddress2, PropertyUpdateOperation.Replace);
                if (rootCtx.SyncState.ExternalLegacyExchangeDN != null)
                {
                    PropertyUpdateXML.Add(list, ADRecipientSchema.LegacyExchangeDN, rootCtx.SyncState.ExternalLegacyExchangeDN, PropertyUpdateOperation.Replace);
                    this.AddX500ProxyAddressIfNeeded(list, srcUser, srcUser.LegacyExchangeDN, srcUser.Identity.ToString());
                }
                if (rootCtx.SyncState.InternalLegacyExchangeDN != null)
                {
                    this.AddX500ProxyAddressIfNeeded(list, srcUser, rootCtx.SyncState.InternalLegacyExchangeDN, destUser.Identity.ToString());
                }
                destUser.LinkedMasterAccount = XMLSerializableBase.Serialize(list.ToArray(), false);
            }
            try
            {
                Guid?newMailboxContainerGuid            = null;
                CrossTenantObjectId newUnifiedMailboxId = null;
                MrsTracer.Service.Debug("Updating source mailbox...", new object[0]);
                UpdateMovedMailboxOperation op;
                Guid newArchiveDatabaseGuid;
                ArchiveStatusFlags archiveStatus;
                string             archiveDomain;
                if (base.CachedRequestJob.PrimaryOnly)
                {
                    op = UpdateMovedMailboxOperation.MorphToMailUser;
                    newArchiveDatabaseGuid = ((srcUser.ArchiveDatabase != null) ? srcUser.ArchiveDatabase.ObjectGuid : Guid.Empty);
                    archiveStatus          = ((srcUser.ArchiveDatabase != null) ? ArchiveStatusFlags.Active : ArchiveStatusFlags.None);
                    archiveDomain          = null;
                }
                else if (base.CachedRequestJob.ArchiveOnly)
                {
                    op = UpdateMovedMailboxOperation.UpdateArchiveOnly;
                    newArchiveDatabaseGuid  = Guid.Empty;
                    archiveStatus           = ArchiveStatusFlags.None;
                    archiveDomain           = ((srcUser.Database != null) ? base.CachedRequestJob.ArchiveDomain : null);
                    newMailboxContainerGuid = srcUser.MailboxContainerGuid;
                    newUnifiedMailboxId     = srcUser.UnifiedMailbox;
                }
                else
                {
                    op = UpdateMovedMailboxOperation.MorphToMailUser;
                    newArchiveDatabaseGuid = Guid.Empty;
                    archiveDomain          = null;
                    archiveStatus          = ArchiveStatusFlags.None;
                }
                UpdateMovedMailboxFlags updateMovedMailboxFlags = UpdateMovedMailboxFlags.None;
                if (base.CachedRequestJob.SkipMailboxReleaseCheck)
                {
                    updateMovedMailboxFlags |= UpdateMovedMailboxFlags.SkipMailboxReleaseCheck;
                }
                rootCtx.SourceMailbox.UpdateMovedMailbox(op, destUser, base.CachedRequestJob.SourceDomainControllerToUpdate ?? srcUser.OriginatingServer, out entries, Guid.Empty, newArchiveDatabaseGuid, archiveDomain, archiveStatus, updateMovedMailboxFlags, newMailboxContainerGuid, newUnifiedMailboxId);
            }
            finally
            {
                base.AppendReportEntries(entries);
            }
            CommonUtils.CatchKnownExceptions(delegate
            {
                srcUser   = rootCtx.SourceMailbox.GetADUser();
                configObj = ConfigurableObjectXML.Create(srcUser);
                this.Report.Append(MrsStrings.ReportSourceMailUserAfterFinalization2(srcUser.ToString(), srcUser.OriginatingServer), configObj, ReportEntryFlags.Source | ReportEntryFlags.After);
            }, null);
        }
예제 #10
0
        protected override void UpdateMovedMailbox()
        {
            ReportEntry[]         entries      = null;
            ADUser                aduser       = base.GetRootMailboxContext().SourceMailbox.GetADUser();
            ConfigurableObjectXML configObject = ConfigurableObjectXML.Create(aduser);

            base.Report.Append(MrsStrings.ReportSourceMailboxBeforeFinalization2(aduser.ToString(), aduser.OriginatingServer), configObject, ReportEntryFlags.Source | ReportEntryFlags.Before);
            ADUser aduser2 = base.GetRootMailboxContext().DestMailbox.GetADUser();

            configObject = ConfigurableObjectXML.Create(aduser2);
            base.Report.Append(MrsStrings.ReportTargetMailUserBeforeFinalization2(aduser2.ToString(), aduser2.OriginatingServer), configObject, ReportEntryFlags.Target | ReportEntryFlags.Before);
            bool isFromDatacenter  = aduser.IsFromDatacenter;
            bool isFromDatacenter2 = aduser2.IsFromDatacenter;

            if (base.CachedRequestJob.PrimaryIsMoving)
            {
                CommonUtils.ValidateTargetDeliveryDomain(aduser2.EmailAddresses, base.CachedRequestJob.TargetDeliveryDomain);
                MailboxCopierBase rootMailboxContext = base.GetRootMailboxContext();
                if (!isFromDatacenter && isFromDatacenter2)
                {
                    rootMailboxContext.SyncState.ExternalLegacyExchangeDN = FreeBusyFolder.GetExternalLegacyDN(aduser);
                }
                else if (isFromDatacenter && !isFromDatacenter2)
                {
                    string mdbLegDN = base.GetRootMailboxContext().DestMailbox.GetMailboxInformation().MdbLegDN;
                    rootMailboxContext.SyncState.InternalLegacyExchangeDN = FreeBusyFolder.GetInternalLegacyDN(aduser2, mdbLegDN);
                }
                List <PropertyUpdateXML> list = new List <PropertyUpdateXML>();
                if (rootMailboxContext.SyncState.ExternalLegacyExchangeDN != null)
                {
                    this.AddX500ProxyAddressIfNeeded(list, aduser2, rootMailboxContext.SyncState.ExternalLegacyExchangeDN, aduser.Identity.ToString());
                }
                if (rootMailboxContext.SyncState.InternalLegacyExchangeDN != null)
                {
                    PropertyUpdateXML.Add(list, ADRecipientSchema.LegacyExchangeDN, rootMailboxContext.SyncState.InternalLegacyExchangeDN, PropertyUpdateOperation.Replace);
                    this.AddX500ProxyAddressIfNeeded(list, aduser2, aduser2.LegacyExchangeDN, aduser2.Identity.ToString());
                }
                aduser.LinkedMasterAccount = XMLSerializableBase.Serialize(list.ToArray(), false);
            }
            MrsTracer.Service.Debug("Updating destination mailbox...", new object[0]);
            UpdateMovedMailboxOperation op;
            Guid newDatabaseGuid;
            Guid newArchiveDatabaseGuid;
            ArchiveStatusFlags archiveStatus;
            string             archiveDomain;

            if (base.CachedRequestJob.PrimaryOnly)
            {
                op = UpdateMovedMailboxOperation.MorphToMailbox;
                newDatabaseGuid        = base.CachedRequestJob.TargetMDBGuid;
                newArchiveDatabaseGuid = ((aduser2.ArchiveDatabase != null) ? aduser2.ArchiveDatabase.ObjectGuid : Guid.Empty);
                archiveStatus          = ArchiveStatusFlags.None;
                archiveDomain          = ((aduser2.ArchiveDatabase == null) ? base.CachedRequestJob.ArchiveDomain : null);
            }
            else if (base.CachedRequestJob.ArchiveOnly)
            {
                op = UpdateMovedMailboxOperation.UpdateArchiveOnly;
                newDatabaseGuid        = Guid.Empty;
                newArchiveDatabaseGuid = base.CachedRequestJob.TargetArchiveMDBGuid;
                archiveStatus          = ((aduser2.Database == null) ? ArchiveStatusFlags.Active : ArchiveStatusFlags.None);
                archiveDomain          = null;
            }
            else
            {
                op = UpdateMovedMailboxOperation.MorphToMailbox;
                newDatabaseGuid        = base.CachedRequestJob.TargetMDBGuid;
                newArchiveDatabaseGuid = base.CachedRequestJob.TargetArchiveMDBGuid;
                archiveDomain          = null;
                archiveStatus          = ArchiveStatusFlags.None;
            }
            UpdateMovedMailboxFlags updateMovedMailboxFlags = UpdateMovedMailboxFlags.None;

            if (base.CachedRequestJob.SkipMailboxReleaseCheck)
            {
                updateMovedMailboxFlags |= UpdateMovedMailboxFlags.SkipMailboxReleaseCheck;
            }
            if (base.CachedRequestJob.SkipProvisioningCheck)
            {
                updateMovedMailboxFlags |= UpdateMovedMailboxFlags.SkipProvisioningCheck;
            }
            try
            {
                base.GetRootMailboxContext().DestMailbox.UpdateMovedMailbox(op, aduser, base.CachedRequestJob.DestDomainControllerToUpdate, out entries, newDatabaseGuid, newArchiveDatabaseGuid, archiveDomain, archiveStatus, updateMovedMailboxFlags, null, null);
            }
            finally
            {
                base.AppendReportEntries(entries);
            }
        }