System.DirectoryServices.AccountManagement
.NET 3.5名前空間を使用して、SSL 暗号化 LDAP 接続を介して Active Directory LDAP サーバーに対してユーザー資格情報を検証しようとしています。サンプルコードは次のとおりです。
using (var pc = new PrincipalContext(ContextType.Domain, "sd.example.com:389", "DC=sd,DC=example,DC=com", ContextOptions.Negotiate))
{
return pc.ValidateCredentials(_username, _password);
}
このコードは、セキュリティで保護されていない LDAP (ポート 389) では問題なく動作しますが、ユーザーとパスの組み合わせをクリア テキストで送信したくありません。しかし、LDAP + SSL (ポート 636) に変更すると、次の例外が発生します。
System.DirectoryServices.Protocols.DirectoryOperationException: The server cannot handle directory requests.
at System.DirectoryServices.Protocols.ErrorChecking.CheckAndSetLdapError(Int32 error)
at System.DirectoryServices.Protocols.LdapSessionOptions.FastConcurrentBind()
at System.DirectoryServices.AccountManagement.CredentialValidator.BindLdap(NetworkCredential creds, ContextOptions contextOptions)
at System.DirectoryServices.AccountManagement.CredentialValidator.Validate(String userName, String password)
at System.DirectoryServices.AccountManagement.PrincipalContext.ValidateCredentials(String userName, String password)
at (my code)
ポート 636 は、その LDAP/AD エントリのパスワード以外の情報を検索するなど、他のアクティビティにも使用できます...
UserPrincipal.FindByIdentity(pc, IdentityType.SamAccountName, _username)
...だから、他のルックアップでは SSL を介して動作するため、LDAP サーバーの SSL 設定ではないことはわかっています。
ValidateCredentials(...)
SSL を介して動作するように呼び出しを受けた人はいますか? 方法を説明できますか?または、AD/LDAP 資格情報を安全に検証するための別の/より良い方法はありますか?