public string IsAuthenticated(string UserID, string Password)
{
string _path = "LDAP://192.168.10.71/DC=wwsp,DC=com";//"LDAP://172.75.200.1/DC=名字,DC=com,DC=cn";
string _filterAttribute = null;
DirectoryEntry entry = new DirectoryEntry(_path, UserID, Password);
try
{
//Bind to the native AdsObject to force authentication.
DirectorySearcher search = new DirectorySearcher(entry);
search.Filter = "(SAMAccountName=" + UserID + ")";
SearchResult result = search.FindOne();
if (null == result)
{
_filterAttribute = "登录失败: 未知的用户名或错误密码.";
}
else
{
_filterAttribute = "true";
}
}
catch (Exception ex)
{
return ex.Message;
}
return _filterAttribute;
}
浙公网安备 33010602011771号