Exemple #1
0
        public LdapTargetConnection(int localServerVersion, TargetServerConfig config, NetworkCredential credentials, SyncTreeType type, EdgeSyncLogSession logSession) : base(localServerVersion, config)
        {
            this.type       = type;
            this.logSession = logSession;
            LdapDirectoryIdentifier identifier = new LdapDirectoryIdentifier(string.Format(CultureInfo.InvariantCulture, "{0}:{1}", new object[]
            {
                base.Host,
                base.Port
            }));

            ExTraceGlobals.ConnectionTracer.TraceDebug <string>((long)this.GetHashCode(), "Attempting to connect to {0}", base.Host);
            try
            {
                this.connection = new LdapConnection(identifier);
            }
            catch (LdapException ex)
            {
                ExTraceGlobals.ConnectionTracer.TraceError <string, string>((long)this.GetHashCode(), "Failed to create a LdapConnection to {0} because {1}", base.Host, ex.Message);
                throw new ExDirectoryException(ex);
            }
            this.connection.SessionOptions.VerifyServerCertificate = new VerifyServerCertificateCallback(this.VerifyServerCertificate);
            this.connection.SessionOptions.SecureSocketLayer       = true;
            this.connection.SessionOptions.Signing         = false;
            this.connection.SessionOptions.Sealing         = false;
            this.connection.SessionOptions.ReferralChasing = ReferralChasingOptions.None;
            this.connection.SessionOptions.ProtocolVersion = 3;
            this.connection.AuthType = AuthType.Basic;
            try
            {
                this.connection.Bind(credentials);
            }
            catch (DirectoryException ex2)
            {
                ExTraceGlobals.ConnectionTracer.TraceError <string, string>((long)this.GetHashCode(), "Failed to connect to {0} because {1}", base.Host, ex2.Message);
                throw new ExDirectoryException(ex2);
            }
            SearchResponse searchResponse = (SearchResponse)this.SendRequest(new SearchRequest(string.Empty, Schema.Query.QueryAll, System.DirectoryServices.Protocols.SearchScope.Base, null));

            if (searchResponse.Entries.Count == 1)
            {
                SearchResultAttributeCollection attributes = searchResponse.Entries[0].Attributes;
                this.adamConfigurationNamingContext = (string)attributes["configurationNamingContext"][0];
                this.adamRootOrgContainerDN         = "CN=First Organization,CN=Microsoft Exchange,CN=Services," + this.adamConfigurationNamingContext;
                string        ldapFilter = "(&(objectClass=msExchExchangeServer)(networkAddress=ncacn_ip_tcp:" + base.Host + "))";
                SearchRequest request    = new SearchRequest(this.adamConfigurationNamingContext, ldapFilter, System.DirectoryServices.Protocols.SearchScope.Subtree, new string[]
                {
                    "name"
                });
                searchResponse = (SearchResponse)this.SendRequest(request);
                if (searchResponse.Entries.Count > 0)
                {
                    this.serverDistinguishedName = searchResponse.Entries[0].DistinguishedName;
                    this.serverName = (string)searchResponse.Entries[0].Attributes["name"][0];
                    return;
                }
                throw new ExDirectoryException(ResultCode.NoSuchAttribute, "Could not read Edge server config object");
            }
            else
            {
                if (searchResponse.Entries.Count == 0)
                {
                    throw new ExDirectoryException(ResultCode.NoSuchAttribute, "Could not read ADAM config naming context");
                }
                throw new InvalidOperationException("expected single result");
            }
        }
Exemple #2
0
 public TargetConnection(int localServerVersion, TargetServerConfig config)
 {
     this.localServerVersion = localServerVersion;
     this.host = config.Host;
     this.port = config.Port;
 }
Exemple #3
0
 public LdapTargetConnection(int localServerVersion, TargetServerConfig config, EdgeSyncLogSession logSession) : base(localServerVersion, config)
 {
     this.logSession = logSession;
 }
 public abstract TargetConnection CreateTargetConnection(TargetServerConfig targetServerConfig, SyncTreeType type, TestShutdownAndLeaseDelegate testShutdownAndLease, EdgeSyncLogSession logSession);