2016-08-25 1 views
1

LdapDirectoryIdentifierを使用してldapを使用して認証し、openldapサーバーと通信しようとしています。認証にldapを使用するC#ASP.NETアプリケーション

コードは、コードを実行すると、LDAPサーバが利用できない旨()バインドで私に例外を与える

  dapDirectoryIdentifier ldi = new LdapDirectoryIdentifier("ldap.com", 636); 
      LdapConnection lconn = new LdapConnection(ldi); 
      lconn.SessionOptions.ProtocolVersion = 3; 
      lconn.Bind(); 
      lconn.Dispose(); 

スニペット。しかし、私のnetstatを見直すと、そこに接続が確立されます。他に利用可能なエラーメッセージはありません。

答えて

1

ポート636はSSL用です。あなたはSSL(SecureSocketLayer = true)を介して、そのサーバーにアクセスできることを確認しLdapConnectionと直接試してみてください。これが動作するかどうか

using (var ldapConnection = new LdapConnection("my.ad.server:636")) { 
        var networkCredential = new NetworkCredential(username, password, "my.ad.server"); 
ldapConnection.SessionOptions.SecureSocketLayer = true; 
        ldapConnection.AuthType = AuthType.Negotiate; 
        ldapConnection.Bind(networkCredential); 
       } 

を参照してください。

+1

これは部分的に答えでした。証明書もありませんでしたので、lconn.SessionOptions.VerifyServerCertificate = new VerifyServerCertificateCallback((con、ver)=> true)を使用して回避する必要がありました。 – adroit

関連する問題