public TransactionalRequestJob ValidateAndPopulateRequestJob(TransactionalRequestJob requestJob, out List <ReportEntry> entries)
        {
            List <ReportEntry> entriesInternal = null;
            string             resultString    = null;
            string             requestJobXML   = XMLSerializableBase.Serialize(new RequestJobXML(requestJob), false);

            try
            {
                this.CallService(delegate()
                {
                    string text = null;
                    try
                    {
                        resultString = this.Channel.ValidateAndPopulateRequestJob(requestJobXML, out text);
                    }
                    finally
                    {
                        if (text != null)
                        {
                            entriesInternal = XMLSerializableBase.Deserialize <List <ReportEntry> >(text, false);
                        }
                    }
                });
            }
            finally
            {
                entries = entriesInternal;
            }
            return(new TransactionalRequestJob(XMLSerializableBase.Deserialize <RequestJobXML>(resultString, false)));
        }
示例#2
0
		private void LoadSyncStateCache()
		{
			MrsTracer.Provider.Function("PstDestinationMailbox.LoadSyncStateData", new object[0]);
			if (this.syncStateCache != null)
			{
				return;
			}
			try
			{
				if (this.syncStatePropId == 0)
				{
					this.syncStatePropId = base.IPst.ReadIdFromNamedProp(PstDestinationMailbox.syncStateNamedProp.Name, 0U, PstDestinationMailbox.syncStateNamedProp.Guid, true);
				}
				this.syncStateCache = new PSTSyncStateDictionary();
				PropertyValue property = base.MessageStorePropertyBag.GetProperty(new PropertyTag((PropertyId)this.syncStatePropId, PropertyType.Unicode));
				if (!property.IsError)
				{
					this.syncStateCache = XMLSerializableBase.Deserialize<PSTSyncStateDictionary>((string)property.Value, true);
				}
			}
			catch (PSTExceptionBase innerException)
			{
				throw new UnableToLoadPSTSyncStatePermanentException(base.IPst.FileName, innerException);
			}
			catch (MoveJobDeserializationFailedPermanentException innerException2)
			{
				throw new UnableToLoadPSTSyncStatePermanentException(base.IPst.FileName, innerException2);
			}
		}
示例#3
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);
            }
        }
示例#4
0
        public static ImapFolderState Deserialize(byte[] compressedXml)
        {
            byte[] bytes   = CommonUtils.DecompressData(compressedXml);
            string @string = Encoding.UTF7.GetString(bytes);

            if (string.IsNullOrEmpty(@string))
            {
                throw new CorruptSyncStateException(new ArgumentNullException("data", "Cannot deserialize null or empty data"));
            }
            return(XMLSerializableBase.Deserialize <ImapFolderState>(@string, true));
        }
示例#5
0
 private static T DeserializeFromStream(Stream stream, bool throwOnDeserializationError)
 {
     if (typeof(T) == typeof(string))
     {
         using (StreamReader streamReader = new StreamReader(stream))
         {
             return((T)((object)streamReader.ReadToEnd()));
         }
     }
     return(XMLSerializableBase.Deserialize <T>(stream, throwOnDeserializationError));
 }
示例#6
0
        private MessageExportResultsMessage(bool useCompression, byte[] blob)
        {
            this.BadMessages     = new List <BadMessageRec>();
            this.MissingMessages = new List <MessageRec>();
            string serializedXML = CommonUtils.UnpackString(blob, useCompression);
            MessageExportResults messageExportResults = XMLSerializableBase.Deserialize <MessageExportResults>(serializedXML, false);

            if (messageExportResults != null)
            {
                this.MissingMessages = messageExportResults.GetMissingMessages();
                this.BadMessages.AddRange(messageExportResults.BadMessages);
            }
        }
示例#7
0
        public static PopFolderState Deserialize(byte[] compressedXml)
        {
            byte[] bytes   = CommonUtils.DecompressData(compressedXml);
            string @string = Encoding.UTF7.GetString(bytes);

            if (string.IsNullOrEmpty(@string))
            {
                throw new CorruptSyncStateException(new ArgumentNullException("data", "Cannot deserialize null or empty data"));
            }
            PopFolderState popFolderState = XMLSerializableBase.Deserialize <PopFolderState>(@string, true);

            popFolderState.MessageList = PopBookmark.Parse(popFolderState.MessageListString);
            return(popFolderState);
        }
