Directory based authentication

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • See Sharp

    #1

    Directory based authentication

    Hello all,

    I have a set of admin pages which are put in a subfolder called admin inside
    my application folder.
    I want to limit access to these admin pages.
    How can I do this?

    In Linux, I can password protect the directory, so that whenever a page
    within the admin subfolder is accessed for the first time, an authentication
    window pops up asking for username-password. How can I implement the same
    in IIS ?

    This way I can avoid having to programmaticall y implement login feature.

    Can anyone please throw light on this ?

    Thanks
    SeeSharp.


  • Saravana

    #2
    Re: Directory based authentication

    You can go for form authentication or windows authentication, then use
    location tag or create web.config (in that folder) to specify particular
    permission for specific folder using role based authorization. For example
    to set permission to particular folder using location tag,
    <location path="<folderna me>">
    <system.web>
    <autorization >
    <allow users="Admin">
    <deny users="*">
    </autorization>
    </system.web>
    </location>


    --
    Saravana
    Microsoft India Community Star,
    MCAD,SE,SD,DBA.


    "See Sharp" <smitha@inapp.c om> wrote in message
    news:#Ud$xI1TDH A.2188@TK2MSFTN GP11.phx.gbl...[color=blue]
    > Hello all,
    >
    > I have a set of admin pages which are put in a subfolder called admin[/color]
    inside[color=blue]
    > my application folder.
    > I want to limit access to these admin pages.
    > How can I do this?
    >
    > In Linux, I can password protect the directory, so that whenever a page
    > within the admin subfolder is accessed for the first time, an[/color]
    authentication[color=blue]
    > window pops up asking for username-password. How can I implement the same
    > in IIS ?
    >
    > This way I can avoid having to programmaticall y implement login feature.
    >
    > Can anyone please throw light on this ?
    >
    > Thanks
    > SeeSharp.
    >
    >[/color]


    Comment

    • See Sharp

      #3
      Re: Directory based authentication

      Thanks Saravana,

      But I still get problems. Its shows an access denied problem.
      I have a parent directory called app. I configured it as a virtual
      directory.
      I use the IIS configuration tool from control panel, right click app -> all
      tasks -> permission wizard -> select new security settings -> public
      website.
      Now I can access the pages in app folder as http://localhost/app/index1.aspx
      In the web.config of the app folder I have the following data:
      *************** *************** *************** *************
      <?xml version="1.0" encoding="utf-8" ?>
      <configuratio n>
      <system.web>

      <compilation defaultLanguage ="c#" debug="true" />
      <customErrors mode="RemoteOnl y" />
      <authenticati on mode="Windows" />
      <trace enabled="false" requestLimit="1 0" pageOutput="fal se"
      traceMode="Sort ByTime" localOnly="true " />
      <sessionState mode="InProc" stateConnection String="tcpip=1 27.0.0.1:42424"
      sqlConnectionSt ring="data source=127.0.0. 1;user id=sa;password= "
      cookieless="fal se" timeout="20" />
      <globalizatio n requestEncoding ="utf-8" responseEncodin g="utf-8" />
      </system.web>
      <location path="admin">
      <system.web>
      <authorizatio n>
      <allow users="abcd" />
      <deny users="*" />
      </authorization>
      </system.web>
      </location>
      </configuration>
      *************** *************

      I have a subfolder admin in my app folder.
      Actually I made it as another application and copied the application's
      folder as a subfolder called admin in my app folder.
      The admin folder therefore has a web.config too.
      But I deleted it so that there is no ambiguity.
      I have not made the admin subfolder as a virtual directory.

      Now with the above security settings, I should get the the files in the
      admin folder as http://localhost/app/admin/index1.aspx
      It should ask for authentication and when I enter the username password of
      user abcd, it should let me in.
      But This does not happen.
      I get an error.
      I tried making the admin subfolder as a virtual directory.
      I even tried to retain its web.config and place this within it:
      <authorizatio n>
      <allow users="abcd" />
      <deny users="*" />
      </authorization>
      In that case it works, but it allows all users in.
      Not abcd alone.

      Can you please throw light on this ?
      Thanks a lot
      SeeSharp.

      "Saravana" <saravank@sct.c o.in> wrote in message
      news:OcoqLV1TDH A.1664@TK2MSFTN GP11.phx.gbl...[color=blue]
      > You can go for form authentication or windows authentication, then use
      > location tag or create web.config (in that folder) to specify particular
      > permission for specific folder using role based authorization. For example
      > to set permission to particular folder using location tag,
      > <location path="<folderna me>">
      > <system.web>
      > <autorization >
      > <allow users="Admin">
      > <deny users="*">
      > </autorization>
      > </system.web>
      > </location>
      >
      >
      > --
      > Saravana
      > Microsoft India Community Star,
      > MCAD,SE,SD,DBA.
      >
      >
      > "See Sharp" <smitha@inapp.c om> wrote in message
      > news:#Ud$xI1TDH A.2188@TK2MSFTN GP11.phx.gbl...[color=green]
      > > Hello all,
      > >
      > > I have a set of admin pages which are put in a subfolder called admin[/color]
      > inside[color=green]
      > > my application folder.
      > > I want to limit access to these admin pages.
      > > How can I do this?
      > >
      > > In Linux, I can password protect the directory, so that whenever a page
      > > within the admin subfolder is accessed for the first time, an[/color]
      > authentication[color=green]
      > > window pops up asking for username-password. How can I implement the[/color][/color]
      same[color=blue][color=green]
      > > in IIS ?
      > >
      > > This way I can avoid having to programmaticall y implement login feature.
      > >
      > > Can anyone please throw light on this ?
      > >
      > > Thanks
      > > SeeSharp.
      > >
      > >[/color]
      >
      >[/color]


      Comment

      • Saravana

        #4
        Re: Directory based authentication

        Have set integrated authentication or basic authentication in IIS. So first
        set its authentication mode in IIS,then enable impersonation in web.config.
        Then try, it should work.

        --
        Saravana
        Microsoft India Community Star,
        MCAD,SE,SD,DBA.


        "See Sharp" <smitha@inapp.c om> wrote in message
        news:e9fX152TDH A.2228@tk2msftn gp13.phx.gbl...[color=blue]
        > Thanks Saravana,
        >
        > But I still get problems. Its shows an access denied problem.
        > I have a parent directory called app. I configured it as a virtual
        > directory.
        > I use the IIS configuration tool from control panel, right click app ->[/color]
        all[color=blue]
        > tasks -> permission wizard -> select new security settings -> public
        > website.
        > Now I can access the pages in app folder as[/color]
        http://localhost/app/index1.aspx[color=blue]
        > In the web.config of the app folder I have the following data:
        > *************** *************** *************** *************
        > <?xml version="1.0" encoding="utf-8" ?>
        > <configuratio n>
        > <system.web>
        >
        > <compilation defaultLanguage ="c#" debug="true" />
        > <customErrors mode="RemoteOnl y" />
        > <authenticati on mode="Windows" />
        > <trace enabled="false" requestLimit="1 0" pageOutput="fal se"
        > traceMode="Sort ByTime" localOnly="true " />
        > <sessionState mode="InProc"[/color]
        stateConnection String="tcpip=1 27.0.0.1:42424"[color=blue]
        > sqlConnectionSt ring="data source=127.0.0. 1;user id=sa;password= "
        > cookieless="fal se" timeout="20" />
        > <globalizatio n requestEncoding ="utf-8" responseEncodin g="utf-8" />
        > </system.web>
        > <location path="admin">
        > <system.web>
        > <authorizatio n>
        > <allow users="abcd" />
        > <deny users="*" />
        > </authorization>
        > </system.web>
        > </location>
        > </configuration>
        > *************** *************
        >
        > I have a subfolder admin in my app folder.
        > Actually I made it as another application and copied the application's
        > folder as a subfolder called admin in my app folder.
        > The admin folder therefore has a web.config too.
        > But I deleted it so that there is no ambiguity.
        > I have not made the admin subfolder as a virtual directory.
        >
        > Now with the above security settings, I should get the the files in the
        > admin folder as http://localhost/app/admin/index1.aspx
        > It should ask for authentication and when I enter the username password of
        > user abcd, it should let me in.
        > But This does not happen.
        > I get an error.
        > I tried making the admin subfolder as a virtual directory.
        > I even tried to retain its web.config and place this within it:
        > <authorizatio n>
        > <allow users="abcd" />
        > <deny users="*" />
        > </authorization>
        > In that case it works, but it allows all users in.
        > Not abcd alone.
        >
        > Can you please throw light on this ?
        > Thanks a lot
        > SeeSharp.
        >
        > "Saravana" <saravank@sct.c o.in> wrote in message
        > news:OcoqLV1TDH A.1664@TK2MSFTN GP11.phx.gbl...[color=green]
        > > You can go for form authentication or windows authentication, then use
        > > location tag or create web.config (in that folder) to specify[/color][/color]
        particular[color=blue][color=green]
        > > permission for specific folder using role based authorization. For[/color][/color]
        example[color=blue][color=green]
        > > to set permission to particular folder using location tag,
        > > <location path="<folderna me>">
        > > <system.web>
        > > <autorization >
        > > <allow users="Admin">
        > > <deny users="*">
        > > </autorization>
        > > </system.web>
        > > </location>
        > >
        > >
        > > --
        > > Saravana
        > > Microsoft India Community Star,
        > > MCAD,SE,SD,DBA.
        > >
        > >
        > > "See Sharp" <smitha@inapp.c om> wrote in message
        > > news:#Ud$xI1TDH A.2188@TK2MSFTN GP11.phx.gbl...[color=darkred]
        > > > Hello all,
        > > >
        > > > I have a set of admin pages which are put in a subfolder called admin[/color]
        > > inside[color=darkred]
        > > > my application folder.
        > > > I want to limit access to these admin pages.
        > > > How can I do this?
        > > >
        > > > In Linux, I can password protect the directory, so that whenever a[/color][/color][/color]
        page[color=blue][color=green][color=darkred]
        > > > within the admin subfolder is accessed for the first time, an[/color]
        > > authentication[color=darkred]
        > > > window pops up asking for username-password. How can I implement the[/color][/color]
        > same[color=green][color=darkred]
        > > > in IIS ?
        > > >
        > > > This way I can avoid having to programmaticall y implement login[/color][/color][/color]
        feature.[color=blue][color=green][color=darkred]
        > > >
        > > > Can anyone please throw light on this ?
        > > >
        > > > Thanks
        > > > SeeSharp.
        > > >
        > > >[/color]
        > >
        > >[/color]
        >
        >[/color]


        Comment

        • Steve C. Orr, MCSD

          #5
          Re: Directory based authentication

          Please fix the date on your computer.


          Comment

          • See Sharp

            #6
            Re: Directory based authentication

            Yup. I did that. I am sorry. I used the calendar to choose a relieving date
            [ I am planning to resign from my job next month].
            And I accidently clicked OK :">

            SeeSharp

            "Steve C. Orr, MCSD" <Steve@Orr.ne t> wrote in message
            news:ugC$HmLUDH A.1740@TK2MSFTN GP12.phx.gbl...[color=blue]
            > Please fix the date on your computer.
            >
            >[/color]


            Comment

            • Paul Hobbs

              #7
              Re: Directory based authentication

              Hi SeeSharp,

              I am an application that does EXACTLY the same as you - an admin folder with
              admin pages that is restricted to a select few. Have you managed to get
              your application to work as you wanted? If so, I would be very interested
              to know how you did it. Authentication is something I have not yet
              mastered.

              Cheers,

              Paul Hobbs



              "See Sharp" <smitha@inapp.c om> wrote in message
              news:#Ud$xI1TDH A.2188@TK2MSFTN GP11.phx.gbl...[color=blue]
              > Hello all,
              >
              > I have a set of admin pages which are put in a subfolder called admin[/color]
              inside[color=blue]
              > my application folder.
              > I want to limit access to these admin pages.
              > How can I do this?
              >
              > In Linux, I can password protect the directory, so that whenever a page
              > within the admin subfolder is accessed for the first time, an[/color]
              authentication[color=blue]
              > window pops up asking for username-password. How can I implement the same
              > in IIS ?
              >
              > This way I can avoid having to programmaticall y implement login feature.
              >
              > Can anyone please throw light on this ?
              >
              > Thanks
              > SeeSharp.
              >
              >[/color]


              Comment

              • See Sharp

                #8
                Re: Directory based authentication

                Hi Paul

                I disabled anonymous logon to my admin directory. In the access control
                list, I add each member whom I want to deny [including anonymous] and deny
                all rights to them. The everyone user has all "required" permissions.

                SeeSharp

                "Paul Hobbs" <paul@mobius.ne t.au> wrote in message
                news:#RHABFtUDH A.2328@TK2MSFTN GP12.phx.gbl...[color=blue]
                > Hi SeeSharp,
                >
                > I am an application that does EXACTLY the same as you - an admin folder[/color]
                with[color=blue]
                > admin pages that is restricted to a select few. Have you managed to get
                > your application to work as you wanted? If so, I would be very interested
                > to know how you did it. Authentication is something I have not yet
                > mastered.
                >
                > Cheers,
                >
                > Paul Hobbs
                >
                >
                >
                > "See Sharp" <smitha@inapp.c om> wrote in message
                > news:#Ud$xI1TDH A.2188@TK2MSFTN GP11.phx.gbl...[color=green]
                > > Hello all,
                > >
                > > I have a set of admin pages which are put in a subfolder called admin[/color]
                > inside[color=green]
                > > my application folder.
                > > I want to limit access to these admin pages.
                > > How can I do this?
                > >
                > > In Linux, I can password protect the directory, so that whenever a page
                > > within the admin subfolder is accessed for the first time, an[/color]
                > authentication[color=green]
                > > window pops up asking for username-password. How can I implement the[/color][/color]
                same[color=blue][color=green]
                > > in IIS ?
                > >
                > > This way I can avoid having to programmaticall y implement login feature.
                > >
                > > Can anyone please throw light on this ?
                > >
                > > Thanks
                > > SeeSharp.
                > >
                > >[/color]
                >
                >[/color]


                Comment

                • Scott Scott

                  #9
                  Re: Directory based authentication

                  AuthentiX passwords protects directories and files.

                  Make your own movie clips and short films. Pick your characters and a place, say what happens, choose a look, and Flicks makes the clip, widescreen with sound.





                  *** Sent via Developersdex http://www.developersdex.com ***
                  Don't just participate in USENET...get rewarded for it!

                  Comment

                  • VB Programmer

                    #10
                    Re: Directory based authentication

                    What sets the current "user"? For example how do I know if the person is
                    "Admin"? Where is that set?

                    "Saravana" <saravank@sct.c o.in> wrote in message
                    news:OcoqLV1TDH A.1664@TK2MSFTN GP11.phx.gbl...[color=blue]
                    > You can go for form authentication or windows authentication, then use
                    > location tag or create web.config (in that folder) to specify particular
                    > permission for specific folder using role based authorization. For example
                    > to set permission to particular folder using location tag,
                    > <location path="<folderna me>">
                    > <system.web>
                    > <autorization >
                    > <allow users="Admin">
                    > <deny users="*">
                    > </autorization>
                    > </system.web>
                    > </location>
                    >
                    >
                    > --
                    > Saravana
                    > Microsoft India Community Star,
                    > MCAD,SE,SD,DBA.
                    >
                    >
                    > "See Sharp" <smitha@inapp.c om> wrote in message
                    > news:#Ud$xI1TDH A.2188@TK2MSFTN GP11.phx.gbl...[color=green]
                    > > Hello all,
                    > >
                    > > I have a set of admin pages which are put in a subfolder called admin[/color]
                    > inside[color=green]
                    > > my application folder.
                    > > I want to limit access to these admin pages.
                    > > How can I do this?
                    > >
                    > > In Linux, I can password protect the directory, so that whenever a page
                    > > within the admin subfolder is accessed for the first time, an[/color]
                    > authentication[color=green]
                    > > window pops up asking for username-password. How can I implement the[/color][/color]
                    same[color=blue][color=green]
                    > > in IIS ?
                    > >
                    > > This way I can avoid having to programmaticall y implement login feature.
                    > >
                    > > Can anyone please throw light on this ?
                    > >
                    > > Thanks
                    > > SeeSharp.
                    > >
                    > >[/color]
                    >
                    >[/color]


                    Comment

                    • John Knoop

                      #11
                      Re: Directory based authentication

                      You assign roles to each user. This has to be done on each request. You set
                      Context.User to a new GenericPrincipa l, and assign roles at the same time.
                      Then you can check using User.IsInRole.

                      The downside is, obviousely, that you must create a new user on each
                      request. A better way would be to save all this information in the Session
                      object. But unfortunately that data isn't accessible from within any of the
                      Application_Req uest* events in global.asax. So you basically need to include
                      a file for checking in every page.

                      /john

                      "VB Programmer" <growNO-SPAM@go-intech.com> wrote in message
                      news:uyn1$M5WDH A.2388@TK2MSFTN GP11.phx.gbl...[color=blue]
                      > What sets the current "user"? For example how do I know if the person is
                      > "Admin"? Where is that set?
                      >
                      > "Saravana" <saravank@sct.c o.in> wrote in message
                      > news:OcoqLV1TDH A.1664@TK2MSFTN GP11.phx.gbl...[color=green]
                      > > You can go for form authentication or windows authentication, then use
                      > > location tag or create web.config (in that folder) to specify[/color][/color]
                      particular[color=blue][color=green]
                      > > permission for specific folder using role based authorization. For[/color][/color]
                      example[color=blue][color=green]
                      > > to set permission to particular folder using location tag,
                      > > <location path="<folderna me>">
                      > > <system.web>
                      > > <autorization >
                      > > <allow users="Admin">
                      > > <deny users="*">
                      > > </autorization>
                      > > </system.web>
                      > > </location>
                      > >
                      > >
                      > > --
                      > > Saravana
                      > > Microsoft India Community Star,
                      > > MCAD,SE,SD,DBA.
                      > >
                      > >
                      > > "See Sharp" <smitha@inapp.c om> wrote in message
                      > > news:#Ud$xI1TDH A.2188@TK2MSFTN GP11.phx.gbl...[color=darkred]
                      > > > Hello all,
                      > > >
                      > > > I have a set of admin pages which are put in a subfolder called admin[/color]
                      > > inside[color=darkred]
                      > > > my application folder.
                      > > > I want to limit access to these admin pages.
                      > > > How can I do this?
                      > > >
                      > > > In Linux, I can password protect the directory, so that whenever a[/color][/color][/color]
                      page[color=blue][color=green][color=darkred]
                      > > > within the admin subfolder is accessed for the first time, an[/color]
                      > > authentication[color=darkred]
                      > > > window pops up asking for username-password. How can I implement the[/color][/color]
                      > same[color=green][color=darkred]
                      > > > in IIS ?
                      > > >
                      > > > This way I can avoid having to programmaticall y implement login[/color][/color][/color]
                      feature.[color=blue][color=green][color=darkred]
                      > > >
                      > > > Can anyone please throw light on this ?
                      > > >
                      > > > Thanks
                      > > > SeeSharp.
                      > > >
                      > > >[/color]
                      > >
                      > >[/color]
                      >
                      >[/color]


                      Comment

                      Working...