我通過用戶名和密碼來檢查用戶是否從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;
}
現在檢查用戶名alone.I需要檢查輸入密碼(userPwd)是否與Active Directory相匹配。怎麼做。
請幫我一把。
可能重複(http://stackoverflow.com/questions/400872/active-directory- check-username-password) – 2014-09-11 07:59:07
什麼版本的.Net? – jww 2014-09-11 08:33:28
即時通訊使用.net 4 – Mythily 2014-09-11 09:31:20