1
我正在尝试使用我在ADAM中创建的用户对ADAM进行身份验证。但是,无论使用哪个密码(正确或不正确),我的搜索都会返回一个有效的DirectoryEntry对象。我会假设如果密码无效,那么搜索将返回一个空对象。我的假设是错误的还是在下面的代码中存在缺陷?ADAM认证 - howto?
DirectoryEntry de = new DirectoryEntry("LDAP://localhost:389/cn=Groups,cn=XXX,cn=YYY,dc=ZZZ");
DirectorySearcher deSearch = new DirectorySearcher();
deSearch.SearchRoot = de;
deSearch.Filter = "(&(objectClass=user) (cn=" + userId + "))";
SearchResultCollection results = deSearch.FindAll();
if (results.Count > 0)
{
DirectoryEntry d = new DirectoryEntry(results[0].Path, userId, password);
if (d != null)
DoSomething();
}
太好了,谢谢。这非常有帮助。 现在我遇到了一个问题,无论是否输入正确的密码,我都会收到无效的用户/密码。有什么想法吗? – user26218 2008-11-19 17:37:04