[英]How to get access control of C:\Windows\System32\inetsrv\config folder using c# asp.net
I am trying to give permission to C:\\Windows\\System32\\inetsrv\\config folder. 我正在尝试授予C:\\ Windows \\ System32 \\ inetsrv \\ config文件夹的权限。 But when I use the below code it throws exception "Attempted to perform an unauthorized operation."
但是,当我使用以下代码时,它将引发异常“尝试执行未经授权的操作”。
string desktopFolderPath = @"C:\Windows\System32\inetsrv\config";
FileSystemAccessRule iis_iusrs = new FileSystemAccessRule("IIS_IUSRS",
FileSystemRights.FullControl,
InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit,
PropagationFlags.None,
AccessControlType.Allow);
FileSystemAccessRule networkService = new FileSystemAccessRule("NETWORK SERVICE",
FileSystemRights.FullControl,
InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit,
PropagationFlags.None,
AccessControlType.Allow);
System.IO.DirectoryInfo desktopFolderDirectory = new System.IO.DirectoryInfo(desktopFolderPath);
DirectorySecurity directorySecurity = null;
directorySecurity = desktopFolderDirectory.GetAccessControl(); -- **Exception**
directorySecurity.AddAccessRule(iis_iusrs);
directorySecurity.AddAccessRule(networkService);
desktopFolderDirectory.SetAccessControl(directorySecurity);
Please help if anyone can. 如果有人可以,请帮忙。 Thanks in advance.
提前致谢。
Go to the folder path Properties
and make sure it Read-only check box is unchecked. 转到文件夹路径“
Properties
,并确保未选中“只读”复选框。
This may be of some help: link
这可能会有所帮助: 链接
If it doesn't, then try sharing the folder.
如果没有,请尝试共享文件夹。
By the way it is a system folder, It may not be accessible, so try hosting pages in
C:\\inetpub
顺便说一句,它是系统文件夹,可能无法访问,因此请尝试在
C:\\inetpub
托管页面
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.