示例#8
0
        // Token: 0x06000282 RID: 642 RVA: 0x000093F0 File Offset: 0x000075F0
        public override bool ReadFromMessageItem(IAnchorStoreObject message)
        {
            if (!base.ReadFromMessageItem(message))
            {
                return(false);
            }
            if (!AnchorXmlSerializableObject <TXmlSerializable> .GetItemClass().Equals(message[StoreObjectSchema.ItemClass]))
            {
                return(false);
            }
            string text = message[ItemSchema.TextBody] as string;

            if (string.IsNullOrEmpty(text))
            {
                return(false);
            }
            this.PersistedObject = XMLSerializableBase.Deserialize <TXmlSerializable>(text, true);
            return(true);
        }
示例#9
0
 private static void SerializeToStream(T obj, Stream stream)
 {
     if (obj == null)
     {
         return;
     }
     if (typeof(T) == typeof(string))
     {
         using (StreamWriter streamWriter = new StreamWriter(stream))
         {
             streamWriter.Write((string)((object)obj));
             CommonUtils.AppendNewLinesAndFlush(streamWriter);
             return;
         }
     }
     XMLSerializableBase.SerializeToStream(obj, stream, false);
     using (StreamWriter streamWriter2 = new StreamWriter(stream))
     {
         CommonUtils.AppendNewLinesAndFlush(streamWriter2);
     }
 }
        public MailboxInformation GetMailboxInformation(TransactionalRequestJob requestJob, Guid primaryMailboxGuid, Guid physicalMailboxGuid, TenantPartitionHint partitionHint, Guid targetMdbGuid, string targetMdbName, string remoteHostName, string remoteOrgName, string remoteDCName, NetworkCredential cred)
        {
            MailboxInformation result = null;

            this.CallService(delegate()
            {
                string username = (cred != null) ? cred.UserName : null;
                string password = (cred != null) ? cred.Password : null;
                string domain   = (cred != null) ? cred.Domain : null;
                if (this.ServerVersion[11])
                {
                    string requestJobXml = XMLSerializableBase.Serialize(new RequestJobXML(requestJob), false);
                    result = this.Channel.GetMailboxInformation4(requestJobXml, primaryMailboxGuid, physicalMailboxGuid, (partitionHint != null) ? partitionHint.GetPersistablePartitionHint() : null, targetMdbGuid, targetMdbName, remoteHostName, remoteOrgName, remoteDCName, username, password, domain);
                    return;
                }
                if (this.ServerVersion[4])
                {
                    result = this.Channel.GetMailboxInformation3(primaryMailboxGuid, physicalMailboxGuid, (partitionHint != null) ? partitionHint.GetPersistablePartitionHint() : null, targetMdbGuid, targetMdbName, remoteHostName, remoteOrgName, remoteDCName, username, password, domain);
                    return;
                }
                result = this.Channel.GetMailboxInformation2(primaryMailboxGuid, physicalMailboxGuid, targetMdbGuid, targetMdbName, remoteHostName, remoteOrgName, remoteDCName, username, password, domain);
            });
            return(result);
        }
 public static StorageActionWatermark Deserialize(string data)
 {
     return(XMLSerializableBase.Deserialize <StorageActionWatermark>(data, true));
 }
 public static MailboxMapiSyncState Deserialize(string data)
 {
     return(XMLSerializableBase.Deserialize <MailboxMapiSyncState>(data, true));
 }
