156

I've just moved away from IIS6 on Win2003 to IIS8 on Win2012 for hosting ASP.NET applications.

Within one particular folder in my application I need to Create & Delete files. After copying the files to the new server, I kept seeing the following errors when I tried to delete files:

Access to the path 'D:\WebSites\myapp.co.uk\companydata\filename.pdf' is denied.

When I check IIS I see that the application is running under the DefaultAppPool account, however, I never set up Windows permissions on this folder to include IIS AppPool\DefaultAppPool

Instead, to stop screaming customers I granted the following permissions on the folder:

IUSR

  • Read & Execute
  • List Folder Contents
  • Read
  • Write

IIS_IUSRS

  • Modify
  • Read & Execute
  • List Folder Contents
  • Read
  • Write

This seems to have worked, but I am concerned that too many privileges have been set. I've read conflicting information online about whether IUSR is actually needed at all here. Can anyone clarify which users/permissions would suffice to Create and Delete documents on this folder please? Also, is IUSR part of the IIS_IUSRS group?

Update & Solution

Please see my answer below. I've had to do this sadly as some recent suggestions were not well thought out, or even safe (IMO).

Community
  • 1
  • 1
EvilDr
  • 7,561
  • 10
  • 60
  • 114
  • To get WordPress working on IIS 8 on an Azure virtual machine (Windows Server 2012 Datacenter) I needed to grant the permissions you have listed for IIS_IUSRS to IUSR for the blog directory in inetpub/wwwroot – dumbledad Dec 20 '13 at 15:51
  • For those who come to this thread because they're trying to run Joomla under IIS and are having problems with the file security settings, I've written a blog article with what I think is the proper solution. Probably also applicable to WordPress or other PHP-based web server programs. http://renniestechblog.com/index.php/information/15-joomla-on-iis-part-7-preparing-for-a-new-website – RenniePet May 10 '17 at 13:28
  • Possible duplicate of [IIS AppPoolIdentity and file system write access permissions](https://stackoverflow.com/questions/5437723/iis-apppoolidentity-and-file-system-write-access-permissions) – KyleMit Oct 24 '17 at 18:44
  • Working fine after adding full permission for folder for user group IIS_IUSRS. – Thulasiram Aug 20 '19 at 10:22
  • @Thulasiram but then you've given full privileges to all IIS Users. Think about that from a hacker's perspective. One weak site and they gain total control of all the rest – EvilDr Aug 21 '19 at 21:56
  • @EvilDr Thanks for Information we are changing the permission now... :) – Thulasiram Aug 22 '19 at 06:30

6 Answers6

160

I hate to post my own answer, but some answers recently have ignored the solution I posted in my own question, suggesting approaches that are nothing short of foolhardy.

In short - you do not need to edit any Windows user account privileges at all. Doing so only introduces risk. The process is entirely managed in IIS using inherited privileges.

Applying Modify/Write Permissions to the Correct User Account

  1. Right-click the domain when it appears under the Sites list, and choose Edit Permissions

    enter image description here

    Under the Security tab, you will see MACHINE_NAME\IIS_IUSRS is listed. This means that IIS automatically has read-only permission on the directory (e.g. to run ASP.Net in the site). You do not need to edit this entry.

    enter image description here

  2. Click the Edit button, then Add...

  3. In the text box, type IIS AppPool\MyApplicationPoolName, substituting MyApplicationPoolName with your domain name or whatever application pool is accessing your site, e.g. IIS AppPool\mydomain.com

    enter image description here

  4. Press the Check Names button. The text you typed will transform (notice the underline):

    enter image description here

  5. Press OK to add the user

  6. With the new user (your domain) selected, now you can safely provide any Modify or Write permissions

    enter image description here

