allow groups with Forms Authentication

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

  1. #1

    Default allow groups with Forms Authentication

    I am testing forms authentication against Active
    Directory. I want to limit access to the site based on
    Windows groups. The app is working but it allows anyone
    with a domain account access which is undesirable. I
    followed the Microsoft KB article 326340. Here is the
    entry in my web.config:

    <authorization>
    <allow roles="domainname\group" />
    <deny users="?" />
    </authorization>

    Does anyone know how to accomplish this?

    Thanks
    rmac
    rmac Guest

  2. Similar Questions and Discussions

    1. Accessing htm files without authentication (forms authentication)
      I have application with forms authentication. All works fine. When user opens .aspx file gets login form, login and then get the .aspx page. But...
    2. Forms Based Authentication - Groups
      What example are you talking about? It doesn't appear in the newsgroup where you posted. Joe K. "cathie corcoran via .NET 247"...
    3. ASP.Net Forms authentication with basic authentication popup
      Relatively new to ASP.Net but have a strange problem. My site uses forms authentication for a large administration section however after the user...
    4. Forms authentication then redirection to a secure web with NT authentication?
      Hi, I want to allow access to particular secured intranet web sites. These intranet are stored in sharepoint (2003 version) Actually I've...
    5. Authentication ticket, cookieless, forms authentication?
      Hi. I want to use Forms Authentication, cookieless. The issue is setting the Authentication Ticket without using cookies (!) That is, the...
  3. #2

    Default Re: allow groups with Forms Authentication

    You would want to change the <deny users="?"> to <deny users="*">
    Role checks are top down. If the first check passes they're in. In your
    example any authenticated user would also pass the next test <deny
    users="?"> just deny's unauthenticated users.
    By changing to <deny users="*">, if they don't pass the first test they
    won't get in because the * says deny everyone. They will get a network
    login dialog box but no matter what they enter into the login dialog it will
    fail with an access denied....well, this is unless they enter a login that
    is a member of the group you allow in.

    Also - If you wanted to provide a "polite" access denied result, i.e. send
    them somewhere else such as your own error page you could alternately just
    set <deny users="?"> (removing your current allow test) and then in your
    global.asax code do a test if the user is in a permitted role else send them
    somewhere else.

    Example
    Sub Application_AuthenticateRequest(ByVal sender As Object, ByVal e As
    EventArgs)
    If Request.IsAuthenticated AndAlso
    Context.User.IsInRole("domainname\group") = false then
    If Request.Url.ToString.IndexOf("mynoaccesspage") > 0 Then
    Response.Redirect("mynoaccesspage")
    End If
    End If
    End Sub


    Hope this helps some

    Brad


    "rmac" <anonymous@discussions.microsoft.com> wrote in message
    news:046e01c3c419$9b1afed0$a101280a@phx.gbl...
    > I am testing forms authentication against Active
    > Directory. I want to limit access to the site based on
    > Windows groups. The app is working but it allows anyone
    > with a domain account access which is undesirable. I
    > followed the Microsoft KB article 326340. Here is the
    > entry in my web.config:
    >
    > <authorization>
    > <allow roles="domainname\group" />
    > <deny users="?" />
    > </authorization>
    >
    > Does anyone know how to accomplish this?
    >
    > Thanks
    > rmac

    Brad Guest

  4. #3

    Default Re: allow groups with Forms Authentication

    Thank you for your response. It was very helpful.

    >-----Original Message-----
    >You would want to change the <deny users="?"> to <deny
    users="*">
    >Role checks are top down. If the first check passes
    they're in. In your
    >example any authenticated user would also pass the next
    test <deny
    >users="?"> just deny's unauthenticated users.
    >By changing to <deny users="*">, if they don't pass the
    first test they
    >won't get in because the * says deny everyone. They will
    get a network
    >login dialog box but no matter what they enter into the
    login dialog it will
    >fail with an access denied....well, this is unless they
    enter a login that
    >is a member of the group you allow in.
    >
    >Also - If you wanted to provide a "polite" access denied
    result, i.e. send
    >them somewhere else such as your own error page you could
    alternately just
    >set <deny users="?"> (removing your current allow test)
    and then in your
    >global.asax code do a test if the user is in a permitted
    role else send them
    >somewhere else.
    >
    >Example
    > Sub Application_AuthenticateRequest(ByVal sender As
    Object, ByVal e As
    >EventArgs)
    > If Request.IsAuthenticated AndAlso
    >Context.User.IsInRole("domainname\group") = false then
    > If Request.Url.ToString.IndexOf
    ("mynoaccesspage") > 0 Then
    > Response.Redirect("mynoaccesspage")
    > End If
    > End If
    > End Sub
    >
    >
    >Hope this helps some
    >
    >Brad
    >
    >
    >"rmac" <anonymous@discussions.microsoft.com> wrote in
    message
    >news:046e01c3c419$9b1afed0$a101280a@phx.gbl...
    >> I am testing forms authentication against Active
    >> Directory. I want to limit access to the site based on
    >> Windows groups. The app is working but it allows anyone
    >> with a domain account access which is undesirable. I
    >> followed the Microsoft KB article 326340. Here is the
    >> entry in my web.config:
    >>
    >> <authorization>
    >> <allow roles="domainname\group" />
    >> <deny users="?" />
    >> </authorization>
    >>
    >> Does anyone know how to accomplish this?
    >>
    >> Thanks
    >> rmac
    >
    >
    >.
    >
    rmac Guest

  5. #4

    Default Re: allow groups with Forms Authentication

    Brad,

    I have tried the method you mentioned. I am not able to
    check the roles. If I put in code on the requested page to
    check for the group I come up empty. Ex:

    If context.User.IsInRole("domainname\group") = True Then
    lblName.Text = "Hello " +
    Context.User.Identity.Name & "."
    End IF

    The label text is empty.

    If I do this and deny unathenticated users in the
    web.config:

    If Request.IsAuthenticated = True Then
    lblName.Text = "Hello " + Context.User.Identity.Name
    & "."
    End If

    the label shows the user name.

    In my web.config file if I do this:

    <allow users="domain\group"
    <deny users="*" />

    I cannot login no matter what account I use.

    Am I missing something?

    Thanks
    rmac
    >-----Original Message-----
    >You would want to change the <deny users="?"> to <deny
    users="*">
    >Role checks are top down. If the first check passes
    they're in. In your
    >example any authenticated user would also pass the next
    test <deny
    >users="?"> just deny's unauthenticated users.
    >By changing to <deny users="*">, if they don't pass the
    first test they
    >won't get in because the * says deny everyone. They will
    get a network
    >login dialog box but no matter what they enter into the
    login dialog it will
    >fail with an access denied....well, this is unless they
    enter a login that
    >is a member of the group you allow in.
    >
    >Also - If you wanted to provide a "polite" access denied
    result, i.e. send
    >them somewhere else such as your own error page you could
    alternately just
    >set <deny users="?"> (removing your current allow test)
    and then in your
    >global.asax code do a test if the user is in a permitted
    role else send them
    >somewhere else.
    >
    >Example
    > Sub Application_AuthenticateRequest(ByVal sender As
    Object, ByVal e As
    >EventArgs)
    > If Request.IsAuthenticated AndAlso
    >Context.User.IsInRole("domainname\group") = false then
    > If Request.Url.ToString.IndexOf
    ("mynoaccesspage") > 0 Then
    > Response.Redirect("mynoaccesspage")
    > End If
    > End If
    > End Sub
    >
    >
    >Hope this helps some
    >
    >Brad
    >
    >
    >"rmac" <anonymous@discussions.microsoft.com> wrote in
    message
    >news:046e01c3c419$9b1afed0$a101280a@phx.gbl...
    >> I am testing forms authentication against Active
    >> Directory. I want to limit access to the site based on
    >> Windows groups. The app is working but it allows anyone
    >> with a domain account access which is undesirable. I
    >> followed the Microsoft KB article 326340. Here is the
    >> entry in my web.config:
    >>
    >> <authorization>
    >> <allow roles="domainname\group" />
    >> <deny users="?" />
    >> </authorization>
    >>
    >> Does anyone know how to accomplish this?
    >>
    >> Thanks
    >> rmac
    >
    >
    >.
    >
    rmac Guest

  6. #5

    Default Re: allow groups with Forms Authentication

    Your example of
    <allow users="domain\group">
    <deny users="*" />
    Should be
    <allow roles="domain\group">
    <deny users="*" />


    FYI - You can also look at "Configure ASP.NET Settings" of the following
    MSDN topic
    [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/SecNetch08.asp[/url]
    It's from the book "Building Secure Microsoft ASP.NET Applications", which I
    highly reccomend.

    Brad



    "rmac" <anonymous@discussions.microsoft.com> wrote in message
    news:0b9e01c3c638$8d1fb700$a101280a@phx.gbl...
    > Brad,
    >
    > I have tried the method you mentioned. I am not able to
    > check the roles. If I put in code on the requested page to
    > check for the group I come up empty. Ex:
    >
    > If context.User.IsInRole("domainname\group") = True Then
    > lblName.Text = "Hello " +
    > Context.User.Identity.Name & "."
    > End IF
    >
    > The label text is empty.
    >
    > If I do this and deny unathenticated users in the
    > web.config:
    >
    > If Request.IsAuthenticated = True Then
    > lblName.Text = "Hello " + Context.User.Identity.Name
    > & "."
    > End If
    >
    > the label shows the user name.
    >
    > In my web.config file if I do this:
    >
    > <allow users="domain\group"
    > <deny users="*" />
    >
    > I cannot login no matter what account I use.
    >
    > Am I missing something?
    >
    > Thanks
    > rmac
    >
    > >-----Original Message-----
    > >You would want to change the <deny users="?"> to <deny
    > users="*">
    > >Role checks are top down. If the first check passes
    > they're in. In your
    > >example any authenticated user would also pass the next
    > test <deny
    > >users="?"> just deny's unauthenticated users.
    > >By changing to <deny users="*">, if they don't pass the
    > first test they
    > >won't get in because the * says deny everyone. They will
    > get a network
    > >login dialog box but no matter what they enter into the
    > login dialog it will
    > >fail with an access denied....well, this is unless they
    > enter a login that
    > >is a member of the group you allow in.
    > >
    > >Also - If you wanted to provide a "polite" access denied
    > result, i.e. send
    > >them somewhere else such as your own error page you could
    > alternately just
    > >set <deny users="?"> (removing your current allow test)
    > and then in your
    > >global.asax code do a test if the user is in a permitted
    > role else send them
    > >somewhere else.
    > >
    > >Example
    > > Sub Application_AuthenticateRequest(ByVal sender As
    > Object, ByVal e As
    > >EventArgs)
    > > If Request.IsAuthenticated AndAlso
    > >Context.User.IsInRole("domainname\group") = false then
    > > If Request.Url.ToString.IndexOf
    > ("mynoaccesspage") > 0 Then
    > > Response.Redirect("mynoaccesspage")
    > > End If
    > > End If
    > > End Sub
    > >
    > >
    > >Hope this helps some
    > >
    > >Brad
    > >
    > >
    > >"rmac" <anonymous@discussions.microsoft.com> wrote in
    > message
    > >news:046e01c3c419$9b1afed0$a101280a@phx.gbl...
    > >> I am testing forms authentication against Active
    > >> Directory. I want to limit access to the site based on
    > >> Windows groups. The app is working but it allows anyone
    > >> with a domain account access which is undesirable. I
    > >> followed the Microsoft KB article 326340. Here is the
    > >> entry in my web.config:
    > >>
    > >> <authorization>
    > >> <allow roles="domainname\group" />
    > >> <deny users="?" />
    > >> </authorization>
    > >>
    > >> Does anyone know how to accomplish this?
    > >>
    > >> Thanks
    > >> rmac
    > >
    > >
    > >.
    > >

    Brad 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