Roles based Forms Auth - denied pages redirect

Ask a Question related to ASP.NET Security, Design and Development.

  1. #1

    Default Roles based Forms Auth - denied pages redirect

    I would like to know how, if at all possible, a custom redirect page can be setup for when a users role(s) are denied to a page.
    The default behaviour seems to be back to the default/login page but I need to tell the user that they are not allowed the access the requested.
    The site in question in basically just html pages pages that have no code in them, so I cannot use page behind code. I also set permissions to various parts of the site using web.config files and cannot hard-code checking in the pages as this may change.

    This is my second attemt to find out.

    For now I am finding the next 'upstream' web.config in an httpmodule and checking the users roles against those int he web.config.
    This is far from ideal - surely forms auth should handle this so I do not have to write such code and lookup web.config files for each request (I know these could be cached, but still not ideal).

    Thanks in advance ......


    --------------------------
    Shaun Venus

    emailid: sunevnuahs
    domain: hotmail.com
    --------------------------
    Shaun Guest

  2. Similar Questions and Discussions

    1. Role Based Forms Auth with Active Directory
      As anybody succesfully implemented a role/groups based forms authentication against the Active Directory? Thx Patrick *** Sent via...
    2. Forms Authentication based on roles.
      HI, I have the following problem. I am making a portal of DJs. The djs must have a Menu, the administrator another menu. I created 2 directories...
    3. Forms Auth Redirect on Access Denied - Question/Help
      If a web app uses forms authentication and a specific aspx page has a role authorization, where should a browser be directed if a user is not in...
    4. Forms Auth and none aspx pages
      I have forms authentication working for any aspx page (I'm doing this on both a folder level and also individual files). The problem I have is if...
    5. forms auth and roles
      You probably already found your answer, but I'll post an answer for anyone else stumbling across this thread. Sorry, you'll have to perform any...
  3. #2

    Default RE: Roles based Forms Auth - denied pages redirect

    Shaun,

    Are you trying to do something along the lines of a customErrors page for a
    401? If so, that's not possible.

    Jim Cheshire [MSFT]
    MCP+I, MCSE, MCSD, MCDBA
    Microsoft Developer Support
    [email]jamesche@online.microsoft.com[/email]

    This post is provided "AS-IS" with no warranties and confers no rights.

    --------------------
    >Thread-Topic: Roles based Forms Auth - denied pages redirect
    >thread-index: AcRtb54WpJXf4HAUTji/o69pj74rmw==
    >X-WBNR-Posting-Host: 194.205.4.1
    >From: "=?Utf-8?B?U2hhdW4=?=" <Shaun@discussions.microsoft.com>
    >Subject: Roles based Forms Auth - denied pages redirect
    >Date: Mon, 19 Jul 2004 02:06:03 -0700
    >Lines: 18
    >Message-ID: <D01C83F5-C77D-4D7D-B24A-F09EE0983CA1@microsoft.com>
    >MIME-Version: 1.0
    >Content-Type: text/plain;
    > charset="Utf-8"
    >Content-Transfer-Encoding: 7bit
    >X-Newsreader: Microsoft CDO for Windows 2000
    >Content-Class: urn:content-classes:message
    >Importance: normal
    >Priority: normal
    >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
    >Newsgroups: microsoft.public.dotnet.framework.aspnet.security
    >NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 127.0.0.1
    >Path: cpmsftngxa06.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFT NGXA03.phx.gbl
    >Xref: cpmsftngxa06.phx.gbl
    microsoft.public.dotnet.framework.aspnet.security: 10854
    >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.security
    >
    >I would like to know how, if at all possible, a custom redirect page can
    be setup for when a users role(s) are denied to a page.
    >The default behaviour seems to be back to the default/login page but I
    need to tell the user that they are not allowed the access the requested.
    >The site in question in basically just html pages pages that have no code
    in them, so I cannot use page behind code. I also set permissions to
    various parts of the site using web.config files and cannot hard-code
    checking in the pages as this may change.
    >
    >This is my second attemt to find out.
    >
    >For now I am finding the next 'upstream' web.config in an httpmodule and
    checking the users roles against those int he web.config.
    >This is far from ideal - surely forms auth should handle this so I do not
    have to write such code and lookup web.config files for each request (I
    know these could be cached, but still not ideal).
    >
    >Thanks in advance ......
    >
    >
    >--------------------------
    >Shaun Venus
    >
    >emailid: sunevnuahs
    >domain: hotmail.com
    >--------------------------
    >
    Jim Cheshire [MSFT] Guest

  4. #3

    Default RE: Roles based Forms Auth - denied pages redirect

    Jim,

    Thanks for getting back to me. Here's what I have done so far .....

    I have a site with many different content areas that users can subscribe to. Each of these areas (in its own folder) has a web.config to specify the roles allowed access, the user belongs to the roles allowed for the subscribed areas.

    As I could not find a way to do the custom error page I have used the usual code in global.asax to retrieve the roles that were stored in the UserData of the AuthenticationTicket at login.
    Then an HttpModule is used to to look back up the path of the request and find the nearest upstream web.config from which the roles are extracting using an XPath query. From these I can find out if the user is allowed access to the content.
    Obviously this is not ideal as there is lots of IO in finding the web.config file. I am caching them and working on a way of parsing the requests path to reduce the IO further.

    If this is the only way to go then I will continue down this path. Just a shame that the 'deny' from the web.config cannot be used to trigger a redirect to a custom page - from which I could tell the user they are not subscribed to that content area etc.

    Thanks again for your time,

    Shaun


    --------------------------
    Shaun Venus

    emailid: sunevnuahs
    domain: hotmail.com
    --------------------------


    "Jim Cheshire [MSFT]" wrote:
    > Shaun,
    >
    > Are you trying to do something along the lines of a customErrors page for a
    > 401? If so, that's not possible.
    >
    > Jim Cheshire [MSFT]
    > MCP+I, MCSE, MCSD, MCDBA
    > Microsoft Developer Support
    > [email]jamesche@online.microsoft.com[/email]
    >
    > This post is provided "AS-IS" with no warranties and confers no rights.
    >
    > --------------------
    > >Thread-Topic: Roles based Forms Auth - denied pages redirect
    > >thread-index: AcRtb54WpJXf4HAUTji/o69pj74rmw==
    > >X-WBNR-Posting-Host: 194.205.4.1
    > >From: "=?Utf-8?B?U2hhdW4=?=" <Shaun@discussions.microsoft.com>
    > >Subject: Roles based Forms Auth - denied pages redirect
    > >Date: Mon, 19 Jul 2004 02:06:03 -0700
    > >Lines: 18
    > >Message-ID: <D01C83F5-C77D-4D7D-B24A-F09EE0983CA1@microsoft.com>
    > >MIME-Version: 1.0
    > >Content-Type: text/plain;
    > > charset="Utf-8"
    > >Content-Transfer-Encoding: 7bit
    > >X-Newsreader: Microsoft CDO for Windows 2000
    > >Content-Class: urn:content-classes:message
    > >Importance: normal
    > >Priority: normal
    > >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
    > >Newsgroups: microsoft.public.dotnet.framework.aspnet.security
    > >NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 127.0.0.1
    > >Path: cpmsftngxa06.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFT NGXA03.phx.gbl
    > >Xref: cpmsftngxa06.phx.gbl
    > microsoft.public.dotnet.framework.aspnet.security: 10854
    > >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.security
    > >
    > >I would like to know how, if at all possible, a custom redirect page can
    > be setup for when a users role(s) are denied to a page.
    > >The default behaviour seems to be back to the default/login page but I
    > need to tell the user that they are not allowed the access the requested.
    > >The site in question in basically just html pages pages that have no code
    > in them, so I cannot use page behind code. I also set permissions to
    > various parts of the site using web.config files and cannot hard-code
    > checking in the pages as this may change.
    > >
    > >This is my second attemt to find out.
    > >
    > >For now I am finding the next 'upstream' web.config in an httpmodule and
    > checking the users roles against those int he web.config.
    > >This is far from ideal - surely forms auth should handle this so I do not
    > have to write such code and lookup web.config files for each request (I
    > know these could be cached, but still not ideal).
    > >
    > >Thanks in advance ......
    > >
    > >
    > >--------------------------
    > >Shaun Venus
    > >
    > >emailid: sunevnuahs
    > >domain: hotmail.com
    > >--------------------------
    > >
    >
    >
    Shaun Guest

  5. #4

    Default RE: Roles based Forms Auth - denied pages redirect

    Hi Shaun,

    The fact that you are doing this successfully with an HttpModule confirms a
    post that I just made in another thread. I wasn't sure if it was possible,
    but figured that an HttpModule would be the only possible way.

    Jim Cheshire [MSFT]
    MCP+I, MCSE, MCSD, MCDBA
    Microsoft Developer Support
    [email]jamesche@online.microsoft.com[/email]

    This post is provided "AS-IS" with no warranties and confers no rights.

    --------------------
    >Thread-Topic: Roles based Forms Auth - denied pages redirect
    >thread-index: AcRvAfKA88UipZTAQUOeq6ZPy9Ei4A==
    >X-WBNR-Posting-Host: 194.205.4.1
    >From: "=?Utf-8?B?U2hhdW4=?=" <Shaun@discussions.microsoft.com>
    >References: <D01C83F5-C77D-4D7D-B24A-F09EE0983CA1@microsoft.com>
    <b826yGabEHA.3848@cpmsftngxa06.phx.gbl>
    >Subject: RE: Roles based Forms Auth - denied pages redirect
    >Date: Wed, 21 Jul 2004 02:06:02 -0700
    >Lines: 93
    >Message-ID: <6ACC939C-66FB-4C63-8B42-3898F53FA78A@microsoft.com>
    >MIME-Version: 1.0
    >Content-Type: text/plain;
    > charset="Utf-8"
    >Content-Transfer-Encoding: 7bit
    >X-Newsreader: Microsoft CDO for Windows 2000
    >Content-Class: urn:content-classes:message
    >Importance: normal
    >Priority: normal
    >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
    >Newsgroups: microsoft.public.dotnet.framework.aspnet.security
    >NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 127.0.0.1
    >Path: cpmsftngxa06.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFT NGXA03.phx.gbl
    >Xref: cpmsftngxa06.phx.gbl
    microsoft.public.dotnet.framework.aspnet.security: 10889
    >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.security
    >
    >Jim,
    >
    >Thanks for getting back to me. Here's what I have done so far .....
    >
    >I have a site with many different content areas that users can subscribe
    to. Each of these areas (in its own folder) has a web.config to specify
    the roles allowed access, the user belongs to the roles allowed for the
    subscribed areas.
    >
    >As I could not find a way to do the custom error page I have used the
    usual code in global.asax to retrieve the roles that were stored in the
    UserData of the AuthenticationTicket at login.
    >Then an HttpModule is used to to look back up the path of the request and
    find the nearest upstream web.config from which the roles are extracting
    using an XPath query. From these I can find out if the user is allowed
    access to the content.
    >Obviously this is not ideal as there is lots of IO in finding the
    web.config file. I am caching them and working on a way of parsing the
    requests path to reduce the IO further.
    >
    >If this is the only way to go then I will continue down this path. Just a
    shame that the 'deny' from the web.config cannot be used to trigger a
    redirect to a custom page - from which I could tell the user they are not
    subscribed to that content area etc.
    >
    >Thanks again for your time,
    >
    >Shaun
    >
    >
    >--------------------------
    >Shaun Venus
    >
    >emailid: sunevnuahs
    >domain: hotmail.com
    >--------------------------
    >
    >
    >"Jim Cheshire [MSFT]" wrote:
    >
    >> Shaun,
    >>
    >> Are you trying to do something along the lines of a customErrors page
    for a
    >> 401? If so, that's not possible.
    >>
    >> Jim Cheshire [MSFT]
    >> MCP+I, MCSE, MCSD, MCDBA
    >> Microsoft Developer Support
    >> [email]jamesche@online.microsoft.com[/email]
    >>
    >> This post is provided "AS-IS" with no warranties and confers no rights.
    >>
    >> --------------------
    >> >Thread-Topic: Roles based Forms Auth - denied pages redirect
    >> >thread-index: AcRtb54WpJXf4HAUTji/o69pj74rmw==
    >> >X-WBNR-Posting-Host: 194.205.4.1
    >> >From: "=?Utf-8?B?U2hhdW4=?=" <Shaun@discussions.microsoft.com>
    >> >Subject: Roles based Forms Auth - denied pages redirect
    >> >Date: Mon, 19 Jul 2004 02:06:03 -0700
    >> >Lines: 18
    >> >Message-ID: <D01C83F5-C77D-4D7D-B24A-F09EE0983CA1@microsoft.com>
    >> >MIME-Version: 1.0
    >> >Content-Type: text/plain;
    >> > charset="Utf-8"
    >> >Content-Transfer-Encoding: 7bit
    >> >X-Newsreader: Microsoft CDO for Windows 2000
    >> >Content-Class: urn:content-classes:message
    >> >Importance: normal
    >> >Priority: normal
    >> >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
    >> >Newsgroups: microsoft.public.dotnet.framework.aspnet.security
    >> >NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 127.0.0.1
    >> >Path: cpmsftngxa06.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFT NGXA03.phx.gbl
    >> >Xref: cpmsftngxa06.phx.gbl
    >> microsoft.public.dotnet.framework.aspnet.security: 10854
    >> >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.security
    >> >
    >> >I would like to know how, if at all possible, a custom redirect page
    can
    >> be setup for when a users role(s) are denied to a page.
    >> >The default behaviour seems to be back to the default/login page but I
    >> need to tell the user that they are not allowed the access the requested.
    >> >The site in question in basically just html pages pages that have no
    code
    >> in them, so I cannot use page behind code. I also set permissions to
    >> various parts of the site using web.config files and cannot hard-code
    >> checking in the pages as this may change.
    >> >
    >> >This is my second attemt to find out.
    >> >
    >> >For now I am finding the next 'upstream' web.config in an httpmodule
    and
    >> checking the users roles against those int he web.config.
    >> >This is far from ideal - surely forms auth should handle this so I do
    not
    >> have to write such code and lookup web.config files for each request (I
    >> know these could be cached, but still not ideal).
    >> >
    >> >Thanks in advance ......
    >> >
    >> >
    >> >--------------------------
    >> >Shaun Venus
    >> >
    >> >emailid: sunevnuahs
    >> >domain: hotmail.com
    >> >--------------------------
    >> >
    >>
    >>
    >
    Jim Cheshire [MSFT] Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139