Re: Loosing roles between two pages ?
From: Joe Kaplan \(MVP - ADSI\) (joseph.e.kaplan_at_removethis.accenture.com)
Date: 03/29/04
- Previous message: Gerald Trainer: "ASPNET_SETREG and Framework 1.1"
- In reply to: Gilles Lambert: "Loosing roles between two pages ?"
- Next in thread: Joe Fallon: "Re: Loosing roles between two pages ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Mon, 29 Mar 2004 15:33:27 -0600
You have to set the principal on every request. This is often done with an
event handler in your global.asax or with an HttpModule.
Where is your code running and is it running on every request?
Joe K.
"Gilles Lambert" <gntools@hotmail.com> wrote in message
news:eYk0mOXFEHA.1368@TK2MSFTNGP11.phx.gbl...
> Hi,
>
> I try to use roles in a ASP .NET application after users are athentified
> in this way :
>
> Dim sRoles() As String = {"User1", "User2", "User2"}
> With Thread.CurrentPrincipal
> Dim gi As New GenericIdentity(.Identity.Name)
> Dim gp = New GenericPrincipal(gi, sRoles)
> AppDomain.CurrentDomain.SetPrincipalPolicy _
> (PrincipalPolicy.UnauthenticatedPrincipal)
> End With
>
> Thread.CurrentPrincipal = gp
>
> Then, if i test the IsInRole Method in the same page, it is ok :
>
> Thread.CurrentPrincipal.IsInRole("User1") 'Returns True
>
> But when i test this method in another following page, all roles are
> lost (it returns always false).
>
> So is it normal or should i do something else ?
>
> Thanks for your answer and best regards.
> Gilles
>
>
>
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!
- Previous message: Gerald Trainer: "ASPNET_SETREG and Framework 1.1"
- In reply to: Gilles Lambert: "Loosing roles between two pages ?"
- Next in thread: Joe Fallon: "Re: Loosing roles between two pages ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|
|