2
我有以下代码来验证Active Directory用户(在Win7上的VS2008)。根据AD异常验证用户名和密码
try
{
PrincipalContext pc = new PrincipalContext(ContextType.Domain, strDomainName))
isPass = pc.ValidateCredentials(strDomainUserName, strDomainUserPass);
}
catch (Exception ex)
{
Logger.Log("authentiate domain user fail: {0},{1}", ex.ToString(), strDomainUserLoginName);
}
某些广告的用户,这是确定的,但对于AD用户,我会出现以下情况例外: System.DirectoryServices.Protocols.DirectoryOperationException:
The server cannot handle directory requests.
System.DirectoryServices.Protocols.ErrorChecking.CheckAndSetLdapError(Int32 error)
System.DirectoryServices.Protocols.LdapSessionOptions.FastConcurrentBind()
System.DirectoryServices.AccountManagement.CredentialValidator.BindLdap(NetworkCredential creds, ContextOptions contextOptions)
System.DirectoryServices.AccountManagement.CredentialValidator.Validate(String userName, String password)
System.DirectoryServices.AccountManagement.PrincipalContext.ValidateCredentials(String userName, String password)
因此,没有Active Directory域用户设置会造成这样的例外?
看看这篇文章的解决方案http://stackoverflow.com/questions/2473222/validatecredentials-returns-false-on-first-call-but-true-on-subsequent-calls – MethodMan 2013-02-20 09:03:34
你也可以看看这个Stackoverflow发布我相信它会回答你的问题.. http://stackoverflow.com/questions/9473314/active-directory-principalcontext-validatecredentials-domain-disambiguation – MethodMan 2013-02-20 09:04:54