Give specific local Windows user group full control access to a folder and its sub folders (edit)
Application Pool Identities | Microsoft Docs
https://stackoverflow.com/questions/7334216/iis7-permissions-overview-applicationpoolidentity
- IIS_IUSRS (build-in group in IIS 7.0)
- IUSR (build-in account in IIS 7.0)
- IIS AppPool\DefaultAppPool
https://docs.google.com/document/d/1gkN2Dy-sL1cx6T5l1pg9RKK0EHxtUzujSk_j-kpCrYQ
Application Pool Identities - Full Access from IIS - Web Deploy - Deployment (HAY HAY HAY HAY HAY)
using System.IO;
using System.Security.AccessControl;
namespace GiveFullPermissionToFolder
{
class Program
{
private static void Main(string[] args)
{
string path = @"C:\Deploy";
DirectoryInfo directoryInfo = new DirectoryInfo(path);
DirectorySecurity directorySecurity = directoryInfo.GetAccessControl();
//var groupName_IIS_IUSRS = Environment.MachineName + @"\IIS_IUSRS";
//var groupName = @"IIS AppPool\DefaultAppPool";
//var groupName = @".\IIS_IUSRS";
//var groupName = @".\Users";
//var groupName = @"IUSR";
//var groupName = @"Authenticated Users";
var groupNames = new[]
{
@"IIS AppPool\DefaultAppPool",
@".\IIS_IUSRS",
@".\Users",
@"IUSR",
@"Authenticated Users"
};
foreach (var groupName in groupNames)
{
directorySecurity.AddAccessRule(
new FileSystemAccessRule(groupName,
FileSystemRights.FullControl,
InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit,
PropagationFlags.None,
AccessControlType.Allow));
directoryInfo.SetAccessControl(directorySecurity);
}
System.Console.WriteLine("Done");
}
}
}
How to give full permission to a folder
using System;
using System.IO;
using System.Security.AccessControl;
namespace Secure
{
internal class Program
{
private static void Main(string[] args)
{
string path = @"D:\Samples\WebService";
DirectoryInfo directoryInfo = new DirectoryInfo(path);
DirectorySecurity directorySecurity = directoryInfo.GetAccessControl();
var groupName_IIS_IUSRS = Environment.MachineName + @"\IIS_IUSRS";
var groupName = @".\IIS_IUSRS";
directorySecurity.AddAccessRule(
new FileSystemAccessRule(groupName,
FileSystemRights.FullControl,
InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit,
PropagationFlags.None,
AccessControlType.Allow));
directoryInfo.SetAccessControl(directorySecurity);
System.Console.WriteLine("Done");
}
}
}