Hi i have a simple custom member ship provider:

Can anyone help me with a simple if statement or switch case where i can route administrators to one page and users to another?

I am currently using the asp.net login controls and dont see how i can specify two different locations depending on the user.

Many Thanks

Grant

my login code:

public override bool ValidateUser(string username, string password)
    {

        SqlConnection conn = new SqlConnection(_connectionString);

        try
        {
            conn.Open();
            string sSQL = "select * from users where U_Name = @username and U_password = @password";
            
            SqlCommand comm = new SqlCommand(sSQL, conn);
            comm.Parameters.AddWithValue("@username", username);
            comm.Parameters.AddWithValue("@password", password);

            SqlDataReader dr = comm.ExecuteReader();

            if (dr.HasRows)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }

        finally
        
        {
            conn.Close();
        }
    }
// i hope you might have roles while doing this..
//which would be Admin, NormalUser
// if user in Admin Role then
FormsAuthentication.SetAuthCookie(UserName.Text,RememberMe.Checked)
Response.Redirect("AdminPage.aspx");

// if user in Normal Role then
FormsAuthentication.SetAuthCookie(UserName.Text,RememberMe.Checked)
Response.Redirect("NormalPage.aspx");

that's the best way to resolve this problem.
if you wanna learn more then
http://asp.net/learn/security/

Hi Thanks for the reply,

I was hoping to just modify the validate user event in the membership provider as i havent implemented roles as that would be too overkill for what i need.

Any ideas?

thanks.
grant

i'm sorry i didn't get it..
could you explain how you want to implement this part..?

Sorry,

I mean is there a way i can add in my code above some like

if role = admin {go here} else {go here}

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.