我正在使用下面的代碼在Active Directory中驗證用戶身份,但密碼以明文形式發送。如何散列我的密碼然後發送到Active Directory?活動目錄身份驗證
DirectoryEntry entry = new DirectoryEntry(path, username, pwd);
try
{
//Bind to the native AdsObject to force authentication.
object obj = entry.NativeObject;
DirectorySearcher search = new DirectorySearcher(entry);
search.Filter = "(SAMAccountName=" + username + ")";
search.PropertiesToLoad.Add("cn");
SearchResult result = search.FindOne();
if (null == result)
{
return false;
}
//Update the new path to the user in the directory.
_path = result.Path;
_filterAttribute = (string)result.Properties["cn"][0];
}
catch (Exception ex)
{
throw new Exception("Error authenticating user. " + ex.Message);
}
return true;
這是一個很好的問題。出於好奇,你使用了什麼AuthenticationType? – Pandincus 2011-02-12 07:19:33
你是什麼意思的AuthenticationType,我使用System.DirectoryServices;名稱空間和提到的身份驗證代碼 – 2011-02-12 07:51:00