EvilDr
  • 7,561
  • 10
  • 60
  • 114
  • 1
    perfect answer. In step 2 I saw that IIS_IUSRS did not have read permission, adding that permission immediately fixed my problem. – Hammad Khan Jun 18 '16 at 22:40
  • 2
    This did not work on my IIS 8.5 server. Adding `IUSR` works. Adding `IIS AppPool\Cache` (the name of my application pool) yields `HTTP Error 401.3 - Unauthorized` – Charles Burns Jul 22 '16 at 21:10
  • 16
    @CharlesBurns I had the same issue, I found this to be my root cause: https://techras.wordpress.com/2016/03/09/error-message-401-3-you-do-not-have-permission-to-view-this-directory-or-page-using-the-credentials-you-supplied-access-denied-due-to-access-control-lists/ (anonymous auth was set to use IUSR instead of Application Pool Identity) – Jon Nov 07 '16 at 15:41
  • 2
    I had a folder used only as a Virtual Directory and it worked fine up until I shared it (the windows folder it pointed to) with another domain account, so it could view the files over our intranet. When I did this, the files in the Virtual Directory suddenly became unreachable. I ended up having to add both `MyComputerName\IIS_IUSRS` and `IUSR` with Read only permissions for it to work again. This is just for Virtual Directories (not .net Apps), but figure someone may find it useful. – MikeTeeVee Apr 10 '17 at 04:34
  • 1
    So so so so Thank's ! I search on the all web, various soluctions, but the true soluction, the simple soluction was show by @Jon. I try execute exec() in cmd an external program, but because this propriety of IIS 8 we not can run. But, now, i search que corret question. – Maicon Herverton May 05 '17 at 12:54
  • @MaiconHerverton - you're welcome. Glad you got it working :-) – EvilDr May 05 '17 at 12:57
  • 20
    Just a note: When you search for the user and the computer is a member of a domain, the IIS AppPool\MyApplicationPoolName may not be found. In my case, I needed to click the Locations button and change the location to the local computer. – statler Aug 09 '17 at 10:04
  • Can confirm, statler is correct; when operating on a domain, you must change the location to be the local machine first. – PeterFnet Oct 13 '17 at 00:20
  • 3
    In my tests the name of the special user to use here has nothing to do with a domain name. It is the name of the Application Pool that is assigned to the site in IIS. This Application Pool may or may not have a name that matches the domain of your website. So the pattern is: `IIS AppPool\[APPLICATION POOL NAME]`. Blanks in the Application Pool name are accepted. Please also note that this user will only be found, if "Built-in security principals" is checked as an object type for the name search (top field in the "Select Users or Groups" dialog). – Jpsy Jun 28 '18 at 08:31
  • Hi. I tried your solution but when I try to add IIS App Pool\App pool name gives me this : An object named "IIS AppPool\Default Web Site" cannot be found. Check the selected object types and location for accuracy and ensure that you typed the object name correctly, or remove this object from the selection. I replicated each step as mentioned in your answer , but still it wont work? – Anita Mathew Feb 23 '19 at 07:06
  • Exactly what I needed. And I love the choice of title "Applying Modify/Write Permissions to the Correct User Account" -- leaving no doubt. But like @Jon I also had to make sure anonymous auth was set to run as application pool identity. – Carnot Antonio Romero Feb 27 '19 at 19:24
  • You could also add a comment about the AppPoolIdentity being set as the Identity for the corresponding application pool (for that domain). – Mladen B. Jun 26 '19 at 09:34
50

IUSR is part of IIS_IUSER group.so i guess you can remove the permissions for IUSR without worrying. Further Reading

However, a problem arose over time as more and more Windows system services started to run as NETWORKSERVICE. This is because services running as NETWORKSERVICE can tamper with other services that run under the same identity. Because IIS worker processes run third-party code by default (Classic ASP, ASP.NET, PHP code), it was time to isolate IIS worker processes from other Windows system services and run IIS worker processes under unique identities. The Windows operating system provides a feature called "Virtual Accounts" that allows IIS to create unique identities for each of its Application Pools. DefaultAppPool is the by default pool that is assigned to all Application Pool you create.

To make it more secure you can change the IIS DefaultAppPool Identity to ApplicationPoolIdentity.

Regarding permission, Create and Delete summarizes all the rights that can be given. So whatever you have assigned to the IIS_USERS group is that they will require. Nothing more, nothing less.

hope this helps.

