System.DirectoryServices.Protocols
.net名前空間 APIを使用して SSL 経由で Active Directory に接続しようとしています
Active Directory に接続するために作成したスニペットを次に示します。
LdapConnection ldapConnection = new LdapConnection(new LdapDirectoryIdentifier("<ipaddress>:<port>"));
ldapConnection.AuthType = AuthType.Basic;
LdapSessionOptions options = ldapConnection.SessionOptions;
options.SecureSocketLayer = true;
options.ProtocolVersion = 3;
X509Certificate cert = new X509Certificate();
cert.Import(@"E:\client.crt");
ldapConnection.ClientCertificates.Add(cert);
ldapConnection.Credential = new NetworkCredential("administrator", "xxxxxxxxxx");
ldapConnection.Bind();
Console.WriteLine("successfully connected");
このスニペットを実行しようとすると、常に LDAP サーバーを使用できないというエラーが発生します。同じものに相当するJAVAを作成しましたが、サーバーに接続できるため、証明書またはアクティブディレクトリ接続に問題はないと思います。同じ IP アドレスとポート 389 を使用して、ssl なしで Active Directory に接続することもできます。
ありがとう