Page view counter

User.IsInRole doesn't work

Last post 08-25-2003 3:01 PM by aka. 3 replies.

Sort Posts:

  • User.IsInRole doesn't work

    08-25-2003, 9:08 AM
    • Loading...
    • ordell
    • Joined on 06-23-2002, 3:00 AM
    • Stockholm, Sweden
    • Posts 11
    • Points 55
    I Used the GenericPriciple and GenericIdentity to authorize a user, then assigned Context.User the GenericPrinciple object but when i Access the User.IsInRole() i always get a "False" result. The User.Identity.Name however works just fine... What can possibly be wrong?

    Also, I'm curious about the Global.asax Application_AuthenticateRequest, should I put the authorization code there, or in my Login.aspx.cs file?
  • Re: User.IsInRole doesn't work

    08-25-2003, 10:10 AM
    • Loading...
    • aka
    • Joined on 06-18-2002, 8:50 AM
    • Posts 165
    • Points 825
    You have to attache the generic prinicpal to the current user context. usually a good place to do it is the application_authenticaterequest event handler becuase this event is fired on every request.

    So move your code that creates a prinicapl and identity object in to the application_authenticaterequest event handler and attache it to to current user.

    HTH

    -aka
  • Re: User.IsInRole doesn't work

    08-25-2003, 2:01 PM
    • Loading...
    • ordell
    • Joined on 06-23-2002, 3:00 AM
    • Stockholm, Sweden
    • Posts 11
    • Points 55
    Ah, thanks a bunch, that was exactly what I wanted to do!

    Is it "good customs" to extend the GenericPricipal class and adding more options, or is the base functionality enough?
  • Re: User.IsInRole doesn't work

    08-25-2003, 2:58 PM
    • Loading...
    • aka
    • Joined on 06-18-2002, 8:50 AM
    • Posts 165
    • Points 825
    Good.

    I am not following the adding more options part in your posting. But all you need is to pass identity and roles information to an instance of Genericprinicpal object.

    HTH

    -aka
Page 1 of 1 (4 items)