Writing to a network share

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

  1. #1

    Default Writing to a network share

    I posted this message in dotnet.framework.security, and was told to repost it her

    Alright, I've been trying to figure out the solution to this problem for a few days and I'm officially stumped.

    My web app server, Machine A, needs the ability to create a file(xml) on my db server, Machine B. The application performs this task after a user invokes a business object through an ASP.net page. Now, if I do this on the app server (ie, log on locally), it works fine. However, if i do this from another client machine, Machine C, I get the beautiful error message

    Access to path \\machineb\log\log.xml is denied

    <code
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.UnauthorizedAccessException: Access to the path "\\orchard\Log\test.xml" is denied.

    ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.

    To grant ASP.NET write access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access

    </code

    Now, here is what I've done

    I've given full control to the directory on the network share to everyon
    I've changed machine.config process model to the SYSTEM account. When that didn't work, I changed it to my network account, which has local admin rights on the network
    I've tried mucking around with the Internet zone permissions and Intranet zone permissions through the .net tools, giving both full trust priviledges, no luc
    We've set the asp.net service to log on as a local system account, network system account, my domain account, and finally, the domains admin account, still no luc

    My code is very simple

    <code
    private void Button1_Click(object sender, System.EventArgs e

    XmlTextWriter writer = new XmlTextWriter(@"\\machinea\Log\log.xml", Encoding.UTF8)
    writer.WriteStartDocument()
    writer.WriteStartElement("DATA")
    writer.WriteElementString("TEST", "Is this going to work")
    writer.WriteEndElement()
    writer.WriteEndDocument()
    writer.Close()

    </code

    So, what am I missing?


    Tyler Davey Guest

  2. Similar Questions and Discussions

    1. Running ASP.NET app off network share
      I'm using IIS 6.0 to try to run an ASP.NET application the files for which live on a shared folder on a machine which also happens to be on a...
    2. ASP.NET permission problems from a network share
      Hi there, I have a new win 2003 web server and having troubles setting up .NET. Im getting the following error from my applications: ...
    3. IIS settings + Dot Net + Network share
      Hi, Good Morning! guys. I am developing a DOT NEt application, using windows 2000 Professional, Dot net FrameWork 1.1. In my localhost Setting on...
    4. share internet in small network HELP?
      First excuse me if make mistake in English still Learn Pierre Got 3 computers, A, B, C, connect together on a router R. A) Windows XP HOME,...
    5. Share files on network
      I have just installed a router between two computers. The main computer is running XP Pro and the other is running 2K pro. Both computers are able...
  3. #2

    Default Re: Writing to a network share

    Take a close look at this document--
    Building Secure ASP.NET Applications: Authentication, Authorization, and Secure Communication.

    Or,
    [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/SecNetHT01.asp[/url]

    If you are using Windows Authentication--follow the Mirrored Account with No impersonation. That's the easiest way to access network resources.


    "Tyler Davey" <anonymous@discussions.microsoft.com> wrote in message news:715EB9C1-2DD9-4E52-B902-284DA7833F6D@microsoft.com...
    > I posted this message in dotnet.framework.security, and was told to repost it here
    >
    > Alright, I've been trying to figure out the solution to this problem for a few days and I'm officially stumped.
    >
    > My web app server, Machine A, needs the ability to create a file(xml) on my db server, Machine B. The application performs this task after a user invokes a business object through an ASP.net page. Now, if I do this on the app server (ie, log on locally), it works fine. However, if i do this from another client machine, Machine C, I get the beautiful error message:
    >
    > Access to path \\machineb\log\log.xml is denied.
    >
    > <code>
    > Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
    >
    > Exception Details: System.UnauthorizedAccessException: Access to the path "\\orchard\Log\test.xml" is denied.
    >
    > ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.
    >
    > To grant ASP.NET write access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.
    >
    > </code>
    >
    > Now, here is what I've done:
    >
    > I've given full control to the directory on the network share to everyone
    > I've changed machine.config process model to the SYSTEM account. When that didn't work, I changed it to my network account, which has local admin rights on the network.
    > I've tried mucking around with the Internet zone permissions and Intranet zone permissions through the .net tools, giving both full trust priviledges, no luck
    > We've set the asp.net service to log on as a local system account, network system account, my domain account, and finally, the domains admin account, still no luck
    >
    > My code is very simple:
    >
    > <code>
    > private void Button1_Click(object sender, System.EventArgs e)
    > {
    > XmlTextWriter writer = new XmlTextWriter(@"\\machinea\Log\log.xml", Encoding.UTF8);
    > writer.WriteStartDocument();
    > writer.WriteStartElement("DATA");
    > writer.WriteElementString("TEST", "Is this going to work");
    > writer.WriteEndElement();
    > writer.WriteEndDocument();
    > writer.Close();
    > }
    > </code>
    >
    > So, what am I missing?
    >
    >
    Prodip Saha Guest

  4. #3

    Default Re: Writing to a network share

    Hi

    Machine\ASPNET is a local account - it can't be assigned permissions to
    remote resources
    LocalSystem is also a local account.

    Try using a *domain* account that has permissions to the remote resource.

    Cheers
    Ken

    "Tyler Davey" <anonymous@discussions.microsoft.com> wrote in message
    news:715EB9C1-2DD9-4E52-B902-284DA7833F6D@microsoft.com...
    : I posted this message in dotnet.framework.security, and was told to repost
    it here
    :
    : Alright, I've been trying to figure out the solution to this problem for a
    few days and I'm officially stumped.
    :
    : My web app server, Machine A, needs the ability to create a file(xml) on
    my db server, Machine B. The application performs this task after a user
    invokes a business object through an ASP.net page. Now, if I do this on the
    app server (ie, log on locally), it works fine. However, if i do this from
    another client machine, Machine C, I get the beautiful error message:
    :
    : Access to path \\machineb\log\log.xml is denied.
    :
    : <code>
    : Description: An unhandled exception occurred during the execution of the
    current web request. Please review the stack trace for more information
    about the error and where it originated in the code.
    :
    : Exception Details: System.UnauthorizedAccessException: Access to the path
    "\\orchard\Log\test.xml" is denied.
    :
    : ASP.NET is not authorized to access the requested resource. Consider
    granting access rights to the resource to the ASP.NET request identity.
    ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or
    Network Service on IIS 6) that is used if the application is not
    impersonating. If the application is impersonating via <identity
    impersonate="true"/>, the identity will be the anonymous user (typically
    IUSR_MACHINENAME) or the authenticated request user.
    :
    : To grant ASP.NET write access to a file, right-click the file in Explorer,
    choose "Properties" and select the Security tab. Click "Add" to add the
    appropriate user or group. Highlight the ASP.NET account, and check the
    boxes for the desired access.
    :
    : </code>
    :
    : Now, here is what I've done:
    :
    : I've given full control to the directory on the network share to everyone
    : I've changed machine.config process model to the SYSTEM account. When
    that didn't work, I changed it to my network account, which has local admin
    rights on the network.
    : I've tried mucking around with the Internet zone permissions and Intranet
    zone permissions through the .net tools, giving both full trust priviledges,
    no luck
    : We've set the asp.net service to log on as a local system account, network
    system account, my domain account, and finally, the domains admin account,
    still no luck
    :
    : My code is very simple:
    :
    : <code>
    : private void Button1_Click(object sender, System.EventArgs e)
    : {
    : XmlTextWriter writer = new XmlTextWriter(@"\\machinea\Log\log.xml",
    Encoding.UTF8);
    : writer.WriteStartDocument();
    : writer.WriteStartElement("DATA");
    : writer.WriteElementString("TEST", "Is this going to work");
    : writer.WriteEndElement();
    : writer.WriteEndDocument();
    : writer.Close();
    : }
    : </code>
    :
    : So, what am I missing?
    :
    :


    Ken Schaefer Guest

  5. #4

    Default Re: Writing to a network share

    Using domain account to run the aspnet_wp is risky. Compromizing one domain
    account is amount to compromizing the whole domain.

    Local Machine\ASPNET mirrored account on the remote server with same
    password as that of webserver machine is sufficient to access remote
    resource.

    "Ken Schaefer" <kenREMOVE@THISadOpenStatic.com> wrote in message
    news:%230sduLbKEHA.2712@TK2MSFTNGP10.phx.gbl...
    > Hi
    >
    > Machine\ASPNET is a local account - it can't be assigned permissions to
    > remote resources
    > LocalSystem is also a local account.
    >
    > Try using a *domain* account that has permissions to the remote resource.
    >
    > Cheers
    > Ken
    >
    > "Tyler Davey" <anonymous@discussions.microsoft.com> wrote in message
    > news:715EB9C1-2DD9-4E52-B902-284DA7833F6D@microsoft.com...
    > : I posted this message in dotnet.framework.security, and was told to
    repost
    > it here
    > :
    > : Alright, I've been trying to figure out the solution to this problem for
    a
    > few days and I'm officially stumped.
    > :
    > : My web app server, Machine A, needs the ability to create a file(xml) on
    > my db server, Machine B. The application performs this task after a user
    > invokes a business object through an ASP.net page. Now, if I do this on
    the
    > app server (ie, log on locally), it works fine. However, if i do this
    from
    > another client machine, Machine C, I get the beautiful error message:
    > :
    > : Access to path \\machineb\log\log.xml is denied.
    > :
    > : <code>
    > : Description: An unhandled exception occurred during the execution of the
    > current web request. Please review the stack trace for more information
    > about the error and where it originated in the code.
    > :
    > : Exception Details: System.UnauthorizedAccessException: Access to the
    path
    > "\\orchard\Log\test.xml" is denied.
    > :
    > : ASP.NET is not authorized to access the requested resource. Consider
    > granting access rights to the resource to the ASP.NET request identity.
    > ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5
    or
    > Network Service on IIS 6) that is used if the application is not
    > impersonating. If the application is impersonating via <identity
    > impersonate="true"/>, the identity will be the anonymous user (typically
    > IUSR_MACHINENAME) or the authenticated request user.
    > :
    > : To grant ASP.NET write access to a file, right-click the file in
    Explorer,
    > choose "Properties" and select the Security tab. Click "Add" to add the
    > appropriate user or group. Highlight the ASP.NET account, and check the
    > boxes for the desired access.
    > :
    > : </code>
    > :
    > : Now, here is what I've done:
    > :
    > : I've given full control to the directory on the network share to
    everyone
    > : I've changed machine.config process model to the SYSTEM account. When
    > that didn't work, I changed it to my network account, which has local
    admin
    > rights on the network.
    > : I've tried mucking around with the Internet zone permissions and
    Intranet
    > zone permissions through the .net tools, giving both full trust
    priviledges,
    > no luck
    > : We've set the asp.net service to log on as a local system account,
    network
    > system account, my domain account, and finally, the domains admin account,
    > still no luck
    > :
    > : My code is very simple:
    > :
    > : <code>
    > : private void Button1_Click(object sender, System.EventArgs e)
    > : {
    > : XmlTextWriter writer = new XmlTextWriter(@"\\machinea\Log\log.xml",
    > Encoding.UTF8);
    > : writer.WriteStartDocument();
    > : writer.WriteStartElement("DATA");
    > : writer.WriteElementString("TEST", "Is this going to work");
    > : writer.WriteEndElement();
    > : writer.WriteEndDocument();
    > : writer.Close();
    > : }
    > : </code>
    > :
    > : So, what am I missing?
    > :
    > :
    >
    >

    Prodip Saha 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