这是我的代码:
public bool ActiveDirectoryAuthenticate(string username, string password)
{
var result = false;
using (var entry = new DirectoryEntry("LDAP://*****/DC=******,DC=biz",username,password,AuthenticationTypes.Secure))
{
var searcher = new DirectorySearcher(entry){Filter = "objectClass=user"};
try
{
var sr = searcher.FindOne();
var PathDic = sr.Properties["distinguishedName"][0].ToString();
result = true;
}
catch (Exception exception)
{
}
}
return result;
}
问题是
sr.Properties["distinguishedName"][0].ToString();
不返回正确的值。
请帮我