Problem With UserInRole

Discussion in 'ASP.NET Starter Kits' started by wengert, Feb 10, 2006.

  1. I have a web site based on the Club Starter Kit. I put all the application tables and the ASPNETDB tables, views and SPs in a single SQL2000 DB hosted by DiscountASP.net. Most of the processes are working fine but when I run the web site from my DiscountASP.net web site, the user.IsInRole("Administrators") never returns True, even for users in that role? If I run the web pages from my local machine (same database), it works fine? It appears that something on my DiscountASP.net web site is causing that to fail. I created a special test.aspx page that displays all the information relating to the logged in user (name, role, application, etc.) and everything looks right. The user's role is shown as "Administrators".

    Does anyone have any thoughts on why just the


    User.IsInRole("Administrators")


    always returns false?

    ------------
    Wayne
     
  2. A little more information:


    After logging in as a user who has the "Administrators" role, if I fudge the code to set the IsAdmin variable to True, if I then click on something like the "Add New Event" button on the Events link, it takes me to the login page. Again, as if the fact I am logged in is not seen. From what I can figure out, I think that when I get to the Events_Edit.aspx page, the Login_Banner.ascx LoginView1 control does not see the user as logged in?


    Does anyone know where/how that is determined?


    ------------
    Wayne
     
  3. After doing a little research it looks like the Administrators group is a builtin group, You might have to pass in the Try using "BUILTIN\\Administrators" for the group. The group names might also be case sensitive.

    Please let us know if this works.


    This may apply to _all_ builtin groups.


    Joel Thoms

    DiscountASP.NET
    http://www.DiscountASP.NET
     
  4. Thanks Joel. I'll give that a try and let you know what happens.


    ------------
    Wayne
     
  5. Joel;


    I tried testing the Administrator status using BUILTIN\\Administrators but that doesn't help and it also returns False even on the local system. I think you focused me in the right area as it sure seems like some built in function/process that needs to change. As I had indicated, a query of the user's role (accessing the application role table) returns the correct value. I'd love to see exactly whay value the system has for IsInRole("xxx"). I don't see how to find out what role the system thinks the user has.


    I tried some variations like "myApp\\Administrators" but those also always return False?


    ------------
    Wayne
     
  6. Also check the ApplicationId of the role. Make sure that it matches the ApplicationId of the application you are using in the aspnet_Applications table.

    DiscountASP.NET
    www.DiscountASP.NET
     
  7. Actually, I went through all the entries and verified applicationid, userid and roleid. All look fine?


    ------------
    Wayne
     

Share This Page