Re: Loosing roles between two pages ?

From: Joe Kaplan \(MVP - ADSI\) (joseph.e.kaplan_at_removethis.accenture.com)
Date: 03/29/04

  • Next message: Joe Fallon: "Re: Loosing roles between two pages ?"
    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!


  • Next message: Joe Fallon: "Re: Loosing roles between two pages ?"

    Relevant Pages

    • Re: On Error GoTo is not working
      ... Dim strRequestID As String ... Dim strMessage As String ... MsgBox "Required fields for this form are: Request ID, Date, Name, ...
      (microsoft.public.access.formscoding)
    • Re: On Error GoTo is not working
      ... Dim strRequestID As String ... Dim strMessage As String ... MsgBox "Required fields for this form are: Request ID, Date, Name, ...
      (microsoft.public.access.formscoding)
    • Re: how can I change this get code to post code
      ... In a get I didn't write anything but in a post I have to so that is why the streamwriter is required. ... Now when we run rep=req.getresponsethe postdata that was put in the web request req is now being sent to the jsp page and it's reply is being stored in rep. ... dim strcontent as string ... Dim strContent As String ...
      (microsoft.public.dotnet.languages.vb)
    • Active Directory Error - The server is unwilling to process the request
      ... The server is unwilling to process the request ... The code below determines the location of the schema, ... Dim oConn 'As ADODB.Connection ...
      (microsoft.public.dotnet.general)
    • Re: HttpHandler
      ... retrieve the content from the remote server. ... ' The request is forwarded back to the ... Dim RawBytes() As Byte = readRequest ... ' Get the stream associated with the response. ...
      (microsoft.public.dotnet.framework.aspnet)