views:

437

answers:

2

I have a WCF web service that I am hosting in IIS (actually running within the Visual Studio web host i.e. Cassini).

I have a file that I have to access in the root of the web directory from the service, and am having trouble figuring out the user identity that the service accesses the directory as. I've given permission to ASPNET, NETWORK SERVICE, and IUSR, but none of these seem to work.

Anyone know what the user is that a WCF service runs as when it's hosted within IIS?

MORE INFO:

Indeed, the WCF service is running as me (my windows account), but for whatever reason, it still cannot open a file in its root directory. The file failed with "Access is Denied". I've given "Everyone" Full Control of the folder, and it doesn't seem to matter.

A: 

If you are running yr serive using Cassini then its going to be the user who is logged into that computer. So probably your username that u have used to login to that machine. Give that user the permission to read the file and try it.

On IIS it depends on your application configuration. You can create app pool under any user account and have yr application running using that pool. Default user in IIS is NETWORK SERVICES.

Lav
Hmmm...both of those users have complete permissions to the directory, but it still doesn't work. Maybe I'm missing something...
Sam Schutte
A: 

Alright...figured out the issue. Turns out the file I was trying to open was marked as read-only, so .NET couldn't open it for writing. Passed FileAccess.Read to the File.Open() method, and now it opens fine.

Unrelated to WCF itself.

Sam Schutte