public static void ProcessMoveRequestCreatedNotification(Guid requestGuid, Guid mdbGuid) { using (RequestJobProvider requestJobProvider = new RequestJobProvider(mdbGuid)) { RequestStatisticsBase moveRequest = (RequestStatisticsBase)requestJobProvider.Read <RequestStatisticsBase>(new RequestJobObjectId(requestGuid, mdbGuid, null)); if (moveRequest != null && !(moveRequest.ValidationResult != RequestJobBase.ValidationResultEnum.Valid)) { if (moveRequest.RequestStyle == RequestStyle.CrossOrg && moveRequest.RequestType == MRSRequestType.Move) { CommonUtils.CatchKnownExceptions(delegate { Guid physicalMailboxGuid = moveRequest.ArchiveOnly ? (moveRequest.ArchiveGuid ?? Guid.Empty) : moveRequest.ExchangeGuid; ProxyControlFlags proxyControlFlags = ProxyControlFlags.DoNotApplyProxyThrottling | moveRequest.GetProxyControlFlags(); IMailbox mailbox; MailboxType mbxType; Guid mdbGuid2; if (moveRequest.Direction == RequestDirection.Pull) { if ((moveRequest.Flags & RequestFlags.RemoteLegacy) != RequestFlags.None) { mailbox = new MapiSourceMailbox(LocalMailboxFlags.None); mailbox.ConfigADConnection(moveRequest.SourceDCName, moveRequest.SourceDCName, moveRequest.SourceCredential); } else { mailbox = new RemoteSourceMailbox(moveRequest.RemoteHostName, moveRequest.RemoteOrgName, moveRequest.RemoteCredential, proxyControlFlags, null, true, LocalMailboxFlags.None); } mbxType = MailboxType.SourceMailbox; mdbGuid2 = Guid.Empty; } else { if ((moveRequest.Flags & RequestFlags.RemoteLegacy) != RequestFlags.None) { mailbox = new MapiDestinationMailbox(LocalMailboxFlags.None); mailbox.ConfigADConnection(moveRequest.TargetDCName, moveRequest.TargetDCName, moveRequest.TargetCredential); } else { mailbox = new RemoteDestinationMailbox(moveRequest.RemoteHostName, moveRequest.RemoteOrgName, moveRequest.RemoteCredential, proxyControlFlags, null, true, LocalMailboxFlags.None); } mbxType = MailboxType.DestMailboxCrossOrg; mdbGuid2 = ((moveRequest.ArchiveOnly ? moveRequest.RemoteArchiveDatabaseGuid : moveRequest.RemoteDatabaseGuid) ?? Guid.Empty); } using (mailbox) { mailbox.Config(null, moveRequest.ExchangeGuid, physicalMailboxGuid, null, mdbGuid2, mbxType, null); mailbox.Connect(MailboxConnectFlags.None); mailbox.UpdateRemoteHostName(moveRequest.UserOrgName); mailbox.Disconnect(); } }, null); } } } }
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); }