public static bool IsUserValid(SISUsers pUserType, string pUsername) { bool blnReturn = false; using (SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["Speedo"].ToString())) { SqlCommand cmd = cn.CreateCommand(); if (pUserType == SISUsers.Encoder) { cmd.CommandText = "SELECT userlvl FROM CM.SisUsers WHERE userlvl='encoder' AND username='******' AND pstatus='1'"; } cn.Open(); SqlDataReader dr = cmd.ExecuteReader(); blnReturn = dr.Read(); dr.Close(); } return(blnReturn); }
public static void AuthenticateUser(SISUsers pUserType, string pUserName) { bool blnHasRecord; using (SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["Speedo"].ToString())) { SqlCommand cmd = cn.CreateCommand(); if (pUserType == SISUsers.Encoder) { cmd.CommandText = "SELECT userlvl FROM CM.SisUsers WHERE username='******' AND userlvl='encoder'"; } cn.Open(); SqlDataReader dr = cmd.ExecuteReader(); blnHasRecord = dr.Read(); dr.Close(); } if (!blnHasRecord) { HttpContext.Current.Response.Redirect("~/AccessDenied.aspx"); } }