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