134

I am trying to get started with using IIS. I created a new site on IIS Manager, mapped it to a folder on my file system and added index.html to the folder. I have set the port to 85 for this site. When I try to access http://localhost:85/index.html, I get the following error message:

401.3 - unathorized - You do not have permission to view this directory or page because of the access control list (ACL) configuration or encryption settings for this resource on the Web server.

I gave read access to everybody on the folder and tried again. I could then access the page.

I then compared the properties of my folder with that of wwwroot. I found that wwwroot had read access on IIS_IUSRS...When I did the same on my folder and tried again, I got the above error again. I checkedthat anonymous access is enabled by default, but I still get this error.

Why does this happen? What is the correct way to resolve the problem?

Aadith Ramia
  • 10,005
  • 19
  • 67
  • 86

10 Answers10

241

I have struggled on this same issue for several days. It can be solved by modifying the security user access properties of the file system folder on which your site is mapped. But IIS_IUSRS is not the only account you must authorize.

  • In IIS management console, in the Authentication part of the configuration of your site, modify the "Anonymous authentication" line and check the account set as "Specific user" (mine is IUSR).
  • Give read and execution permission on the folder of your site to the account listed as the specific user.

OR

  • In IIS management console, in the Authentication part of the configuration of your site, modify the "Anonymous authentication" line by selecting "Identity of the application pool" instead of "Specific user".
ScottyG
  • 3,204
  • 3
  • 32
  • 42
