private void Connect(ReplicationTopology topology) { EdgeSyncLog edgeSyncLog = new EdgeSyncLog(string.Empty, new Version(), string.Empty, string.Empty, string.Empty); EdgeSyncLogSession logSession = edgeSyncLog.OpenSession(string.Empty, string.Empty, 0, string.Empty, EdgeSyncLoggingLevel.None); try { DirectTrust.Load(); NetworkCredential networkCredential = Util.ExtractNetworkCredential(topology.LocalHub, this.edgeServer.Fqdn, logSession); if (networkCredential == null) { this.failureDetail = Strings.NoCredentialsFound(this.EdgeServer.Fqdn).ToString(); } else { this.edgeConnection = (LdapTargetConnection)TestEdgeConnectionFactory.Create(topology.LocalHub, new TargetServerConfig(this.EdgeServer.Name, this.EdgeServer.Fqdn, this.EdgeServer.EdgeSyncAdamSslPort), networkCredential, SyncTreeType.General, logSession); this.failureDetail = string.Empty; if (this.edgeConnection != null) { this.ExtractLeaseInfo(); this.ExtractCookieRecords(); } } } catch (ExDirectoryException ex) { this.failureDetail = ex.Message; this.edgeConnection = null; } finally { DirectTrust.Unload(); } }
private bool VerifyServerCertificate(LdapConnection conn, X509Certificate cert) { SecurityIdentifier left = DirectTrust.MapCertToSecurityIdentifier(new X509Certificate2(cert)); if (left != WellKnownSids.EdgeTransportServers) { EdgeSyncEvents.Log.LogEvent(EdgeSyncEventLogConstants.Tuple_FailedDirectTrustMatch, null, new object[] { base.Host }); this.logSession.LogFailedDirectTrust(base.Host, "Failed: Microsoft Exchange couldn't match the certificate thumbprint. The connection was stopped.", new X509Certificate2(cert)); return(false); } return(true); }