我试图使用.NET 3.5 System.DirectoryServices.AccountManagement
命名空间通过SSL加密的LDAP连接对我们的Active Directory LDAP服务器验证用户凭据。这里的示例代码:如何通过LDAP + SSL验证Active Directory信用?
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)
...所以我知道这不是我的LDAP服务器的SSL设置,因为它可以通过SSL进行其他查找。
是否有人通过SSL调用ValidateCredentials(...)
调用?你能解释一下吗?或者有另一种/更好的方法来安全验证AD/LDAP凭证?
以下是有关通过SSL对LDAP进行故障诊断的MSDN文章:http://support.microsoft.com/kb/938703 – CAbbott
感谢您的链接。但是,我可以通过LDAPS(端口636)进行通信,这对我已经执行的所有其他LDAP查询都很好。这似乎是有关'ValidateCredentials()'的一些不寻常的事情。不过,我会更详细地阅读文章。 –
除非LDAP客户端提供密码质量和历史检查,否则密码应以明文形式传输 - 不能散列 - 通过与支持密码质量检查和密码历史记录实施的服务器的安全连接进行传输,否则,服务器将无法执行质量和历史。 –