ユーザーがイントラネットアプリケーションにログインできるようにするには、Windows資格情報を使用する必要があります。私はユーザー名とロールを持つテーブルを作成し、Environment.UserName
のユーザー名と私のテーブルを比較する予定です。これを中継するのはどれくらい安全ですか?このタスクを達成するためのより良い方法はありますか?イントラネットアプリケーションでユーザーを認証する
ありがとうございます。
ユーザーがイントラネットアプリケーションにログインできるようにするには、Windows資格情報を使用する必要があります。私はユーザー名とロールを持つテーブルを作成し、Environment.UserName
のユーザー名と私のテーブルを比較する予定です。これを中継するのはどれくらい安全ですか?このタスクを達成するためのより良い方法はありますか?イントラネットアプリケーションでユーザーを認証する
ありがとうございます。
あなたは、この使用してActive Directory認証を行うことができます。
ベローは、あなたのアプリケーションで試すことができるサンプルコードです。あなたがWindowsアプリケーションで開発している場合
string domainUser = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
string[] paramsLogin = domainUser.Split('\\');
string domain = paramsLogin[0].ToString();
string LdapPath = "";
string strDomainPath = DomainPath();
LdapPath = string.Format("LDAP://{0}/{1}", DomainName, strDomainPath);
string username = LoginUser.UserName;
string password = LoginUser.Password;
string domainAndUsername = domain + @"\" + username;
DirectoryEntry entry = new DirectoryEntry(LdapPath, domainAndUsername, password);
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 (result != null)
{
IsLoginSucess = true;
//Do your stuff here
}
// Update the new path to the user in the directory
LdapPath = result.Path;
string _filterAttribute = (String)result.Properties["cn"][0];
}
catch (Exception ex)
{
IsLoginSucess = false;
}
、これを見てみましょう:あなたは、Webアプリケーションを開発している場合
Authenticate user in WinForms (Nothing to do with ASP.Net) System.Security.Principal.WindowsIdentity.GetCurrent()
はあなたの現在のWindowsユーザ
を与えるだろう、そこにあります組み込みのサポートでは、web.configファイルに関連するエントリが必要です。
Using windows authentication in asp.net with c#
HttpContext.Current.User.Identity
あなたにユーザーの身元をお知らせします