PrincipalPermission Problem in ASP.NET

From: Dominick Baier (dotnet_at_leastprivilege.com)
Date: 12/28/04

  • Next message: Paul Delcogliano: "Re: problem with strong name CAS"
    To: microsoft.public.dotnet.security
    Date: Tue, 28 Dec 2004 11:07:07 -0800
    
    

    try Thread.CurrentPrincipal = gp (IIRC works only intra-page - if you want to set the principal in AuthenticateRequest you have to user Context.User)

     

     ---
     Dominick Baier - DevelopMentor
     http://www.leastprivilege.com

       nntp://news.microsoft.com/microsoft.public.dotnet.security/<5D5A70B1-4658-408E-BF52-26085FB2C740@microsoft.com>

     Every time I run the below code, I always get a Security Exception.
     
     Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
     System.EventArgs) Handles MyBase.Load
     Dim gi As New GenericIdentity("JoeUser")
     Dim gp As New GenericPrincipal(gi, New String() {"Admin"})
     HttpContext.Current.User = gp
     ProtectedFunction()
     End Sub
     
     Private Sub ProtectedFunction()
     Dim pp As New PrincipalPermission("JoeUser", "Admin")
     pp.Demand()
     End Sub
     
     Does anyone know what I'm doing wrong or if I need to change a setting in
     web.config.
     
     Thanks
     
     [microsoft.public.dotnet.security]


  • Next message: Paul Delcogliano: "Re: problem with strong name CAS"

    Relevant Pages

    • Re: Modules not Known
      ... Dim pCode$ ... Dim pCodeModule As CodeModule ... Private Sub VBIDEReference() ... Option Compare Database ...
      (comp.databases.ms-access)
    • A VB6 program to generate CONSTants for a user defined gradient
      ... EndProperty ... It may be used for amy moral purpose. ... Dim mGreen1 As Long ... Private Sub ColorDisplay_MouseDown(Button As Integer, Shift As Integer, _ ...
      (comp.lang.basic.visual.misc)
    • Re: access 2003
      ... Dim ctl As Control ... Dim rs As Recordset ... This sets the query definitions for choosing data to create an invoice using ... Event on combo box: Private Sub ChooseCust_AfterUpdate ...
      (microsoft.public.access.conversion)
    • Re: Gradient Generator BMP Tool Improved
      ... EndProperty ... It may be used for amy moral purpose. ... Dim mGreen1 As Long ... Private Sub ColorDisplay_MouseDown(Button As Integer, Shift As Integer, _ ...
      (comp.lang.basic.visual.misc)
    • Calendar Control issue.
      ... Protected WithEvents Calendar1 As System.Web.UI.WebControls.Calendar ... Private Sub Page_Init(ByVal sender As System.Object, ... Dim mo As String ...
      (microsoft.public.dotnet.framework.aspnet)