DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   ASP.NET (http://www.daniweb.com/forums/forum18.html)
-   -   Roles.IsUserInRole() can't get it work !!! (http://www.daniweb.com/forums/thread164772.html)

Yamazaki Dec 29th, 2008 10:12 am
Roles.IsUserInRole() can't get it work !!!
 
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 !!
            }
        }
    }

Yamazaki Dec 29th, 2008 5:14 pm
Re: Roles.IsUserInRole() can't get it work !!!
 
Help plz. ...

iDeveloper Dec 29th, 2008 10:09 pm
Re: Roles.IsUserInRole() can't get it work !!!
 
When you created each user did you approve their account? Make sure each user is in the 'approved' status, otherwise they won't validate.

Yamazaki Dec 30th, 2008 4:34 pm
Re: Roles.IsUserInRole() can't get it work !!!
 
Yes they're Active users if that what you mean!

Yamazaki Jan 2nd, 2009 4:13 pm
Re: Roles.IsUserInRole() can't get it work !!!
 
up...

Yamazaki Jan 5th, 2009 7:57 am
Re: Roles.IsUserInRole() can't get it work !!!
 
Problem solved, incorrect syntax, i should use it like that:

Roles.IsUserInRole(string username, string rolename){}


All times are GMT -4. The time now is 2:28 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC