2
我试图使用应用程序模式(ADAM)对AD进行身份验证,但一直收到未知的用户名或密码错误。如果我在LDP.exe
中测试登录,则在简单绑定上登录没有问题。我浏览过所有类似的帖子,但都没有解决,我应该检查什么建议?未知用户名或密码错误,LDAP Active Directory
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;
}
我都试过上下文的,DirectoryEntry的和主 - 都是具有相同的结果,主要使用ContextType.ApplicationDirectory因为它是ADAM。我有应用程序池作为ApplicationPoolIdentity,我尝试使用Localservice,Localsystem,但得到相同的错误。 – PeteTheGreek
只是为了踢,你有没有尝试在web.config中添加标识impersonate = true,它将在请求用户的上下文中执行请求,如果有效的话,perms是问题。 – kd7
试过,没有效果,问题仍然存在。我已经在AD中设置了userprincipalname,如果我在VS中创建一个新站点,并将成员资格提供程序更改为AD,则它不会出现问题,但不会出现上述代码。 –
PeteTheGreek