域身份验证的问题
在验证域帐户和密码的时候, 帐户,密码都是正确的,可以正常登入域, 但就是验证不成功, 请各位高手指点.
代码如下:
public static DirectoryEntry GetDirectoryEntry(string commonName, string password)
{
string path = "LDAP://"+域名;
DirectoryEntry dirEntry = new DirectoryEntry(path, 域名+@"\"+commonName, password);
DirectorySearcher deSearch = new DirectorySearcher(dirEntry);
deSearch.Filter = "(SAMAccountName=" + commonName + ")";
try
{
SearchResult result = deSearch.FindOne();
DirectoryEntry de = new DirectoryEntry(result.Path);
return de;
}
catch
{
return null;
}
}