asp.net, basic authentication, file access

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

  1. #1

    Default asp.net, basic authentication, file access

    I have a asp.net application that is configured to
    use "basic authentication". The application needs to have
    access to delete a file in let's say directory
    d:\inetpub\wwwroot\myApp\reports. Do I need to grant
    access to the ASPNET account or to the accounts of the
    users who will be accessing the site ?

    I put the following line of code in
    Thread.CurrentPrincipal.Identity.Name.ToString() and it
    returns the id of the person logged in.



    thanks for your help
    jzink Guest

  2. Similar Questions and Discussions

    1. sso/basic authentication
      We are interested in using basic authentication (with https) to implement Single Sign On (SSO) with Internet Explorer clients. Does anyone have...
    2. Custom Basic Authentication
      -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hello all, I want to be able to use Basic Authentication without the need of specific accounts in...
    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. Basic Access Authentication
      I found this article http://www.dotnet247.com/247reference/msgs/22/113795.aspx, but unfortunatly it no longer exists here, so I'm re-opening it. ...
    5. Basic authentication with LWP::Parallel
      Hi, I am having problems doing basic authentication with LWP::Parallel::UserAgent. It works fine when I use LWP::Useragent with the following...
  3. #2

    Default Re: asp.net, basic authentication, file access

    If you have turned the impersonation on the .net code will run under the
    identity of he users who will be accessing the site, else the .net code will
    run under the ASPNET account (this is a default) identity.

    HtH,
    Andrea

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


    "jzink" <zinks.home@verizon.net> wrote in message
    news:065401c3d141$c293ee60$a501280a@phx.gbl...
    > I have a asp.net application that is configured to
    > use "basic authentication". The application needs to have
    > access to delete a file in let's say directory
    > d:\inetpub\wwwroot\myApp\reports. Do I need to grant
    > access to the ASPNET account or to the accounts of the
    > users who will be accessing the site ?
    >
    > I put the following line of code in
    > Thread.CurrentPrincipal.Identity.Name.ToString() and it
    > returns the id of the person logged in.
    >
    >
    >
    > thanks for your help

    Andrea D'Onofrio [MSFT] Guest

  4. #3

    Default Re: asp.net, basic authentication, file access

    I don't believe I have impersonation turned on. Here is
    my machine.config entries:
    <identity impersonate="false" userName="" password=""/>

    <processModel
    enable="true"
    timeout="Infinite"
    idleTimeout="Infinite"
    shutdownTimeout="0:00:05"
    requestLimit="Infinite"
    requestQueueLimit="5000"
    restartQueueLimit="10"
    memoryLimit="60"
    webGarden="false"
    cpuMask="0xffffffff"
    userName="machine"
    password="AutoGenerate"
    logLevel="Errors"
    clientConnectedCheck="0:00:05"
    comAuthenticationLevel="Connect"
    comImpersonationLevel="Impersonate"
    responseDeadlockInterval="00:03:00"
    maxWorkerThreads="20"
    maxIoThreads="20"
    />

    However, if I place this code in an aspx page:
    Thread.CurrentPrincipal.Identity.Name.ToString()
    I see the id of the person being authenticated.

    >-----Original Message-----
    >If you have turned the impersonation on the .net code
    will run under the
    >identity of he users who will be accessing the site, else
    the .net code will
    >run under the ASPNET account (this is a default) identity.
    >
    >HtH,
    >Andrea
    >
    >--
    >This posting is provided "AS IS" with no warranties, and
    confers no rights.
    >
    >
    >"jzink" <zinks.home@verizon.net> wrote in message
    >news:065401c3d141$c293ee60$a501280a@phx.gbl...
    >> I have a asp.net application that is configured to
    >> use "basic authentication". The application needs to
    have
    >> access to delete a file in let's say directory
    >> d:\inetpub\wwwroot\myApp\reports. Do I need to grant
    >> access to the ASPNET account or to the accounts of the
    >> users who will be accessing the site ?
    >>
    >> I put the following line of code in
    >> Thread.CurrentPrincipal.Identity.Name.ToString() and it
    >> returns the id of the person logged in.
    >>
    >>
    >>
    >> thanks for your help
    >
    >
    >.
    >
    JZink Guest

  5. #4

    Default RE: asp.net, basic authentication, file access

    You will want to grant access to the ASPNET account for deleting the file.
    If you want only the authenticated user to have the ability to delete the
    file then you could simply set impersonation to true and set permissions
    for that logged on user. If you do this and you are still having problems,
    a good way to troubleshoot would be to use filemon while you repro any
    errors. You can download it from [url]www.sysinternals.com[/url]. It will show you
    what user is accessing what files and whether the access was successful or
    not.

    This posting is provided "AS IS" with no warranties, and confers no rights.

    Holly

    Holly Mazerolle Guest

  6. #5

    Default RE: asp.net, basic authentication, file access

    I do not have impersonation set to true, yet when I put
    this code into my aspx page:
    Response.Write (
    Thread.CurrentPrincipal.Identity.Name.ToString() )
    it will write out the name of the user who was
    authenticated not ASPNET. What am I missing ???
    >-----Original Message-----
    >You will want to grant access to the ASPNET account for
    deleting the file.
    >If you want only the authenticated user to have the
    ability to delete the
    >file then you could simply set impersonation to true and
    set permissions
    >for that logged on user. If you do this and you are still
    having problems,
    >a good way to troubleshoot would be to use filemon while
    you repro any
    >errors. You can download it from [url]www.sysinternals.com[/url]. It
    will show you
    >what user is accessing what files and whether the access
    was successful or
    >not.
    >
    >This posting is provided "AS IS" with no warranties, and
    confers no rights.
    >
    >Holly
    >
    >.
    >
    jzink Guest

  7. #6

    Default Re: asp.net, basic authentication, file access

    If you want to see the identity of the worker process, that is, the account
    that will be used to access your protected resource, you should use
    System.Security.Principal.WindowsIdentity.GetCurre nt().Name.

    This will return, in you case, the ASPNET account if you turn off
    impersonation, or your logged on user account if you turn on impersonation.



    --
    Eng. Hernan de Lahitte - MSDE
    Lagash Systems S.A. - Buenos Aires, Argentina
    [url]http://www.lagash.com[/url]



    "jzink" <zinks.home@verizon.net> wrote in message
    news:096201c3d468$ab769af0$a601280a@phx.gbl...
    > I do not have impersonation set to true, yet when I put
    > this code into my aspx page:
    > Response.Write (
    > Thread.CurrentPrincipal.Identity.Name.ToString() )
    > it will write out the name of the user who was
    > authenticated not ASPNET. What am I missing ???
    >
    > >-----Original Message-----
    > >You will want to grant access to the ASPNET account for
    > deleting the file.
    > >If you want only the authenticated user to have the
    > ability to delete the
    > >file then you could simply set impersonation to true and
    > set permissions
    > >for that logged on user. If you do this and you are still
    > having problems,
    > >a good way to troubleshoot would be to use filemon while
    > you repro any
    > >errors. You can download it from [url]www.sysinternals.com[/url]. It
    > will show you
    > >what user is accessing what files and whether the access
    > was successful or
    > >not.
    > >
    > >This posting is provided "AS IS" with no warranties, and
    > confers no rights.
    > >
    > >Holly
    > >
    > >.
    > >

    Hernan de Lahitte Guest

  8. #7

    Default Re: asp.net, basic authentication, file access

    I changed the aspx code to print out
    System.Security.Principal.WindowsIdentity.GetCurre nt().Name
    and now i see NT AUTHORITY\NETWORK SERVICE. shouldn't i
    see aspnet ???
    >-----Original Message-----
    >If you want to see the identity of the worker process,
    that is, the account
    >that will be used to access your protected resource, you
    should use
    >System.Security.Principal.WindowsIdentity.GetCurr ent
    ().Name.
    >
    >This will return, in you case, the ASPNET account if you
    turn off
    >impersonation, or your logged on user account if you turn
    on impersonation.
    >
    >
    >
    >--
    >Eng. Hernan de Lahitte - MSDE
    >Lagash Systems S.A. - Buenos Aires, Argentina
    >[url]http://www.lagash.com[/url]
    >
    >
    >
    >"jzink" <zinks.home@verizon.net> wrote in message
    >news:096201c3d468$ab769af0$a601280a@phx.gbl...
    >> I do not have impersonation set to true, yet when I put
    >> this code into my aspx page:
    >> Response.Write (
    >> Thread.CurrentPrincipal.Identity.Name.ToString() )
    >> it will write out the name of the user who was
    >> authenticated not ASPNET. What am I missing ???
    >>
    >> >-----Original Message-----
    >> >You will want to grant access to the ASPNET account for
    >> deleting the file.
    >> >If you want only the authenticated user to have the
    >> ability to delete the
    >> >file then you could simply set impersonation to true
    and
    >> set permissions
    >> >for that logged on user. If you do this and you are
    still
    >> having problems,
    >> >a good way to troubleshoot would be to use filemon
    while
    >> you repro any
    >> >errors. You can download it from [url]www.sysinternals.com[/url].
    It
    >> will show you
    >> >what user is accessing what files and whether the
    access
    >> was successful or
    >> >not.
    >> >
    >> >This posting is provided "AS IS" with no warranties,
    and
    >> confers no rights.
    >> >
    >> >Holly
    >> >
    >> >.
    >> >
    >
    >
    >.
    >
    jzink Guest

  9. #8

    Default Re: asp.net, basic authentication, file access

    This is the default AppPoll Account for W2K3. This might be you case. The
    ASPNET account is the default for an XP box or lower.

    --
    Eng. Hernan de Lahitte - MSDE
    Lagash Systems S.A. - Buenos Aires, Argentina
    [url]http://www.lagash.com[/url]



    "jzink" <zinks.home@verizon.net> wrote in message
    news:00ac01c3d48a$fe49a340$a601280a@phx.gbl...
    > I changed the aspx code to print out
    > System.Security.Principal.WindowsIdentity.GetCurre nt().Name
    > and now i see NT AUTHORITY\NETWORK SERVICE. shouldn't i
    > see aspnet ???
    >
    > >-----Original Message-----
    > >If you want to see the identity of the worker process,
    > that is, the account
    > >that will be used to access your protected resource, you
    > should use
    > >System.Security.Principal.WindowsIdentity.GetCurr ent
    > ().Name.
    > >
    > >This will return, in you case, the ASPNET account if you
    > turn off
    > >impersonation, or your logged on user account if you turn
    > on impersonation.
    > >
    > >
    > >
    > >--
    > >Eng. Hernan de Lahitte - MSDE
    > >Lagash Systems S.A. - Buenos Aires, Argentina
    > >[url]http://www.lagash.com[/url]
    > >
    > >
    > >
    > >"jzink" <zinks.home@verizon.net> wrote in message
    > >news:096201c3d468$ab769af0$a601280a@phx.gbl...
    > >> I do not have impersonation set to true, yet when I put
    > >> this code into my aspx page:
    > >> Response.Write (
    > >> Thread.CurrentPrincipal.Identity.Name.ToString() )
    > >> it will write out the name of the user who was
    > >> authenticated not ASPNET. What am I missing ???
    > >>
    > >> >-----Original Message-----
    > >> >You will want to grant access to the ASPNET account for
    > >> deleting the file.
    > >> >If you want only the authenticated user to have the
    > >> ability to delete the
    > >> >file then you could simply set impersonation to true
    > and
    > >> set permissions
    > >> >for that logged on user. If you do this and you are
    > still
    > >> having problems,
    > >> >a good way to troubleshoot would be to use filemon
    > while
    > >> you repro any
    > >> >errors. You can download it from [url]www.sysinternals.com[/url].
    > It
    > >> will show you
    > >> >what user is accessing what files and whether the
    > access
    > >> was successful or
    > >> >not.
    > >> >
    > >> >This posting is provided "AS IS" with no warranties,
    > and
    > >> confers no rights.
    > >> >
    > >> >Holly
    > >> >
    > >> >.
    > >> >
    > >
    > >
    > >.
    > >

    Hernan de Lahitte Guest

  10. #9

    Default Re: asp.net, basic authentication, file access

    what do you mean by appPoll account and how come I don't
    see nt authority\network service as a user in computer
    management\users ??
    >-----Original Message-----
    >This is the default AppPoll Account for W2K3. This might
    be you case. The
    >ASPNET account is the default for an XP box or lower.
    >
    >--
    >Eng. Hernan de Lahitte - MSDE
    >Lagash Systems S.A. - Buenos Aires, Argentina
    >[url]http://www.lagash.com[/url]
    >
    >
    >
    >"jzink" <zinks.home@verizon.net> wrote in message
    >news:00ac01c3d48a$fe49a340$a601280a@phx.gbl...
    >> I changed the aspx code to print out
    >> System.Security.Principal.WindowsIdentity.GetCurre nt
    ().Name
    >> and now i see NT AUTHORITY\NETWORK SERVICE. shouldn't i
    >> see aspnet ???
    >>
    >> >-----Original Message-----
    >> >If you want to see the identity of the worker process,
    >> that is, the account
    >> >that will be used to access your protected resource,
    you
    >> should use
    >> >System.Security.Principal.WindowsIdentity.GetCurr ent
    >> ().Name.
    >> >
    >> >This will return, in you case, the ASPNET account if
    you
    >> turn off
    >> >impersonation, or your logged on user account if you
    turn
    >> on impersonation.
    >> >
    >> >
    >> >
    >> >--
    >> >Eng. Hernan de Lahitte - MSDE
    >> >Lagash Systems S.A. - Buenos Aires, Argentina
    >> >[url]http://www.lagash.com[/url]
    >> >
    >> >
    >> >
    >> >"jzink" <zinks.home@verizon.net> wrote in message
    >> >news:096201c3d468$ab769af0$a601280a@phx.gbl...
    >> >> I do not have impersonation set to true, yet when I
    put
    >> >> this code into my aspx page:
    >> >> Response.Write (
    >> >> Thread.CurrentPrincipal.Identity.Name.ToString() )
    >> >> it will write out the name of the user who was
    >> >> authenticated not ASPNET. What am I missing ???
    >> >>
    >> >> >-----Original Message-----
    >> >> >You will want to grant access to the ASPNET account
    for
    >> >> deleting the file.
    >> >> >If you want only the authenticated user to have the
    >> >> ability to delete the
    >> >> >file then you could simply set impersonation to true
    >> and
    >> >> set permissions
    >> >> >for that logged on user. If you do this and you are
    >> still
    >> >> having problems,
    >> >> >a good way to troubleshoot would be to use filemon
    >> while
    >> >> you repro any
    >> >> >errors. You can download it from
    [url]www.sysinternals.com[/url].
    >> It
    >> >> will show you
    >> >> >what user is accessing what files and whether the
    >> access
    >> >> was successful or
    >> >> >not.
    >> >> >
    >> >> >This posting is provided "AS IS" with no warranties,
    >> and
    >> >> confers no rights.
    >> >> >
    >> >> >Holly
    >> >> >
    >> >> >.
    >> >> >
    >> >
    >> >
    >> >.
    >> >
    >
    >
    >.
    >
    jzink Guest

  11. #10

    Default Re: asp.net, basic authentication, file access

    With AppPool, I refer to the Application Pool that has Windows 2003. To
    check this, go to the IIS Management Console snap-in and in the Application
    Pools folder, right click the DefaultAppPool node (This is the default
    Application Pool for all Web Sites). In the Properties/Identity tab option,
    you will see you selected Application Pool Identity.This should be the
    Network Service or in the canonical format, "NT AUTHORITY\NETWORK SERVICE".
    As you ponted out, you won't see this account with the Users manager. This
    is a predefined system account, like the System (TCB) account. The Network
    Service account is a low priviledge account so if you change this account in
    the AppPool Identity option for another with more priviledges, be carefull
    with a possible "Elevation of Priviledge Threat".

    --
    Eng. Hernan de Lahitte - MSDE
    Lagash Systems S.A. - Buenos Aires, Argentina
    [url]http://www.lagash.com[/url]



    "jzink" <zinks.home@verizon.net> wrote in message
    news:076701c3d4cb$1e7e7740$a101280a@phx.gbl...
    > what do you mean by appPoll account and how come I don't
    > see nt authority\network service as a user in computer
    > management\users ??
    >
    > >-----Original Message-----
    > >This is the default AppPoll Account for W2K3. This might
    > be you case. The
    > >ASPNET account is the default for an XP box or lower.
    > >
    > >--
    > >Eng. Hernan de Lahitte - MSDE
    > >Lagash Systems S.A. - Buenos Aires, Argentina
    > >[url]http://www.lagash.com[/url]
    > >
    > >
    > >
    > >"jzink" <zinks.home@verizon.net> wrote in message
    > >news:00ac01c3d48a$fe49a340$a601280a@phx.gbl...
    > >> I changed the aspx code to print out
    > >> System.Security.Principal.WindowsIdentity.GetCurre nt
    > ().Name
    > >> and now i see NT AUTHORITY\NETWORK SERVICE. shouldn't i
    > >> see aspnet ???
    > >>
    > >> >-----Original Message-----
    > >> >If you want to see the identity of the worker process,
    > >> that is, the account
    > >> >that will be used to access your protected resource,
    > you
    > >> should use
    > >> >System.Security.Principal.WindowsIdentity.GetCurr ent
    > >> ().Name.
    > >> >
    > >> >This will return, in you case, the ASPNET account if
    > you
    > >> turn off
    > >> >impersonation, or your logged on user account if you
    > turn
    > >> on impersonation.
    > >> >
    > >> >
    > >> >
    > >> >--
    > >> >Eng. Hernan de Lahitte - MSDE
    > >> >Lagash Systems S.A. - Buenos Aires, Argentina
    > >> >[url]http://www.lagash.com[/url]
    > >> >
    > >> >
    > >> >
    > >> >"jzink" <zinks.home@verizon.net> wrote in message
    > >> >news:096201c3d468$ab769af0$a601280a@phx.gbl...
    > >> >> I do not have impersonation set to true, yet when I
    > put
    > >> >> this code into my aspx page:
    > >> >> Response.Write (
    > >> >> Thread.CurrentPrincipal.Identity.Name.ToString() )
    > >> >> it will write out the name of the user who was
    > >> >> authenticated not ASPNET. What am I missing ???
    > >> >>
    > >> >> >-----Original Message-----
    > >> >> >You will want to grant access to the ASPNET account
    > for
    > >> >> deleting the file.
    > >> >> >If you want only the authenticated user to have the
    > >> >> ability to delete the
    > >> >> >file then you could simply set impersonation to true
    > >> and
    > >> >> set permissions
    > >> >> >for that logged on user. If you do this and you are
    > >> still
    > >> >> having problems,
    > >> >> >a good way to troubleshoot would be to use filemon
    > >> while
    > >> >> you repro any
    > >> >> >errors. You can download it from
    > [url]www.sysinternals.com[/url].
    > >> It
    > >> >> will show you
    > >> >> >what user is accessing what files and whether the
    > >> access
    > >> >> was successful or
    > >> >> >not.
    > >> >> >
    > >> >> >This posting is provided "AS IS" with no warranties,
    > >> and
    > >> >> confers no rights.
    > >> >> >
    > >> >> >Holly
    > >> >> >
    > >> >> >.
    > >> >> >
    > >> >
    > >> >
    > >> >.
    > >> >
    > >
    > >
    > >.
    > >

    Hernan de Lahitte Guest

  12. #11

    Default Re: asp.net, basic authentication, file access

    So in your case since you are on Win2003 and you are not using
    impersonation the NT Authority\Network Service account will be who is
    accessing the location you are attempting to delete files from. As I
    mentioned before you may want to consider impersonation so that you only
    give permission to a specific domain account.

    This posting is provided "AS IS" with no warranties, and confers no rights.

    Holly

    Holly Mazerolle 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