Forms Auth Redirect on Access Denied - Question/Help

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

  1. #1

    Default 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 the
    role for that location?

    Background to my question:
    I'm using forms authentication on a web app, setting the ticket in
    code...also setting the role in the ticket. I then later set the
    context.user to a new generic principal which includes the roles from the
    ticket. This works fine and the user (me in this case) is authenticated.

    I placed role authorization on a specific location (aspx file) and when I'm
    in that role I correctly see the page. If I remove myself (or another
    tester) from the role for that page access is correctly denied, however the
    browser is displays the message below instead of something like a 401 error.
    It seems I can't even use a custom 401 in the config to trap this.

    Is the message below what I should be getting? If so, can I trap to
    redirect? If not, what might be going on to cause this message?

    Thanks

    Brad

    Role setting example
    ================================================
    <location path="securepage.aspx">
    <system.web>
    <authorization>
    <allow roles="Manager"/>
    <deny users="*" />
    </authorization>
    </system.web>
    </location>


    ================================================
    Browser display when access is denied.
    ================================================
    The page cannot be displayed
    The page you are looking for is currently unavailable. The Web site might be
    experiencing technical difficulties, or you may need to adjust your browser
    settings.



    Please try the following:
    Click the Refresh button, or try again later.

    If you typed the page address in the Address bar, make sure that it is
    spelled correctly.

    To check your connection settings, click the Tools menu, and then click
    Internet Options. On the Connections tab, click Settings. The settings
    should match those provided by your local area network (LAN) administrator
    or Internet service provider (ISP).
    If your Network Administrator has enabled it, Microsoft Windows can examine
    your network and automatically discover network connection settings.
    If you would like Windows to try and discover them,
    click Detect Network Settings
    Some sites require 128-bit connection security. Click the Help menu and then
    click About Internet Explorer to determine what strength security you have
    installed.
    If you are trying to reach a secure site, make sure your Security settings
    can support it. Click the Tools menu, and then click Internet Options. On
    the Advanced tab, scroll to the Security section and check settings for SSL
    2.0, SSL 3.0, TLS 1.0, PCT 1.0.
    Click the Back button to try another link.


    Cannot find server or DNS Error
    Internet Explorer
    =======================================


    Brad Guest

  2. Similar Questions and Discussions

    1. Stupid Forms Auth Question
      I'm new... please be gentle... I've built a login form for a very simple website using C#/ASP.NET. Security isn't that big of a deal, so I'm...
    2. Forms Auth cookie question
      This may be a dumb question, but does anyone know where the Forms Authentication cookie is kept on an XP box? It definitely isn't kept with all of...
    3. Forms Auth and FormsAuthentication.SignOut()Question
      I'm using Form Auth. I 'm using the FormsAuthentication.SignOut() to sign out But when the user logins in and later logs out using...
    4. Forms Auth with ADirectory Question
      I tried out the code at:- http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetse c/html/SecNetHT02.asp But i'm getting the...
    5. 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...
  3. #2

    Default RE: Forms Auth Redirect on Access Denied - Question/Help

    Hi Brad,

    You may set the custom error page in <customErrors> Element of web.config:

    [url]http://www.microsoft.com/technet/treeview/default.asp?url=/technet/prodtechn[/url]
    ol/windowsserver2003/proddocs/standard/aaconcustomerrorselement.asp

    Hope this help,

    Luke
    Microsoft Online Support

    Get Secure! [url]www.microsoft.com/security[/url]
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)

    MSFT Guest

  4. #3

    Default Re: Forms Auth Redirect on Access Denied - Question/Help

    Luke - As I mentioned, that's my problem and thus my question: I'm
    setting custom errors and it's not hitting any.
    Again my question. If access is denied to a specific location (aspx) what
    result should IIS or .Net product (what should the browser get) And if
    customer error s is NOT trapping it how can I trap it...or is something
    wrong going on. (please review my original post again).


    Brad

    "MSFT" <lukezhan@online.microsoft.com> wrote in message
    news:U4fhplAsDHA.3428@cpmsftngxa07.phx.gbl...
    > Hi Brad,
    >
    > You may set the custom error page in <customErrors> Element of web.config:
    >
    >
    [url]http://www.microsoft.com/technet/treeview/default.asp?url=/technet/prodtechn[/url]
    > ol/windowsserver2003/proddocs/standard/aaconcustomerrorselement.asp
    >
    > Hope this help,
    >
    > Luke
    > Microsoft Online Support
    >
    > Get Secure! [url]www.microsoft.com/security[/url]
    > (This posting is provided "AS IS", with no warranties, and confers no
    > rights.)
    >

    Brad Guest

  5. #4

    Default Re: Forms Auth Redirect on Access Denied - Question/Help

    Hi Brad,

    Can you catch the error in the method Application_Error of global.asax? For
    more information about asp.net error handling, you may refer to:

    [url]http://www.15seconds.com/issue/030102.htm[/url]

    Hope this help,

    Luke
    Microsoft Online Support

    Get Secure! [url]www.microsoft.com/security[/url]
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)

    MSFT Guest

  6. #5

    Default Re: Forms Auth Redirect on Access Denied - Question/Help

    No. I have applicaiton error handling and it's not picking it up. Let me
    ask this another way: Using the following example what should a client
    expect to see and/or how does asp.net react if the client attempts to access
    securepage.aspx and they NOT a memeber of the Manager Role.

    <location path="securepage.aspx">
    <system.web>
    <authorization>
    <allow roles="Manager"/>
    <deny users="*" />
    </authorization>
    </system.web>
    </location>




    "MSFT" <lukezhan@online.microsoft.com> wrote in message
    news:LdGap5nsDHA.3644@cpmsftngxa07.phx.gbl...
    > Hi Brad,
    >
    > Can you catch the error in the method Application_Error of global.asax?
    For
    > more information about asp.net error handling, you may refer to:
    >
    > [url]http://www.15seconds.com/issue/030102.htm[/url]
    >
    > Hope this help,
    >
    > Luke
    > Microsoft Online Support
    >
    > Get Secure! [url]www.microsoft.com/security[/url]
    > (This posting is provided "AS IS", with no warranties, and confers no
    > rights.)
    >

    Brad Guest

  7. #6

    Default Re: Forms Auth Redirect on Access Denied - Question/Help

    Never mind, Luke. Seems that ASP.NET will just keep redirecting the user
    to the login page is they are not in the role....an error can't be trapped
    and user really can't be redirected if the roles are using in the web
    config. To bad...you'd think their would be a means to trap that access was
    denied. It just means I do forms auth in code on the page as I have been
    doing to date.


    "Brad" <nospam@co.lane.or.us> wrote in message
    news:Otq$ERqsDHA.2416@TK2MSFTNGP10.phx.gbl...
    > No. I have applicaiton error handling and it's not picking it up. Let me
    > ask this another way: Using the following example what should a client
    > expect to see and/or how does asp.net react if the client attempts to
    access
    > securepage.aspx and they NOT a memeber of the Manager Role.
    >
    > <location path="securepage.aspx">
    > <system.web>
    > <authorization>
    > <allow roles="Manager"/>
    > <deny users="*" />
    > </authorization>
    > </system.web>
    > </location>
    >
    >
    >
    >
    > "MSFT" <lukezhan@online.microsoft.com> wrote in message
    > news:LdGap5nsDHA.3644@cpmsftngxa07.phx.gbl...
    > > Hi Brad,
    > >
    > > Can you catch the error in the method Application_Error of global.asax?
    > For
    > > more information about asp.net error handling, you may refer to:
    > >
    > > [url]http://www.15seconds.com/issue/030102.htm[/url]
    > >
    > > Hope this help,
    > >
    > > Luke
    > > Microsoft Online Support
    > >
    > > Get Secure! [url]www.microsoft.com/security[/url]
    > > (This posting is provided "AS IS", with no warranties, and confers no
    > > rights.)
    > >
    >
    >

    Brad Guest

  8. #7

    Default Re: Forms Auth Redirect on Access Denied - Question/Help

    Hi Brad,

    I think we may try other approach to achieve this. For example, in the form
    load of the security.aspx, check the user with IsInRole method, perform
    further rocess or redirect it to a special form.

    Luke
    Microsoft Online Support

    Get Secure! [url]www.microsoft.com/security[/url]
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)

    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