これが私の ASP.NET 認証操作です。
private void LoginButton_Click(Object sender,
EventArgs e)
{
string userName = txtUserName.Value;
string password = txtUserPass.Value;
if (ValidateUser(txtUserName.Value, txtUserPass.Value))
{
FormsAuthenticationTicket tkt;
string cookiestr;
HttpCookie ck;
tkt = new FormsAuthenticationTicket(1, txtUserName.Value, DateTime.Now,
DateTime.Now.AddMinutes(3), chkPersistCookie.Checked,
userName + "@ticket");
cookiestr = FormsAuthentication.Encrypt(tkt);
ck = new HttpCookie(FormsAuthentication.FormsCookieName, cookiestr);
if (chkPersistCookie.Checked)
ck.Expires = tkt.Expiration;
ck.Path = FormsAuthentication.FormsCookiePath;
Response.Cookies.Add(ck);
string strRedirect;
strRedirect = Request["ReturnUrl"];
if (strRedirect == null)
strRedirect = "MyAccount.aspx";
Response.Redirect(strRedirect, true);
}
else
Response.Redirect("logon.aspx", true);
}
すべての資格情報が保存されているデータベースに User テーブルがあります。メソッドを使用しValidateUser
て、資格情報の検証を行っています。また、メンバー、モデレーター、管理者の 3 種類のユーザーがいます。メンバーの各タイプには、固有の機能があります。A、B、および C の T-SQL がデータベース内に格納されているとします。
何を許可する必要がありますか:
メンバーはクエリのみを実行します。
司会者はAとBを実行します。
管理者は、A、B、および C を実行します。
もちろん、Web アプリから実行を管理することはできますが、安全性についてはわかりません。技術的には、App の外部で同様のクエリを実行できます。これにより、すべてのデータベース データにアクセスできます。どうにかしてWeb AppログインとDbアクセスも組み合わせたいです。
ありがとう!