62,046
社区成员
发帖
与我相关
我的任务
分享
//login.aspx.cs
private bool SiteLevelCustomAuthenticationMethod(string UserName,string Password)
{
bool boolReturnValue =false;
// Insert code that implements a site-specific custom
// authentication method here.
// This example implementation always returns false.
string strConnection = "server=WIN-VM5GVPGG2R3;database=laborage;integrated security=true;";
SqlConnection Connection =new SqlConnection(strConnection);
String strSQL = "Select * From ADMINISTRATOR";
SqlCommand command =new SqlCommand(strSQL, Connection);
SqlDataReader Dr;
Connection.Open();
Dr=command.ExecuteReader();
while(Dr.Read())
{
if((UserName == Dr["ID"].ToString()) & (Password == Dr["PWD"].ToString()))
{
boolReturnValue =true;
Session("admin") = Dr["ADNAME"];
}
Dr.Close();
return boolReturnValue;
}
return false;
}
if (Session["admin"] == null) Response.Redirect("~/login.aspx");