62,047
社区成员
发帖
与我相关
我的任务
分享
protected void Login1_Authenticate1(object sender, AuthenticateEventArgs e)
{
bool Authenticated = false;
Authenticated = SiteLevelCustomAuthenticationMethod(Login1.UserName, Login1.Password);
e.Authenticated = Authenticated;
if (Authenticated == true)
{
Response.Redirect("Home.aspx");
}
}
private bool SiteLevelCustomAuthenticationMethod(string UserName, string Password)
{
bool boolReturnValue = false;
SqlConnection Connection = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLconnStr"].ConnectionString);
String strSQL = "Select * From user";
SqlCommand command = new SqlCommand(strSQL, Connection);
SqlDataReader Dr;
Connection.Open();
Dr = command.ExecuteReader();
while (Dr.Read())
{
if ((UserName == Dr["name"].ToString()) & (Password == Dr["Paswd"].ToString()))
{
boolReturnValue = true;
}
Dr.Close();
return boolReturnValue;
}
}
while (Dr.Read())
{
if ((UserName == Dr["name"].ToString()) & (Password == Dr["Paswd"].ToString()))
{
boolReturnValue = true;
}
Dr.Close();
return boolReturnValue;
}
private bool SiteLevelCustomAuthenticationMethod(string UserName, string Password)
{
bool boolReturnValue = false;
SqlConnection Connection = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLconnStr"].ConnectionString);
String strSQL = "Select * From user";
SqlCommand command = new SqlCommand(strSQL, Connection);
SqlDataReader Dr;
Connection.Open();
Dr = command.ExecuteReader();
while (Dr.Read())
{
if ((UserName == Dr["name"].ToString()) & (Password == Dr["Paswd"].ToString()))
{
boolReturnValue = true;
}
Dr.Close();
}
return boolReturnValue;
}