Re: Loosing roles between two pages ?
From: Joe Kaplan \(MVP - ADSI\) (joseph.e.kaplan_at_removethis.accenture.com)
Date: 03/30/04
- Next message: Alek Davis: "Re: mimic NT password creation"
- Previous message: Joe Fallon: "Re: Loosing roles between two pages ?"
- In reply to: Joe Fallon: "Re: Loosing roles between two pages ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Mon, 29 Mar 2004 17:10:58 -0600
Ok, I see where you are setting the principal via an application event and I
saw the code where you are generating the principal earlier, but it isn't
clear how they are working together. Is the principal is getting added to
the session as part of the login process?
My suspicion is that an event downstream from is sticking a different
principal in the context after your code has already run. It may also be
the case that your code isn't executing at all on that particular request.
You might consider adding some tracing code to the rest of the events to see
if this is the case or set some breakpoints and run in the debugger.
However, you should definitely be able to get this to work.
Joe K.
"Joe Fallon" <jfallon1@nospamtwcny.rr.com> wrote in message
news:uIPO7tdFEHA.4012@TK2MSFTNGP09.phx.gbl...
> I use this in Global.asax for my CSLA based app:
>
> Private Sub Global_AcquireRequestState(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles MyBase.AcquireRequestState
>
> If Not Session("CSLA-Principal") Is Nothing Then
> Thread.CurrentPrincipal = CType(Session("CSLA-Principal"), MyUser)
> HttpContext.Current.User = CType(Session("CSLA-Principal"), MyUser)
> Else
> If Thread.CurrentPrincipal.Identity.IsAuthenticated = True Then
> Web.Security.FormsAuthentication.SignOut()
> Server.Transfer(Request.ApplicationPath + "/Login.aspx")
> End If
> End If
>
> End Sub
>
> The code after the Else handles the case where the session died but the
user
> still has an authenticated cookie!
> Can happen many ways - IIS recycles the app, etc.
>
> FYI - CSLA is a framework developed by Rocky Lhotka.
>
> --
> Joe Fallon
>
>
>
> "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!
>
>
- Next message: Alek Davis: "Re: mimic NT password creation"
- Previous message: Joe Fallon: "Re: Loosing roles between two pages ?"
- In reply to: Joe Fallon: "Re: Loosing roles between two pages ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]