示例#13
0
 internal static MapiSyncState Deserialize(string data)
 {
     return(XMLSerializableBase.Deserialize <MapiSyncState>(data, false));
 }
 private static ADPropertyDefinition CreateXmlProperty <T>(string name, Func <PushNotificationAppConfigXml, T?> getter, Action <PushNotificationAppConfigXml, T?> setter) where T : struct
 {
     return(XMLSerializableBase.ConfigXmlProperty <PushNotificationAppConfigXml, T?>(name, ExchangeObjectVersion.Exchange2012, PushNotificationAppSchema.AppSettings, null, getter, setter, null, null));
 }
        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);
        }
        string IMailboxReplicationService.ValidateAndPopulateRequestJob(string requestJobXML, out string reportEntryXMLs)
        {
            string reportString = null;
            string resultString = null;

            try
            {
                this.ForwardKnownExceptions(delegate
                {
                    List <ReportEntry> list = new List <ReportEntry>();
                    try
                    {
                        RequestJobXML requestJob = XMLSerializableBase.Deserialize <RequestJobXML>(requestJobXML, true);
                        using (TransactionalRequestJob transactionalRequestJob = new TransactionalRequestJob(requestJob))
                        {
                            transactionalRequestJob.IsFake   = true;
                            transactionalRequestJob.Identity = new RequestJobObjectId((transactionalRequestJob.RequestType == MRSRequestType.Move) ? transactionalRequestJob.ExchangeGuid : transactionalRequestJob.RequestGuid, (transactionalRequestJob.WorkItemQueueMdb == null) ? Guid.Empty : transactionalRequestJob.WorkItemQueueMdb.ObjectGuid, null);
                            RequestIndexEntryProvider requestIndexEntryProvider = new RequestIndexEntryProvider();
                            using (requestIndexEntryProvider.RescopeTo(transactionalRequestJob.DomainControllerToUpdate, transactionalRequestJob.OrganizationId))
                            {
                                if (transactionalRequestJob.SourceUserId != null)
                                {
                                    transactionalRequestJob.SourceUser = requestIndexEntryProvider.ReadADUser(transactionalRequestJob.SourceUserId, transactionalRequestJob.SourceExchangeGuid);
                                }
                                if (transactionalRequestJob.TargetUserId != null)
                                {
                                    transactionalRequestJob.TargetUser = requestIndexEntryProvider.ReadADUser(transactionalRequestJob.TargetUserId, transactionalRequestJob.TargetExchangeGuid);
                                }
                            }
                            if (MailboxSyncerJobs.ContainsJob(transactionalRequestJob.IdentifyingGuid))
                            {
                                resultString = requestJobXML;
                            }
                            else
                            {
                                BaseJob baseJob = MailboxSyncerJobs.ConstructJob(transactionalRequestJob);
                                if (baseJob == null)
                                {
                                    MrsTracer.Service.Error("Don't know how to process '{0}' request", new object[]
                                    {
                                        transactionalRequestJob.RequestType
                                    });
                                    throw new RequestTypeNotUnderstoodPermanentException(CommonUtils.LocalComputerName, VersionInformation.MRS.ToString(), (int)transactionalRequestJob.RequestType);
                                }
                                using (baseJob)
                                {
                                    baseJob.Initialize(transactionalRequestJob);
                                    baseJob.ValidateAndPopulateRequestJob(list);
                                    transactionalRequestJob.Message              = baseJob.CachedRequestJob.Message;
                                    transactionalRequestJob.SourceVersion        = baseJob.CachedRequestJob.SourceVersion;
                                    transactionalRequestJob.SourceArchiveVersion = baseJob.CachedRequestJob.SourceArchiveVersion;
                                    transactionalRequestJob.SourceServer         = baseJob.CachedRequestJob.SourceServer;
                                    transactionalRequestJob.SourceArchiveServer  = baseJob.CachedRequestJob.SourceArchiveServer;
                                    transactionalRequestJob.TargetVersion        = baseJob.CachedRequestJob.TargetVersion;
                                    transactionalRequestJob.TargetArchiveVersion = baseJob.CachedRequestJob.TargetArchiveVersion;
                                    transactionalRequestJob.TargetServer         = baseJob.CachedRequestJob.TargetServer;
                                    transactionalRequestJob.TargetArchiveServer  = baseJob.CachedRequestJob.TargetArchiveServer;
                                    transactionalRequestJob.RemoteDatabaseGuid   = baseJob.CachedRequestJob.RemoteDatabaseGuid;
                                    resultString = XMLSerializableBase.Serialize(new RequestJobXML(transactionalRequestJob), false);
                                }
                            }
                        }
                    }
                    finally
                    {
                        reportString = XMLSerializableBase.Serialize(list, false);
                    }
                }, null);
            }
            finally
            {
                reportEntryXMLs = reportString;
            }
            return(resultString);
        }
 internal static ConfigurableObjectXML Parse(string serializedData)
 {
     return(XMLSerializableBase.Deserialize <ConfigurableObjectXML>(serializedData, false));
 }
 internal static EasHierarchySyncState Deserialize(string data)
 {
     return(XMLSerializableBase.Deserialize <EasHierarchySyncState>(data, false));
 }
