problem writing a file

Discussion in 'ASP .Net Security' started by Iain A. Mcleod, Sep 27, 2004.

  1. Hi,
    I'm really stuck with this one - wondering if you can spot the problem?
    I think that it's a webserver problem that goes deeper than web.config.
    I've not been able to write to a file on a network share via ASP.NET. The
    network share is not the same as the webserver.

    relevant section of web.config:
    <appSettings>
    <!-- the location we cannot write to. My staging server
    doesn't have write permissions here, but I do if authenticating as
    myself -->
    <add key="ProjectCollection"
    value=\\my_server\userhome\MyAccount\websiteTests\test.txt />
    </appSettings>
    <!-- Neither of these work!
    I have write perms here for my user accunt and believe that
    my staging server has write perms here too
    add key="ProjectCollection"
    value=\\my_server\commondocuments\websiteTests\test.txt />
    -->
    </appSettings>
    <system.web>
    <!-- I have also tried "None" here -->
    <authentication mode="Windows" />

    <!-- I have tried leaving this out -->
    <identity impersonate="true" />

    <authorization>
    <allow users="mydomain\myusername" />
    <deny users="*" />
    <!-- I have tried allow users="*" but I think that then my server
    tries to authenticate as ASPNET. This certainly should not access my home
    folder, but should??? access the common share. I believe that my
    administrator has set up access privs for my server on the common share. It
    doesn't access it however! -->
    </authorization>
    </system.web>
    Relevant code:
    Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles btnSearch.Click
    'identity we are running as - 2 ways of getting the same
    information
    ' returns my username if I am impersonating and
    authenticating in web.config
    'however, still cannot write to either folder no
    matter what I am impersonating or not
    Trace.Write(Page.User.Identity.Name)

    Trace.Write(System.Security.Principal.WindowsIdentity.GetCurrent().Name)
    'filename we are trying to write to
    Dim strFileName As String =
    ConfigurationSettings.AppSettings("ProjectCollection")
    Trace.Write(strFileName)
    'fails here. This creates a file in location specified by
    Config setting above
    Dim fs As FileStream = New FileStream(strFileName,
    FileMode.Append)
    Dim w As New StreamWriter(fs)
    w.WriteLine("Test")
    w.Close()
    fs.Close()
    End Sub
    Any Ideas?
    Many thanks
    Sorry for long post
    Iain
     
    Iain A. Mcleod, Sep 27, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark Kamoski
    Replies:
    1
    Views:
    2,467
  2. BLF
    Replies:
    4
    Views:
    1,307
    Mike Treseler
    Aug 7, 2004
  3. John Carnahan

    File Access error - writing to .txt file

    John Carnahan, Jul 18, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    817
    John Carnahan
    Jul 18, 2003
  4. HNguyen
    Replies:
    4
    Views:
    2,457
    HNguyen
    Dec 21, 2004
  5. Greg
    Replies:
    9
    Views:
    840
    Nobody
    Oct 8, 2011
Loading...

Share This Page