Re: Access Denied

From: Peter Bromberg [C# MVP] (pbromberg_at_yahoo.com)
Date: 09/11/04


Date: Fri, 10 Sep 2004 20:35:54 -0400

The account that your WebService is running under does not have write
permissions. You have basically two choices:

1) Determine the account (ASPNET, IUSR_<YourMachineName> ) that the service
is running under and grant it modify permissions on the folder where you
need to write your log. (you may need to do this both in IIS and for the
physical file folder with ACL's as well)
2) Try changing your -processModel "userName" attribute in machine.config
file from "machine" to "system". Note that this option is the "brute force"
approach and can have security consequences.
--Peter
"Marathoner" <Marathoner@discussions.microsoft.com> wrote in message
news:125493F7-E737-42B0-9433-CF5EFF9B123C@microsoft.com...
>I have written a Web Service in C# that attempts to log error information
>on
> our Web Server. The code below sets the path where the error information
> is
> to be written:
>
> string sFilePath = Server.MapPath("XML/");
> ExceptionManager.Publi***(sStartElement,sFilePath,
> sLog,sKey,sStoredProc,oParms);
>
> I am calling a procedure that writes the data out to an XML file on the
> server. I get an Access Denied error when I try to run this line of code:
>
> StreamWriter sw = new StreamWriter (sFileName, false, Encoding.UTF8);
>
> This codes works when I am writing error data to a directory on a user's
> local machine but when I use the Web Service to log the error, an access
> denied error occurrs.
>
> How can I overcome this security issue on a Web Server so that I can write
> to a file?
> --
> Robert Hill
> Senior Programmer/Analyst
> Wake Forest Univ Baptist Med Ctr


Quantcast