【发布时间】:2011-11-18 13:38:21
【问题描述】:
我正在尝试使用应用程序模式 (ADAM) 对 AD 进行身份验证,但不断收到未知用户名或错误密码。如果我在LDP.exe 中测试登录,它登录没问题,简单绑定。我已经浏览了所有具有相同问题的类似帖子,但还没有解决,有什么建议我应该检查一下吗?
private bool ValidateActiveDirectoryLogin(string Username, string Password)
{
bool Success = false;
System.DirectoryServices.DirectoryEntry Entry = new System.DirectoryServices.DirectoryEntry("LDAP://localhost:389/OU=Users,O=TestDirectory", Username, Password);
System.DirectoryServices.DirectorySearcher Searcher = new System.DirectoryServices.DirectorySearcher(Entry);
Searcher.SearchScope = System.DirectoryServices.SearchScope.Subtree;
try
{
System.DirectoryServices.SearchResult Results = Searcher.FindOne();
Success = (Results != null);
}
catch (Exception ex)
{
Success = false;
throw;
}
return Success;
}
【问题讨论】: