A
Andrew Banks
I've added the following to my global.asax file and am having problems with
the line highlighted by the ######'s
Can anyone offer any suggestions on this please? I've been working from a
poor VB example and have converted to C# the best I can.
Any help would be appreciated.
Thanks
protected void Application_AuthenticateRequest(Object sender, EventArgs e)
{
if (Request.IsAuthenticated)
{
SqlConnection con;
string sql;
SqlCommand cmd;
SqlDataReader reader;
string roles;
con = new
SqlConnection(System.Configuration.ConfigurationSettings.AppSettings.Get("Co
nnectionString"));
sql = "SELECT AdminID, AddAdmin FROM Admin WHERE AdminID = '" +
User.Identity.Name + "'";
cmd = new SqlCommand(sql, con);
con.Open();
reader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
if (reader["AddAdmin"].ToString()=="1")
roles = "Management";
else
roles = "Staff";
###############################
HttpContext.Current.User = new GenericPrincipal(User.Identity,
roles);
###############################
con.Close();
}
}
the line highlighted by the ######'s
Can anyone offer any suggestions on this please? I've been working from a
poor VB example and have converted to C# the best I can.
Any help would be appreciated.
Thanks
protected void Application_AuthenticateRequest(Object sender, EventArgs e)
{
if (Request.IsAuthenticated)
{
SqlConnection con;
string sql;
SqlCommand cmd;
SqlDataReader reader;
string roles;
con = new
SqlConnection(System.Configuration.ConfigurationSettings.AppSettings.Get("Co
nnectionString"));
sql = "SELECT AdminID, AddAdmin FROM Admin WHERE AdminID = '" +
User.Identity.Name + "'";
cmd = new SqlCommand(sql, con);
con.Open();
reader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
if (reader["AddAdmin"].ToString()=="1")
roles = "Management";
else
roles = "Staff";
###############################
HttpContext.Current.User = new GenericPrincipal(User.Identity,
roles);
###############################
con.Close();
}
}