示例#19
0
 internal static PersistedSyncData Deserialize(string data)
 {
     return(XMLSerializableBase.Deserialize <PersistedSyncData>(data, true));
 }
示例#20
0
 public static ReplaySyncState Deserialize(string data)
 {
     return(XMLSerializableBase.Deserialize <ReplaySyncState>(data, true));
 }
示例#21
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);
        }
示例#22
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);
            }
        }
示例#23
0
        internal static EasFolderSyncState Deserialize(byte[] data)
        {
            string @string = Encoding.UTF7.GetString(data);

            return(XMLSerializableBase.Deserialize <EasFolderSyncState>(@string, true));
        }
 internal static PSTSyncStateDictionary Deserialize(string blob)
 {
     return(XMLSerializableBase.Deserialize <PSTSyncStateDictionary>(blob, false));
 }
        private void PrivateValidate(ConfigSchemaBase schema)
        {
            if ("EnableSettingsGroup" == base.ParameterSetName)
            {
                HashSet <string> hashSet = new HashSet <string>();
                foreach (string text in new string[]
                {
                    this.EnableGroup,
                    this.DisableGroup
                })
                {
                    if (!string.IsNullOrEmpty(text))
                    {
                        if (!this.DataObject.Settings.ContainsKey(text))
                        {
                            base.WriteError(new ExchangeSettingsGroupNotFoundException(text), ExchangeErrorCategory.Client, this.DataObject);
                        }
                        if (hashSet.Contains(text))
                        {
                            base.WriteError(new ExchangeSettingsGroupFoundMultipleTimesException(text), ExchangeErrorCategory.Client, this.DataObject);
                        }
                        hashSet.Add(text);
                    }
                }
                if (hashSet.Count <= 0)
                {
                    base.WriteError(new RecipientTaskException(Strings.ExchangeSettingsEnableUsage), ExchangeErrorCategory.Client, this.DataObject);
                }
                return;
            }
            if ("CreateSettingsGroupAdvanced" == base.ParameterSetName || "UpdateSettingsGroupAdvanced" == base.ParameterSetName)
            {
                this.SelectedSettingsGroup = XMLSerializableBase.Deserialize <SettingsGroup>(this.SettingsGroup, InternalExchangeSettingsSchema.ConfigurationXMLRaw);
                this.ValidateGroupName(this.SelectedSettingsGroup.Name, "CreateSettingsGroupAdvanced" == base.ParameterSetName);
                this.ValidatePriority(this.SelectedSettingsGroup.Priority);
                this.ValidateSettingsGroup(schema);
                return;
            }
            bool flag = "CreateSettingsGroup" == base.ParameterSetName || "CreateSettingsGroupGeneric" == base.ParameterSetName;

            this.ValidateGroupName(this.GroupName, flag);
            if (flag)
            {
                this.SelectedSettingsGroup = this.CreateNewSettingsGroup();
                if (!this.Disable)
                {
                    this.SelectedSettingsGroup.Enabled = true;
                }
            }
            else if (this.GroupName == "default" && !this.DataObject.Settings.ContainsKey(this.GroupName) && ("UpdateSetting" == base.ParameterSetName || "UpdateMultipleSettings" == base.ParameterSetName))
            {
                base.WriteVerbose(new LocalizedString(string.Format("Creating default group for new settings", new object[0])));
                this.SelectedSettingsGroup         = this.CreateNewSettingsGroup();
                this.SelectedSettingsGroup.Enabled = true;
                this.DataObject.AddSettingsGroup(this.SelectedSettingsGroup);
            }
            else if (!this.ClearHistory || this.IsFieldSet("GroupName"))
            {
                this.SelectedSettingsGroup = this.DataObject.GetSettingsGroupForModification(this.GroupName);
            }
            if (this.IsFieldSet("Priority"))
            {
                this.ValidatePriority(this.Priority);
                this.SelectedSettingsGroup.Priority = this.Priority;
            }
            else if (flag)
            {
                this.ValidatePriority(this.SelectedSettingsGroup.Priority);
            }
            if ("UpdateSettingsGroup" == base.ParameterSetName)
            {
                if (this.IsFieldSet("ScopeFilter"))
                {
                    if (!this.SelectedSettingsGroup.HasExplicitScopeFilter && (this.SelectedSettingsGroup.Scopes.Count != 1 || !(this.SelectedSettingsGroup.Scopes[0] is SettingsForestScope)))
                    {
                        base.WriteError(new ExchangeSettingsCannotChangeScopeFilterOnDownlevelGroupException(this.GroupName), ExchangeErrorCategory.Client, this.DataObject);
                    }
                    this.SelectedSettingsGroup.ScopeFilter = this.ScopeFilter;
                }
                if (this.IsFieldSet("ExpirationDate"))
                {
                    if (this.ExpirationDate != null && this.ExpirationDate.Value < DateTime.UtcNow)
                    {
                        this.WriteWarning(Strings.ExchangeSettingsExpirationDateIsInThePastWarning(this.ExpirationDate.Value.ToString()));
                    }
                    this.SelectedSettingsGroup.ExpirationDate = (this.ExpirationDate ?? DateTime.MinValue);
                }
            }
            if (this.ScopeId == null && ("RemoveScope" == base.ParameterSetName || "UpdateScope" == base.ParameterSetName))
            {
                if (this.SelectedSettingsGroup.Scopes.Count != 1)
                {
                    base.WriteError(new ExchangeSettingsDefaultScopeNotFoundException(this.GroupName), ExchangeErrorCategory.Client, this.DataObject);
                }
                this.ScopeId = new Guid?(this.SelectedSettingsGroup.Scopes[0].ScopeId);
                base.WriteVerbose(new LocalizedString(string.Format("Using default scope {0}", this.ScopeId)));
            }
            if ("RemoveScope" == base.ParameterSetName)
            {
                if (this.SelectedSettingsGroup.HasExplicitScopeFilter)
                {
                    base.WriteError(new ExchangeSettingsCannotChangeScopeOnScopeFilteredGroupException(this.GroupName), ExchangeErrorCategory.Client, this.DataObject);
                }
                int num = this.SelectedSettingsGroup.Scopes.RemoveAll((SettingsScope x) => x.ScopeId == this.ScopeId);
                if (num <= 0)
                {
                    base.WriteError(new ExchangeSettingsScopeNotFoundException(this.GroupName, this.ScopeId.ToString()), ExchangeErrorCategory.Client, this.DataObject);
                }
                if (this.SelectedSettingsGroup.Scopes.Count <= 0)
                {
                    this.SelectedSettingsGroup.Scopes.Add(new SettingsForestScope());
                }
            }
            else if ("AddScope" == base.ParameterSetName)
            {
                if (this.SelectedSettingsGroup.HasExplicitScopeFilter)
                {
                    base.WriteError(new ExchangeSettingsCannotChangeScopeOnScopeFilteredGroupException(this.GroupName), ExchangeErrorCategory.Client, this.DataObject);
                }
                this.SelectedSettingsGroup.Scopes.Add(this.CreateDownlevelScope());
            }
            else if ("UpdateScope" == base.ParameterSetName)
            {
                if (this.SelectedSettingsGroup.HasExplicitScopeFilter)
                {
                    base.WriteError(new ExchangeSettingsCannotChangeScopeOnScopeFilteredGroupException(this.GroupName), ExchangeErrorCategory.Client, this.DataObject);
                }
                SettingsScope settingsScope = this.SelectedSettingsGroup.Scopes.Find((SettingsScope x) => x.ScopeId == this.ScopeId);
                if (settingsScope == null)
                {
                    base.WriteError(new ExchangeSettingsScopeNotFoundException(this.GroupName, this.ScopeId.ToString()), ExchangeErrorCategory.Client, this.DataObject);
                }
                this.WriteWarning(new LocalizedString("The use of Scopes is deprecated, use ScopeFilter instead."));
                if (settingsScope is SettingsForestScope)
                {
                    base.WriteError(new ExchangeSettingsUpdateScopeForestException(this.GroupName, this.ScopeId.ToString()), ExchangeErrorCategory.Client, this.DataObject);
                }
                else if (settingsScope is SettingsGenericScope)
                {
                    if (this.IsFieldSet("GenericScopeName"))
                    {
                        settingsScope.Restriction.SubType = this.GenericScopeName;
                    }
                    if (this.IsFieldSet("GenericScopeValue"))
                    {
                        settingsScope.Restriction.NameMatch = this.GenericScopeValue;
                    }
                }
                else
                {
                    if (this.IsFieldSet("NameMatch"))
                    {
                        settingsScope.Restriction.NameMatch = this.NameMatch;
                    }
                    if (this.IsFieldSet("GuidMatch") && this.GuidMatch != null)
                    {
                        settingsScope.Restriction.NameMatch = this.GuidMatch.ToString();
                    }
                    if (this.IsFieldSet("MinVersion"))
                    {
                        settingsScope.Restriction.MinVersion = this.MinVersion;
                    }
                    if (this.IsFieldSet("MaxVersion"))
                    {
                        settingsScope.Restriction.MaxVersion = this.MaxVersion;
                    }
                }
            }
            if ("UpdateSettingsGroup" == base.ParameterSetName || "CreateSettingsGroup" == base.ParameterSetName || "AddScope" == base.ParameterSetName || "UpdateScope" == base.ParameterSetName || "CreateSettingsGroupGeneric" == base.ParameterSetName || "RemoveScope" == base.ParameterSetName)
            {
                this.ValidateSettingsGroup(schema);
            }
            if ("UpdateSetting" == base.ParameterSetName || "RemoveSetting" == base.ParameterSetName)
            {
                this.ModifiedSettings = new List <KeyValuePair <string, string> >(1);
                this.ModifiedSettings.Add(new KeyValuePair <string, string>(this.ConfigName, this.ConfigValue));
            }
            else if ("UpdateMultipleSettings" == base.ParameterSetName || "RemoveMultipleSettings" == base.ParameterSetName)
            {
                this.ModifiedSettings = new List <KeyValuePair <string, string> >(this.ConfigPairs.Length);
                foreach (string text2 in this.ConfigPairs)
                {
                    string key   = text2;
                    string value = null;
                    int    num2  = text2.IndexOf('=');
                    if (num2 < 0)
                    {
                        if ("UpdateMultipleSettings" == base.ParameterSetName)
                        {
                            base.WriteError(new ExchangeSettingsBadFormatOfConfigPairException(text2), ExchangeErrorCategory.Client, this.DataObject);
                        }
                    }
                    else
                    {
                        key   = text2.Substring(0, num2);
                        value = text2.Substring(num2 + 1);
                    }
                    this.ModifiedSettings.Add(new KeyValuePair <string, string>(key, value));
                }
            }
            if (("UpdateSetting" == base.ParameterSetName || "UpdateMultipleSettings" == base.ParameterSetName) && !this.Force)
            {
                foreach (KeyValuePair <string, string> keyValuePair in this.ModifiedSettings)
                {
                    try
                    {
                        schema.ParseAndValidateConfigValue(keyValuePair.Key, keyValuePair.Value, null);
                    }
                    catch (ConfigurationSettingsException exception)
                    {
                        base.WriteError(exception, ExchangeErrorCategory.Client, this.DataObject);
                    }
                }
            }
        }