internal static MailboxReplicationServiceClient Create(IConfigurationSession session, MRSJobType jobType, Guid mdbGuid, List <string> unreachableMrsServers) { MRSCapabilities requiredCapability = RequestJobXML.MapJobTypeToCapability(jobType); string text = null; DatabaseInformation databaseInformation = MapiUtils.FindServerForMdb(mdbGuid, null, null, FindServerFlags.None); if (!string.IsNullOrEmpty(databaseInformation.ServerFqdn)) { text = databaseInformation.ServerFqdn.ToLower(CultureInfo.InvariantCulture); } List <string> mrsServers = MailboxReplicationServiceClient.GetMrsServers(session, mdbGuid); List <string> list = new List <string>(mrsServers.Count); foreach (string text2 in mrsServers) { string text3 = text2.ToLower(CultureInfo.InvariantCulture); if (string.Compare(text3, text, CultureInfo.InvariantCulture, CompareOptions.Ordinal) != 0 && !unreachableMrsServers.Contains(text3)) { list.Add(text2); } } List <string> list2 = CommonUtils.RandomizeSequence <string>(list); if (text != null) { list2.Insert(0, text); } foreach (string text4 in list2) { try { return(MailboxReplicationServiceClient.Create(text4, requiredCapability)); } catch (MailboxReplicationPermanentException ex) { MrsTracer.Common.Warning("Attempt to connect to CAS Server {0} failed with error: {1}", new object[] { text4, CommonUtils.FullExceptionMessage(ex) }); } catch (MailboxReplicationTransientException ex2) { MrsTracer.Common.Warning("Attempt to connect to CAS Server {0} failed with error: {1}", new object[] { text4, CommonUtils.FullExceptionMessage(ex2) }); } unreachableMrsServers.Add(text4.ToLower(CultureInfo.InvariantCulture)); } throw new NoMRSAvailableTransientException(); }
public static MailboxReplicationServiceClient Create(string serverName, MRSCapabilities requiredCapability) { MrsTracer.Common.Debug("MRSClient: attempting to connect to '{0}'", new object[] { serverName }); string text = string.Format("net.tcp://{0}/Microsoft.Exchange.MailboxReplicationService", serverName); NetTcpBinding netTcpBinding = new NetTcpBinding(SecurityMode.Transport); netTcpBinding.Security.Transport.ProtectionLevel = ProtectionLevel.EncryptAndSign; netTcpBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows; netTcpBinding.Security.Message.ClientCredentialType = MessageCredentialType.Windows; int config = ConfigBase <MRSConfigSchema> .GetConfig <int>("MrsBindingMaxMessageSize"); netTcpBinding.MaxReceivedMessageSize = (long)config; netTcpBinding.ReaderQuotas.MaxStringContentLength = config; netTcpBinding.ReaderQuotas.MaxArrayLength = config; EndpointAddress remoteAddress; try { remoteAddress = new EndpointAddress(text); } catch (UriFormatException innerException) { throw new InvalidEndpointAddressPermanentException(text, innerException); } MailboxReplicationServiceClient mailboxReplicationServiceClient = null; bool flag = false; try { mailboxReplicationServiceClient = new MailboxReplicationServiceClient(netTcpBinding, remoteAddress); mailboxReplicationServiceClient.ExchangeVersionInformation(requiredCapability); flag = true; } finally { if (!flag && mailboxReplicationServiceClient != null) { mailboxReplicationServiceClient.Dispose(); } } MrsTracer.Common.Debug("MRSClient: connected to '{0}', version {1}", new object[] { mailboxReplicationServiceClient.ServerVersion.ComputerName, mailboxReplicationServiceClient.ServerVersion }); return(mailboxReplicationServiceClient); }
public static MailboxReplicationServiceClient Create(string serverName, MRSJobType jobType) { return(MailboxReplicationServiceClient.Create(serverName, RequestJobXML.MapJobTypeToCapability(jobType))); }
public static MailboxReplicationServiceClient Create(string serverName) { return(MailboxReplicationServiceClient.Create(serverName, MRSJobType.Unknown)); }