Using ASP.NET Web Admin tool, i created 5 users and assigned them to different roles, but when i try to user Roles.IsUserInRole, it doesn't work, please take a look here:

protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
    {
        string username = Login1.UserName;
        string password = Login1.Password;

        if (!IsPostBack)
        {


            if (Membership.ValidateUser(username, password))
            {

                if (Roles.IsUserInRole("Saleman"))
                    Response.Redirect("~/Saleman.aspx");

                else if (Roles.IsUserInRole("Accountant"))
                    Response.Redirect("~/Accountant.aspx");

                else if (Roles.IsUserInRole("HR"))
                    Response.Redirect("~/HR.aspx");


                //Always receive Attempt to login failed message !!
            }
        }
    }

Recommended Answers

All 5 Replies

Help plz. ...

When you created each user did you approve their account? Make sure each user is in the 'approved' status, otherwise they won't validate.

Yes they're Active users if that what you mean!

up...

Problem solved, incorrect syntax, i should use it like that: Roles.IsUserInRole(string username, string rolename){}

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.