Travis G
  • 1,534
  • 1
  • 13
  • 18
  • 3
    I just installed IIS 8 under Server Essentials 2012 R2. This machine is also a domain controller. In AD Users and Computers, the IIS_IUSRS group is empty--it does not contain the IUSR user. I suppose I could add it to the group, but for anonymous sites, I'll just grant permissions to the IUSR user. – Mark Berry Nov 17 '13 at 03:38
  • 7
    When I granted permissions for IUSR it worked. When I granted permissions to IIS_IUSER it did not work. – ihebiheb Jan 22 '14 at 15:34
  • Iusr is not a member of IIS_Iusrs. (or windows have a bug) Generally, Windows uses IIS_Iusrs. (executing dynamic pages or accessing static pages) but there is some cases when windows uses Iusr, not IIS_Iusrs. file upload using PHP is one of that case. (and if you granted iis_iusr only, you will meet privilege exception) I think M$ should give "A best-practice" for granting permssion of Iusr and IIS_Iusrs... – finejustice Jan 12 '15 at 17:14
  • I think now its changed to Application pool group i.e (IWGP) . I gave permissions to IWGP and it worked . – Rohit Arora May 28 '15 at 18:09
  • 7
    IUSR is part of IIS_IUSER. NO IT IS NOT! IUSR is the anonimous user, IIS_IUSER is the group for apppool users – giammin Jul 24 '15 at 08:20
  • Hell no this is not true – ihebiheb Aug 24 '17 at 08:39
6

When I added IIS_IUSRS permission to site folder - resources, like js and css, still were unaccessible (error 401, forbidden). However, when I added IUSR - it became ok. So for sure "you CANNOT remove the permissions for IUSR without worrying", dear @Travis G@

Alexander
  • 739
  • 11
  • 15
  • 7
    Don't forget that (if you have IIS7+) the correct solution is to use `IIS AppPool\MyApplicationPoolName` as per my updated answer. You don't need to mess about with IUSR(S) any more! – EvilDr Jul 11 '14 at 15:13
  • 2
    I've tried your suggestion, but it does not work. I have removed IUSR(S) from permission and remained only the poolname, app is running under. Resources became unaccessible. IIS 8.5. When I added IUSR - it got working. – Alexander Jul 15 '14 at 17:16
  • You need to post your own question with as much information about your situation please. – EvilDr Feb 24 '19 at 18:59
  • @EvilDRr dotNet code will run as the application pool user (if that's what the identity of the appPool has been configured to use). Otherwise, anonymous requests to (static) resources such as images will be handled via the anonymous authentication of which IUSR is the default identity. – xorinzor Feb 12 '21 at 13:33
4

@EvilDr You can create an IUSR_[identifier] account within your AD environment and let the particular application pool run under that IUSR_[identifier] account:

"Application pool" > "Advanced Settings" > "Identity" > "Custom account"

Set your website to "Applicaton user (pass-through authentication)" and not "Specific user", in the Advanced Settings.

Now give that IUSR_[identifier] the appropriate NTFS permissions on files and folders, for example: modify on companydata.

Jan Reilink
  • 438
  • 4
  • 12
  • Thanks but I'm not using AD. Also according to recent MS documentation, IIS 7&8 are already configured to work as you describe. The question really is whether one of the specified accounts is actually needed or not, and which one does the business? – EvilDr Feb 21 '13 at 16:27
  • @EvilDr Thanks for clarifying you are not using an AD. Well, IIS_IUSRS is not a user, it's a group. Like IIS_WPG on IIS 6.0. You can read about IIS_IUSRS and IUSR here: [link](http://www.iis.net/learn/get-started/planning-for-security/understanding-built-in-user-and-group-accounts-in-iis). You can set modify permissions on companydata\* for the IUSR account and you can add this user to the IIS_IUSRS group and use that useraccount to run your application pool under. You only need to grand permissions for IIS_IUSRS on shared folders (TMP for instance), if you have multiple IUSR_accounts. – Jan Reilink Feb 22 '13 at 06:57
  • Jan, I always thought that IUSR was part of the IIS_IUSRS group by default? How can you check if this is so, as the IUSR account is a built-in account. Are you saying that I should uncheck Modify for IIS_USRS and check it for IUSR instead? Given the single-application requirement I don't think it will really make a difference will it? – EvilDr Feb 25 '13 at 10:14
4

IIS_IUSRS group has prominence only if you are using ApplicationPool Identity. Even though you have this group looks empty at run time IIS adds to this group to run a worker process according to microsoft literature.

Ashburn RK
  • 402
  • 3
  • 8
  • Not sure why this was downvoted. https://docs.microsoft.com/en-us/iis/get-started/planning-for-security/understanding-built-in-user-and-group-accounts-in-iis#understanding-the-new-iisiusrs-group – Greg Mar 22 '18 at 18:59
0

I would use specific user (and NOT Application user). Then I will enable impersonation in the application. Once you do that whatever account is set as the specific user, those credentials would used to access local resources on that server (Not for external resources).

Specific User setting is specifically meant for accessing local resources.

developer747
  • 13,032
  • 22
  • 78
  • 136