RE: FormsAuthentication Roles Problem

From: [MSFT] (lukezhan_at_online.microsoft.com)
Date: 11/26/04


Date: Fri, 26 Nov 2004 04:10:17 GMT

Since you use Form authentication, can you explain more about how you
implement IPrincipal.IsInRole and Application_AuthenticateRequest?
Normally, we need grant roles in Application_AuthenticateRequest like:

Sub Application_AuthenticateRequest(ByVal sender As Object, ByVal e As
EventArgs)
        if (not(HttpContext.Current.User is Nothing)) then
            if HttpContext.Current.User.Identity.AuthenticationType = "Forms" then
                Dim id as System.Web.Security.FormsIdentity
                id = HttpContext.Current.User.Identity
        
                Dim MyRoles(2) As String
                MyRoles(0) = "Manager"
                MyRoles(1) = "Admin"
                HttpContext.Current.User = new
System.Security.Principal.GenericPrincipal(id,MyRoles)
            End if
        End if
        End sub

Luke



Relevant Pages

  • Re: Simple Question regarding relative path references
    ... Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs) ... as Form authentication is already provided for you. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Wrapping FileSystemWatcher to prevent crossthread ops
    ... Public Shadows Event Changed(ByVal sender As Object, ... Private Delegate Sub DelegatorFSE(ByVal sender As Object, ... Private Sub watch_Changed(ByVal sender As Object, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Global.asax not firing
    ... Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs) ... ' Fires when the application is started ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Global.asax not firing
    ... Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs) ... ' Fires when the application is started ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: possible to create one control array with different controls?
    ... That's a sub of the base FORM class which is why I surmise you put ... Private Overloads Sub OnEnter(ByVal sender As System.Object, ... If TypeOf sender Is TextBox Then ... I have 3 textboxes and 1 combobox on a form. ...
    (microsoft.public.dotnet.languages.vb)