@manhng

Welcome to my blog!

Give specific local Windows user group full control access to a folder and its sub folders (IIS_IUSRS + IUSR)

September 6, 2020 23:07

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/48075130/give-specific-local-windows-user-group-read-access-to-a-folder-and-its-subfolder

https://stackoverflow.com/questions/7334216/iis7-permissions-overview-applicationpoolidentity

https://docs.microsoft.com/en-us/iis/manage/powershell/powershell-snap-in-creating-web-sites-web-applications-virtual-directories-and-application-pools

https://docs.microsoft.com/en-us/iis/get-started/planning-for-security/understanding-built-in-user-and-group-accounts-in-iis

  • 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");
}
}
}

IIS Create Application and Set Application Pool (C#)

September 12, 2018 11:48

IIS - Create Application and Set Application Pool (C#) (edit)

Chú ý:

+ Mở Visual Studio 2017 với quyền Administrator

+ Cài đặt Web Management Tools

Input

+ Tên Root Application: MyAppPool

+ Tên Application: MyApp

+ Tên Customer: 4000

Output

+ Tạo Application nếu chưa tồn tại.

+ Sử dụng XCopy để copy toàn bộ files từ một nguồn cho trước đến Physical Path của Application vừa tạo.

+ Hoặc Unzip từ một nguồn là 1 file .zip cho trước.

+ Set ApplicationPool trùng với ApplicationPool của Root Application.

Tham khảo

Sử dụng thư viện Microsoft.Web.Administration.dll

Sử dụng thư viện System.IO.Compression.dllSystem.IO.Compression.FileSystem.dll

1) https://forums.iis.net/t/1207235.aspx?How+to+convert+a+physical+folder+into+an+Asp+NET+Application+using+Microsoft+Web+Administration+C+API

2) https://stackoverflow.com/questions/3228813/how-to-get-websites-physical-path-on-local-iis-server-from-a-desktop-app

3) http://www.anotherchris.net/csharp/6-ways-to-get-the-current-directory-in-csharp/

4) https://dailydotnettips.com/different-ways-of-getting-path/

5) https://www.c-sharpcorner.com/UploadFile/jawedmd/xcopy-using-C-Sharp-to-copy-filesfolders/

6) https://stackoverflow.com/questions/32236796/fastest-way-to-copy-files-from-one-directory-to-another (có sử dụng dữ liệu trong Database và Sql Server Connection)

https://www.c-sharpcorner.com/UploadFile/satisharveti/programmatically-create-iis-website-and-application-pool-usi/

https://stackoverflow.com/questions/16417578/iis-application-creation-by-using-microsoft-web-administration-library-creates-t

https://www.c-sharpcorner.com/UploadFile/225740/introduction-to-application-pool-in-iis/

https://stackoverflow.com/questions/12147721/change-apppool-of-application-programatically

Categories

Recent posts