ASP.NET でログイン ページを作成しています。3 回失敗したユーザーをブロックし、10 分後にブロックを解除したいと考えています。Login Control を使っていないので、Membership Provider が使えないので、Timeout を使おうと考えました。以下のコードを変更して、ユーザーをブロックおよびブロック解除するにはどうすればよいですか?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;
using Replicon.Cryptography.SCrypt;
namespace WebApplication1
{
public partial class SignIn : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
public class LoginAttempt { public DateTime AttemptTime {get;set;} }
protected void Button1_Click(object sender, EventArgs e)
{
String CS = ConfigurationManager.ConnectionStrings["MyDatabaseConnectionString1"].ConnectionString;
using (SqlConnection con = new SqlConnection(CS))
{
SqlCommand cmd = new SqlCommand("select * from Users where Username=@Username", con);
cmd.Parameters.Add("@Username", Username.Text);
con.Open();
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
sda.Fill(dt);
if (dt.Rows.Count != 0)
{
foreach (DataRow row in dt.Rows)
{
if (Replicon.Cryptography.SCrypt.SCrypt.Verify(Password.Text, (string)row["Password"]))
{
Session["USERNAME "] = Username.Text;
Response.Redirect("~/UserHome.aspx");
return;
}
{ lblError.Text = "Invalid Username or Password !"; }
}
}
}
}
}
}