title: How to get access control of C:\Windows\System32\inetsrv\config folder using c# asp.net
body: <p>I am trying to give permission to C:\Windows\System32\inetsrv\config folder. But when I use the below code it throws exception "Attempted to perform an unauthorized operation." </p>
  
  <pre><code> 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);
  </code></pre>
  
  <p>Please help if anyone can. Thanks in advance.</p>