FileSystemObject Errors

Discussion in 'ASP .Net Security' started by Tony, Nov 3, 2005.

  1. Tony

    Tony Guest

    I am trying (unsuccessfully) to open a file using fso_OpenTextFile. I have
    given Full Trust to the assembly in Code Groups and Assembly Trust. I have
    added IUSR and IWAM as users. I have checked and double checked every
    permission available. I continue to get a Security Exception error off of
    this code:


    Dim epth As String = Server.MapPath("/error/errlog.log")
    Dim fso As New Scripting.FileSystemObject

    fso = Server.CreateObject("Scripting.FileSystemObject")
    f = fso_OpenTextFile(epth, IOMode.ForAppending, True)
    f.WriteLine("[" & DateString & "][" & TimeString & "] Module
    'hs.aspx::page_Load::General', " & "Error " & Err.Number & ": " &
    Err.Description)
    f.Close()
    Server.Transfer("/hsp/error/100.htm")

    The error I get is this:

    System.Security.SecurityException: Exception from HRESULT: 0x800A0046
    (CTL_E_PERMISSIONDENIED).
     
    Tony, Nov 3, 2005
    #1
    1. Advertising

  2. Tony

    Ken Schaefer Guest

    Are you running on Windows 2000/XP or Windows 2003 Server

    By defaut, on Windows 2000/XP, ASP.NET pages run in the aspnet_wp.exe
    process, and the process identity for tha process is Machine\ASPNET

    On Windows 2003 Server, ASP.NET pages run in w3wp.exe process, and the
    default process identity is NT Authority\Network Service.

    You will need to give the appropriate account read/write NTFS permissions to
    that file.

    If you are using other accounts, or are impersonating, then please provide
    details of your current configuration in that respect.

    A troubleshooting tool you can use is Filemon from www.sysinternals.com,
    which will tell you what account is being denied access to what.

    Cheers
    Ken

    "Tony" <> wrote in message
    news:...
    :I am trying (unsuccessfully) to open a file using fso_OpenTextFile. I have
    : given Full Trust to the assembly in Code Groups and Assembly Trust. I have
    : added IUSR and IWAM as users. I have checked and double checked every
    : permission available. I continue to get a Security Exception error off of
    : this code:
    :
    :
    : Dim epth As String = Server.MapPath("/error/errlog.log")
    : Dim fso As New Scripting.FileSystemObject
    :
    : fso = Server.CreateObject("Scripting.FileSystemObject")
    : f = fso_OpenTextFile(epth, IOMode.ForAppending, True)
    : f.WriteLine("[" & DateString & "][" & TimeString & "] Module
    : 'hs.aspx::page_Load::General', " & "Error " & Err.Number & ": " &
    : Err.Description)
    : f.Close()
    : Server.Transfer("/hsp/error/100.htm")
    :
    : The error I get is this:
    :
    : System.Security.SecurityException: Exception from HRESULT: 0x800A0046
    : (CTL_E_PERMISSIONDENIED).
     
    Ken Schaefer, Nov 4, 2005
    #2
    1. Advertising

  3. Tony

    Guest

    I am actually having a very similiar issue:
    Any thoughts would be helpful:

    Here's the scenerio:

    HAD: Entire Windows 2000 domain multiple servers
    Internal Web Server - Windows 2000
    NAS Server - Windows 2000

    Internal Web Application (On Web server) utilizing ASP scripts to
    access shared directories through mapped drives on NAS Server. (And
    yes, I know UNC paths should have been used, but I didn't actually
    write this, just trying to follow someone else)

    UPGRADED: All servers (including Web Server) except NAS Server to
    Windows 2003 Server.
    NAS Server remained on W2K Server.

    PROBLEM: For some reason when ASP scripts are ran on the web server
    (2003) they cannot access data on the NAS server (2000). However, they
    have no problem accessing local data. ;-/

    What special permissions have to be setup on either the 2003 and/or
    2000 server to allow access to shared directories via an ASP script.

    I'm at the end of my rope on this one, I have researched IIS 5.0 Worker
    Process Isolation Mode, which we were in, and I have tried to switch
    out of and still no luck. I have checked and re-checked all the NTFS
    permissions on the NAS server shared directory and everything that I
    believe is supposed to be there is allowed modify access.


    OTHER NOTE: It looks like most of the scripts are utilizing one of our
    "IUSR_" accounts in the directory security within IIS 6.0 and I have
    double-checked the password is correct and that this user is a member
    of the IIS_WPG group who incidentally also has NTFS permissions to this
    share.

    Here is an exact example:

    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html;
    charset=iso-8859-1">
    </head>
    <body>
    <%
    Set
    fso=Server.CreateObject("Scripting.FileSystemObject")
    if fso.fileExists("C:\rt.txt") then
    CFile = "C:\rt.txt file found"
    else
    CFile = "C:\rt.txt file not found"
    end if


    if fso.fileExists("E:\rt.txt") then
    EFile = "E:\rt.txt file found"
    else
    EFile = "E:\rt.txt file not found"
    end if


    if fso.fileExists("D:\rt.txt") then
    DFile = "D:\rt.txt file found"
    else
    DFile = "D:\rt.txt file not found"
    end if
    Set fso = nothing
    %>
    This is to verify whether the file can be found on the particluar
    drive<br><%=CFile%><br><%=DFile%><br><%=EFile%>
    </body>
    </html>


    C & E are local drives where this rt.txt file is located and the
    scripti finds them fine.
    D is a mapped network drive on a windows 2000 server and even though
    the file is there, the script displays the "File Not Found" message
    indicating to me that it must not have permission or something.
     
    , Dec 1, 2005
    #3
  4. Tony

    JR Guest

    I am actually having a very similiar issue:
    Any thoughts would be helpful:

    Here's the scenerio:

    HAD: Entire Windows 2000 domain multiple servers
    Internal Web Server - Windows 2000
    NAS Server - Windows 2000

    Internal Web Application (On Web server) utilizing ASP scripts to
    access shared directories through mapped drives on NAS Server. (And
    yes, I know UNC paths should have been used, but I didn't actually
    write this, just trying to follow someone else)

    UPGRADED: All servers (including Web Server) except NAS Server to
    Windows 2003 Server.
    NAS Server remained on W2K Server.

    PROBLEM: For some reason when ASP scripts are ran on the web server
    (2003) they cannot access data on the NAS server (2000). However, they
    have no problem accessing local data. ;-/

    What special permissions have to be setup on either the 2003 and/or
    2000 server to allow access to shared directories via an ASP script.

    I'm at the end of my rope on this one, I have researched IIS 5.0 Worker
    Process Isolation Mode, which we were in, and I have tried to switch
    out of and still no luck. I have checked and re-checked all the NTFS
    permissions on the NAS server shared directory and everything that I
    believe is supposed to be there is allowed modify access.


    OTHER NOTE: It looks like most of the scripts are utilizing one of our
    "IUSR_" accounts in the directory security within IIS 6.0 and I have
    double-checked the password is correct and that this user is a member
    of the IIS_WPG group who incidentally also has NTFS permissions to this
    share.

    Here is an exact example:

    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html;
    charset=iso-8859-1">
    </head>
    <body>
    <%
    Set
    fso=Server.CreateObject("Scripting.FileSystemObject")
    if fso.fileExists("C:\rt.txt") then
    CFile = "C:\rt.txt file found"
    else
    CFile = "C:\rt.txt file not found"
    end if


    if fso.fileExists("E:\rt.txt") then
    EFile = "E:\rt.txt file found"
    else
    EFile = "E:\rt.txt file not found"
    end if


    if fso.fileExists("D:\rt.txt") then
    DFile = "D:\rt.txt file found"
    else
    DFile = "D:\rt.txt file not found"
    end if
    Set fso = nothing
    %>
    This is to verify whether the file can be found on the particluar
    drive<br><%=CFile%><br><%=DFile%><br><%=EFile%>
    </body>
    </html>


    C & E are local drives where this rt.txt file is located and the
    scripti finds them fine.
    D is a mapped network drive on a windows 2000 server and even though
    the file is there, the script displays the "File Not Found" message
    indicating to me that it must not have permission or something.
     
    JR, Dec 1, 2005
    #4
    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. Pedro Bautista
    Replies:
    0
    Views:
    542
    Pedro Bautista
    Aug 29, 2003
  2. Mark Goldin

    Errors, errors, errors

    Mark Goldin, Jan 17, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    986
    Mark Goldin
    Jan 17, 2004
  3. =?Utf-8?B?UGF0cmljay5PLklnZQ==?=

    FileSystemObject Question

    =?Utf-8?B?UGF0cmljay5PLklnZQ==?=, Nov 22, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    2,710
    =?Utf-8?B?UGF0cmljay5PLklnZQ==?=
    Nov 22, 2004
  4. =?Utf-8?B?a2VybWl0?=

    Script w/ FileSystemObject, error creating object

    =?Utf-8?B?a2VybWl0?=, Apr 22, 2005, in forum: ASP .Net
    Replies:
    8
    Views:
    5,184
    =?Utf-8?B?a2VybWl0?=
    Apr 24, 2005
  5. =?Utf-8?B?VG9ueQ==?=

    FileSystemObject Errors

    =?Utf-8?B?VG9ueQ==?=, Nov 3, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    5,611
    Kevin Spencer
    Nov 4, 2005
Loading...

Share This Page