groch
  • 3,326
  • 1
  • 21
  • 18
  • 10
    I found the anon authent with "Application Pool Identity" to work, but could not make it go with IUSR for some reason. Thanks. – fortboise Jul 09 '14 at 16:24
  • 8
    The logic behind is that by default the site uses anonymous authentication, and IUSR is the anonymous account. So IIS uses IUSR account to access the file system (web site physical path) which might not work always (as many of your file system won't accept IUSR). That's the cause of 401.3. By changing file system access (grant that account access to files) or changing anonymous account to pool identity (pool identity is in IIS_IUSRS, which usually have access to files), IIS should have enough permissions to access the files. – Lex Li Mar 20 '18 at 21:48
82

Here is what worked for me.

  1. Set the app pool identity to an account that can be assigned permissions to a folder.
  2. Ensure the source directory and all related files have been granted read rights to the files to the account assigned to the app pool identity property
  3. In IIS, at the server root node, set anonymous user to inherit from app pool identity. (This was the part I struggled with)

To set the server anonymous to inherit from the app pool identity do the following..

  • Open IIS Manager (inetmgr)
  • In the left-hand pane select the root node (server host name)
  • In the middle pane open the 'Authentication' applet
  • Highlight 'Anonymous Authentication'
  • In the right-hand pane select 'Edit...' (a dialog box should open)
  • select 'Application pool identity'
barrypicker
  • 9,740
  • 11
  • 65
  • 79
  • 11
    #3) FIXED MY ISSUE : In IIS, at the server root node, set anonymous user to inherit from app pool identity. (This was the part I struggled with) – Ravi Ram Aug 06 '16 at 18:19
  • 2
    I know you're not supposed to write "thank you" comments, but I feel like I need to express my gratitude. There is no way I would have figured this out. – Jonny Cook Aug 29 '17 at 01:58
  • @RaviRam: Please explain the steps you followed. Step by Step as a beginner. What do you mean by"n IIS, at the server root node, set anonymous user to inherit from app pool identity. " Please help. – Unbreakable Dec 20 '17 at 20:56
  • @RaviRam - run the command "inetmgr.exe" and IIS administration screen will appear. From this, follow the steps outlined in my answer. You will likely need to run the command as administrator. https://msdn.microsoft.com/en-us/library/bb763170.aspx – barrypicker Dec 21 '17 at 00:00
  • As mentioned in another answer, I found that you don't have to change the anon auth settings at the root level - you can change that setting at the site or virtual directory level too – jaycer Apr 01 '20 at 14:46
  • 1
    Another answer I wish I could upvote multiple times, due to finding this answer multiple times when I've hit the same issue multiple times (with large gaps between!) – freefaller Jul 02 '21 at 15:24
40

TL;DR;

In most cases, granting access to the following account(s) (one|both) will be enough:

  1. IIS AppPool\DefaultAppPool
  2. IUSR

with Access Rights:

  1. Read & Execute
  2. List folder contents
  3. Read

That's it!

Read on for a more detailed explanation...


  1. Open IIS and select your application.
  2. On the right side click on Authentication.
  3. Select "Anonymous authentication" here.
  4. The following dialog pops up.

enter image description here

Grant access to the web application folder's ACL depending what is selected in the pic above:

  • Specific user: grant access for both IUSR (in my case) + IIS AppPool\DefaultAppPool
  • Application pool identity: grant access for IIS AppPool\DefaultAppPool only

IIS AppPool\DefaultAppPool account is the default AppPool account for new IIS web applications, if you have set a custom account, use the custom one.


Give the following permissions to the account(s):

  1. Read & Execute
  2. List folder contents
  3. Read

enter image description here

Legends
  • 21,202
  • 16
  • 97
  • 123
18

Since you're dealing with static content...

On the folder that acts as the root of your website- if you right click > properties > security, does "Users" show up in the list? if not click "Add..." and type it in, be sure to click "Apply" when you're done.

joelmdev
  • 11,083
  • 10
  • 65
  • 89
3

Try this solution:

https://serverfault.com/questions/38222/iis-7-5-windows-7-http-error-401-3-unauthorized

Also check if the user running the IIS AppPool has read access to that folder/file.

Have a look at this:

http://www.iis.net/learn/manage/configuring-security/application-pool-identities

Also have a look at this:

http://www.iis.net/learn/get-started/planning-for-security/understanding-built-in-user-and-group-accounts-in-iis

Community
  • 1
  • 1
c-chavez
  • 7,237
  • 5
  • 35
  • 49
2
  1. Create a new Site, Right Click on Sites folder then click add Site
  2. Enter the site name.
  3. Select physical path
  4. Select Ip Address
  5. Change Port
  6. Click OK
  7. Go to Application Pools
  8. Select the site pool
  9. Right-click the click Advance Settings
  10. Change the .Net CLR Version to "No Manage Code"
  11. Change the Identity to "ApplicationPoolIdentity"
  12. Go to Site home page then click "Authentication"
  13. Right-click to AnonymousAuthentication then click "Edit"
  14. Select Application Pool Identity
  15. Click ok
  16. boom!

for routes add a web.config

<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="React Routes" stopProcessing="true">
                    <match url=".*" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                        <add input="{REQUEST_URI}" pattern="^/(api)" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="/" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>
1

Just in case anyone else runs into this. I troubleshooted all of these steps and it turns out because I unzipped some files from a MAC, Microsoft automatically without any notification Encrypted the files. After hours of trying to set folder permissions I went in and saw the file names were green which means the files were encrypted and IIS will throw the same error even if folder permissions are correct.

Joe
  • 234
  • 5
  • 18
  • Spent way too much time on this exact same issue. Simply here to commiserate. I ended up here searching for IIS and access to EFS, but your answer clued me into the root cause of my issue - an expanded zip file from a Mac. My particular scenario was an issue where ASP.NET Core hosted in process on IIS wouldn't launch - no event log messages, no stdout logs, etc. Accessing via localhost gave an error message that web.config was invalid but showed no source. Obviously file was accessible, but contents couldn't be read. – Aaron May 24 '19 at 19:02
0

Another problem that may arise relating to receiving an unauthorized is related to the providers used in the authentication setting from IIS. In My case I was experience that problem If I set the Windows Authentication provider as "Negotiate". After I selected "NTLM" option the access was granted.

More Information on Authentication providers

https://learn.microsoft.com/en-us/iis/configuration/system.webserver/security/authentication/windowsauthentication/providers/

0

Please enable the following items in Windows 2012 R2

enter image description here

0

If you are working with Application Pool authentication (instead of IUSR), which you should, then this list of checks by Jean Sun is the very best I could find to deal with 401 errors in IIS:


Open IIS Manager, navigate to your website or application folder where the site is deployed to.

  1. Open Advanced Settings (it's on the right hand Actions pane).
  2. Note down the Application Pool name then close this window
  3. Double click on the Authentication icon to open the authentication settings
  4. Disable Windows Authentication
  5. Right click on Anonymous Authentication and click Edit
  6. Choose the Application pool identity radio button the click OK
  7. Select the Application Pools node from IIS manager tree on left and select the Application Pool name you noted down in step 3
  8. Right click and select Advanced Settings
  9. Expand the Process Model settings and choose ApplicationPoolIdentityfrom the "Built-in account" drop down list then click OK.
  10. Click OK again to save and dismiss the Application Pool advanced settings page
  11. Open an Administrator command line (right click on the CMD icon and select "Run As Administrator". It'll be somewhere on your start menu, probably under Accessories.
  12. Run the following command:

    icacls <path_to_site> /grant "IIS APPPOOL\<app_pool_name>"(CI)(OI)(M)
    

    For example:

    icacls C:\inetpub\wwwroot\mysite\ /grant "IIS APPPOOL\DEFAULTAPPPOOL":(CI)(OI)(M)
    

Especially steps 5. & 6. are often overlooked and rarely mentioned on the web.

Jpsy
  • 20,077
  • 7
  • 118
  • 115