【发布时间】:2014-09-11 06:17:14
【问题描述】:
我正在传递用户名和密码以检查用户是否在 Active Directory 中有效。
这是我的代码:
private bool ValidUser(string name, string userPwd)
{
string UserName = "XXXXXXXXXX";
string Password = "XXXXXXXXXXXXX";
DirectoryEntry objRootEntry = new DirectoryEntry("XXXXXXXX.com", UserName, Password);
DirectorySearcher objADSearcher = new DirectorySearcher(objRootEntry);
objADSearcher.Filter = ("(&(sAMAccountType=xxxxxxxxx)(samAccountName=" + name + "))");
SearchResult objResult = objADSearcher.FindOne();
DirectoryEntry objLoginEntry = (objResult != null) ? objResult.GetDirectoryEntry() : null;
if (objLoginEntry != null)
{
return true;
}
return false;
}
现在它只检查用户名。我需要检查输入密码(userPwd)是否与活动目录匹配。如何做到这一点。
请帮帮我。
【问题讨论】:
-
.Net 有哪些版本?
标签: c# asp.net active-directory