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);
        }
Example #2
0
 public StorageFxProxyPool(StorageDestinationMailbox destMailbox, ICollection <byte[]> folderIds) : base(folderIds)
 {
     this.destMailbox = destMailbox;
 }