yyykk
yyykk

Reputation: 51

IIS service is running as Local System account, so how do I give it shared directory permissions?

My ASP page reads a file from a shared directory and sends it to the user.

        Response.Clear();
        Response.ContentType = "application/octet-stream";
        Response.AddHeader("Content-Disposition:", string.Format("attachment; filename={0}", fileName));
        Response.WriteFile(filePath);
        Response.End();

This ASP code runs on the web server, I suppose it is running as Local System account because IIS is. filePath points to a file on the file server \\fileserver\shared\abc.pdf

When I debug the code on my local machine, the file is read correctly from ASP page. However when I run it on the web server, it can not read the file. What permission do I need to give \fileserver\shared so that the ASP page will correctly read the file? Obviously Local System is not a valid user logon in the permission page.

Upvotes: 0

Views: 4604

Answers (2)

Scoregraphic
Scoregraphic

Reputation: 7200

You may try to impersonate with a user allowed to access the share. Add this in your web.config:

<identity impersonate="true" userName="accountname" password="password" />

Upvotes: 0

blowdart
blowdart

Reputation: 56540

IIS by default runs it's application pools as "Network Service". This is a local account on the IIS box. If you want to access a network share then you need to reconfigure the application pool identity to an account with has access to the share, for example a domain account.

If both boxes are not in a domain then you can create a username and password on both machines (identical on both machines) and use that for the application pool, setting the permissions on the share to allow access by that (local) user on the fileserver

Upvotes: 1

Related Questions