Simon
Simon

Reputation: 1333

Give IIS web application permission to access files on network drive

I have developed an Intranet web application using C# and .NET that authenticates users using Windows Authentication

One of the pages reads data from an excel file stored on a network drive and displays the information on screen. To access the area of the network drive where the excel file is stored you need to be a member of a certain active directory group.

When I run the application locally this works fine, as it will be running under my login ID which has permission to the network drive.

However when I go to the live version of the application on our web server I get

System.UnauthorizedAccessException: Access to the path '\\foo\bar.xlsx' is denied.

I guess this is because the user that IIS is using doesn't have permission to the network drive.

I have set up the application pool in IIS to use ApplicationPoolIdentity which i assume uses IIS_USRS but how do i give that permission to the network drive?

If I change the application pool in IIS to use an account that has permissions, such as my details, instead of ApplicationPoolIdentity i get the following error instead:

Service Unavailable

HTTP Error 503. The service is unavailable.

Any help is greatly appreciated.

Upvotes: 0

Views: 2257

Answers (3)

loganpixel
loganpixel

Reputation: 87

ACCESS DENIED: Same error but different scenario. Using C# .NET to access Active Directory to change passwords via System.DirectoryServices.AccountManagement. I was able to read but get the access denied trying to right back, naturally. This was because the application did not have rights to modify Active Directory. To fix this, I had to add an account in web.config that had Account Operator AD rights. Below is what I needed to add to get it to work for our situation.

<add key="adAdminUser" value="USERNAME"/>
<add key="adAdminPassword" value="PASSWORD"/>
<add key="adDomainFull" value="BLANK4US"/>

Upvotes: 0

Simon
Simon

Reputation: 1333

I fixed my issue by adding the server account to the active directory group that has permission to view the folders.

Upvotes: 0

Farzin Kanzi
Farzin Kanzi

Reputation: 3433

The .xlsx files has

application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

mime type. Go to IIS that has problem, Click on mime types button and at the table check if it has the mime type i said.

Upvotes: 0

Related Questions