problems reading network file from ASP .NET

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

    #1

    problems reading network file from ASP .NET

    I've written a simple ASP .NET web application that reads a text file and
    displays it in the web browser. Works fine when reading a local path; but
    fails with "can not find a part of the path", or "can not access network
    file" when attemting to access a UNC network path. I am using IIS 6.0 on
    Server 2003. SharePoint Portal Server is also installed on this server. I
    have granted full access to 'everyone' on the network file. An equivalent
    ..NET desktop application reads the file fine.

    This seems like a trival task. What am I missing?
  • Bill Borg

    #2
    RE: problems reading network file from ASP .NET

    Try giving access specifically to your ASP.NET machine account, which by
    default has less privilege than Everyone. Equivalent .NET app is fine because
    it's not running under a least-privileged account.

    Bill

    "zxkuqyb" wrote:
    [color=blue]
    > I've written a simple ASP .NET web application that reads a text file and
    > displays it in the web browser. Works fine when reading a local path; but
    > fails with "can not find a part of the path", or "can not access network
    > file" when attemting to access a UNC network path. I am using IIS 6.0 on
    > Server 2003. SharePoint Portal Server is also installed on this server. I
    > have granted full access to 'everyone' on the network file. An equivalent
    > .NET desktop application reads the file fine.
    >
    > This seems like a trival task. What am I missing?[/color]

    Comment

    • Steve C. Orr [MVP, MCSD]

      #3
      Re: problems reading network file from ASP .NET

      The ASPNET user account that ASP.NET uses by default does not have network
      permissions. Either give the account such network permissions (likely with
      the help of your network administrator) or use impersonation to have it run
      under a different user account that does have such permissions.
      For testing purposes you can have it run under your personal user account.
      Here's more info:
      http://msdn.microsoft.com/library/de...ersonation.asp

      --
      I hope this helps,
      Steve C. Orr, MCSD, MVP



      "zxkuqyb" <zxkuqyb@discus sions.microsoft .com> wrote in message
      news:C6DB0A87-8B02-4ED3-B5CE-360609D99E7A@mi crosoft.com...[color=blue]
      > I've written a simple ASP .NET web application that reads a text file and
      > displays it in the web browser. Works fine when reading a local path; but
      > fails with "can not find a part of the path", or "can not access network
      > file" when attemting to access a UNC network path. I am using IIS 6.0 on
      > Server 2003. SharePoint Portal Server is also installed on this server.
      > I
      > have granted full access to 'everyone' on the network file. An equivalent
      > .NET desktop application reads the file fine.
      >
      > This seems like a trival task. What am I missing?[/color]


      Comment

      • zxkuqyb

        #4
        Re: problems reading network file from ASP .NET

        I am using impersonation, and exactly that seems to be the problem. If I set
        identity impersonate to false, the files are read fine. Set to true, access
        is denied. I went through and granted the approprite permissions to both the
        IIS_WPG and the user accounts. Is there anything else that could be limiting
        access?

        "Steve C. Orr [MVP, MCSD]" wrote:
        [color=blue]
        > The ASPNET user account that ASP.NET uses by default does not have network
        > permissions. Either give the account such network permissions (likely with
        > the help of your network administrator) or use impersonation to have it run
        > under a different user account that does have such permissions.
        > For testing purposes you can have it run under your personal user account.
        > Here's more info:
        > http://msdn.microsoft.com/library/de...ersonation.asp
        >
        > --
        > I hope this helps,
        > Steve C. Orr, MCSD, MVP
        > http://SteveOrr.net
        >
        >
        > "zxkuqyb" <zxkuqyb@discus sions.microsoft .com> wrote in message
        > news:C6DB0A87-8B02-4ED3-B5CE-360609D99E7A@mi crosoft.com...[color=green]
        > > I've written a simple ASP .NET web application that reads a text file and
        > > displays it in the web browser. Works fine when reading a local path; but
        > > fails with "can not find a part of the path", or "can not access network
        > > file" when attemting to access a UNC network path. I am using IIS 6.0 on
        > > Server 2003. SharePoint Portal Server is also installed on this server.
        > > I
        > > have granted full access to 'everyone' on the network file. An equivalent
        > > .NET desktop application reads the file fine.
        > >
        > > This seems like a trival task. What am I missing?[/color]
        >
        >
        >[/color]

        Comment

        • Steve C. Orr [MVP, MCSD]

          #5
          Re: problems reading network file from ASP .NET

          OK, so then don't use impersonation.
          Problem solved.
          No?

          --
          I hope this helps,
          Steve C. Orr, MCSD, MVP



          "zxkuqyb" <zxkuqyb@discus sions.microsoft .com> wrote in message
          news:C65A5173-CD9A-4B6A-8A34-1BA6498301AF@mi crosoft.com...[color=blue]
          >I am using impersonation, and exactly that seems to be the problem. If I
          >set
          > identity impersonate to false, the files are read fine. Set to true,
          > access
          > is denied. I went through and granted the approprite permissions to both
          > the
          > IIS_WPG and the user accounts. Is there anything else that could be
          > limiting
          > access?
          >[/color]


          Comment

          • zxkuqyb

            #6
            Re: problems reading network file from ASP .NET

            If I didn't need to restrict access to the app on a per user basis, sure that
            would solve the problem. Being that I do, it sure would be nice if
            impersonation worked.

            thanks

            "Steve C. Orr [MVP, MCSD]" wrote:
            [color=blue]
            > OK, so then don't use impersonation.
            > Problem solved.
            > No?
            >
            > --
            > I hope this helps,
            > Steve C. Orr, MCSD, MVP
            > http://SteveOrr.net
            >
            >
            > "zxkuqyb" <zxkuqyb@discus sions.microsoft .com> wrote in message
            > news:C65A5173-CD9A-4B6A-8A34-1BA6498301AF@mi crosoft.com...[color=green]
            > >I am using impersonation, and exactly that seems to be the problem. If I
            > >set
            > > identity impersonate to false, the files are read fine. Set to true,
            > > access
            > > is denied. I went through and granted the approprite permissions to both
            > > the
            > > IIS_WPG and the user accounts. Is there anything else that could be
            > > limiting
            > > access?
            > >[/color]
            >
            >
            >[/color]

            Comment

            • Kurt Yokum

              #7
              Re: problems reading network file from ASP .NET

              Did you ever get resolution on this?

              I am having a nearly identical problem. SharePoint development server,
              running Windows 2003, trying to do a File.Exists on a file on the network
              using a UNC path, and it returns false. On doing a File.OpenRead it says the
              file does not exist which isn't true. The web.config already was setup for
              Windows impersonation on the SharePoint dev server and that setting is what
              it took to get it to work in a non-Sharepoint .NET app so it wouldn't use the
              ASPNET credentials. Something is going on with SharePoint. Any ideas?

              "zxkuqyb" wrote:
              [color=blue]
              > If I didn't need to restrict access to the app on a per user basis, sure that
              > would solve the problem. Being that I do, it sure would be nice if
              > impersonation worked.
              >
              > thanks
              >
              > "Steve C. Orr [MVP, MCSD]" wrote:
              >[color=green]
              > > OK, so then don't use impersonation.
              > > Problem solved.
              > > No?
              > >
              > > --
              > > I hope this helps,
              > > Steve C. Orr, MCSD, MVP
              > > http://SteveOrr.net
              > >
              > >
              > > "zxkuqyb" <zxkuqyb@discus sions.microsoft .com> wrote in message
              > > news:C65A5173-CD9A-4B6A-8A34-1BA6498301AF@mi crosoft.com...[color=darkred]
              > > >I am using impersonation, and exactly that seems to be the problem. If I
              > > >set
              > > > identity impersonate to false, the files are read fine. Set to true,
              > > > access
              > > > is denied. I went through and granted the approprite permissions to both
              > > > the
              > > > IIS_WPG and the user accounts. Is there anything else that could be
              > > > limiting
              > > > access?
              > > >[/color]
              > >
              > >
              > >[/color][/color]

              Comment

              • zxkuqyb

                #8
                Re: problems reading network file from ASP .NET

                I had to use "basic authentication" to get the app to work.

                Comment

                Working...