I have a simple test script that attempts to create a file and to append an existing file. This is a web-based script hosted by IIS.

When I call this script by putting its URL into a browser running on my PC, the tests pass: one file is created, the other file is appended to. However, if I run a browser on the application server and access the script using a "localhost" URL, I get a permission denied error on both file operations.

If I run the script from the command line on the server, either as an elevated (Run as Administrator) command line or not, the script is able to write to both files

The script is running under IIS's CGI module, not FastCGI, with the Impersonate User option enabled. The site uses Windows Authentication. In both cases, regardless of which browser I use to run the script, I see that the perl.exe process is running as my domain user. I can't figure out why I get different behavior when access the script from a browser running on the server versus a browser running on my own PC. Has anyone ever seen anything like this?

I used the Errno library to get some more info about the permission denied error when opening the files for write/append:

13 Permission denied
5 Access is denied
EVENT_SYSTEM_CONTEXTHELPEND
EMARCH_ENC_I17_IMM5C_INST_WORD_POS_X
EMR_SETBRUSHORGEX
EACCES
ERROR_INVALID_DATA

By the way, my specific Windows user account has explicit access to the folder I'm trying to write to.

As an experiment, I turned off Impersonate User on IIS's CGI module. The perl interpreter runs as DefaultAppPool and does have permission to write to the files.

THANK YOU

In reply to permission denied on file write only when running browser on application server by raccardi

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.