Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. Permissions and Permission Propogation

Permissions and Permission Propogation

Scheduled Pinned Locked Moved .NET (Core and Framework)
questioncsharpwindows-adminsecurityhelp
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tristan Rhodes
    wrote on last edited by
    #1

    Hi Guys, Scenario: I have a .Net app that creates a new User and then assigns full read / write permissions for that user to the application Program Files and application HKLM Registry section. The application then runs under the current user and impersonates the authorised user to modify the appropriate sections when nescessary. The permissions assignment is assigned with the following code:

            //Registry - Propogated Rule
            RegistryAccessRule rule = new RegistryAccessRule(LOGON\_USER\_NAME, RegistryRights.FullControl, InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.InheritOnly, AccessControlType.Allow); 
            RegistrySecurity security = new RegistrySecurity();
            security.AddAccessRule(rule);
    
            //Create Test Sub Key in Registry with permissions for the MicaUser
            RegistryKey root = Registry.LocalMachine.CreateSubKey(SUB\_KEY\_ROOT, RegistryKeyPermissionCheck.ReadWriteSubTree);
            root.SetAccessControl(security);
    
    
            //File System - Propogated Rule
            FileSystemAccessRule rule = new FileSystemAccessRule(LOGON\_USER\_NAME, FileSystemRights.FullControl, InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.InheritOnly, AccessControlType.Allow);
            DirectorySecurity security = new DirectorySecurity();
            security.SetAccessRule(rule);
    
            //Create Test Directory in Program Files with permissions for the MicaUser
            Directory.CreateDirectory(dir);
            Directory.SetAccessControl(dir, security);
    

    Problem: When i check the registry / directory, i have full permissions for any existing folders / subkeys below the dir / subkey Root, but not for the root itself. i.e. HKLM\Software\MyApp\TestKey I Assign the permisssions to MyApp, then my User has full permissions on TestKey, but i am unable to create SubKeys in MyApp, nor delete the TestKey SubKey, nor set values in MyApp. This also applies to the ACL permissions on folders. My question is - how do i setup both propogating privelages, and full read / write permissions on the root item? Regards Tristan

    ------------------------------- Carrier Bags - 21st Century Tumbleweed.

    T 1 Reply Last reply
    0
    • T Tristan Rhodes

      Hi Guys, Scenario: I have a .Net app that creates a new User and then assigns full read / write permissions for that user to the application Program Files and application HKLM Registry section. The application then runs under the current user and impersonates the authorised user to modify the appropriate sections when nescessary. The permissions assignment is assigned with the following code:

              //Registry - Propogated Rule
              RegistryAccessRule rule = new RegistryAccessRule(LOGON\_USER\_NAME, RegistryRights.FullControl, InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.InheritOnly, AccessControlType.Allow); 
              RegistrySecurity security = new RegistrySecurity();
              security.AddAccessRule(rule);
      
              //Create Test Sub Key in Registry with permissions for the MicaUser
              RegistryKey root = Registry.LocalMachine.CreateSubKey(SUB\_KEY\_ROOT, RegistryKeyPermissionCheck.ReadWriteSubTree);
              root.SetAccessControl(security);
      
      
              //File System - Propogated Rule
              FileSystemAccessRule rule = new FileSystemAccessRule(LOGON\_USER\_NAME, FileSystemRights.FullControl, InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.InheritOnly, AccessControlType.Allow);
              DirectorySecurity security = new DirectorySecurity();
              security.SetAccessRule(rule);
      
              //Create Test Directory in Program Files with permissions for the MicaUser
              Directory.CreateDirectory(dir);
              Directory.SetAccessControl(dir, security);
      

      Problem: When i check the registry / directory, i have full permissions for any existing folders / subkeys below the dir / subkey Root, but not for the root itself. i.e. HKLM\Software\MyApp\TestKey I Assign the permisssions to MyApp, then my User has full permissions on TestKey, but i am unable to create SubKeys in MyApp, nor delete the TestKey SubKey, nor set values in MyApp. This also applies to the ACL permissions on folders. My question is - how do i setup both propogating privelages, and full read / write permissions on the root item? Regards Tristan

      ------------------------------- Carrier Bags - 21st Century Tumbleweed.

      T Offline
      T Offline
      Tristan Rhodes
      wrote on last edited by
      #2

      I have managed to open up the Registry sub key root by adding two seperate permissions:

         RegistrySecurity security = new RegistrySecurity();
              
              //Non Propogated Rule
              RegistryAccessRule rule = new RegistryAccessRule(LOGON\_USER\_NAME, RegistryRights.FullControl,InheritanceFlags.None, PropagationFlags.None, AccessControlType.Allow);
              security.AddAccessRule(rule);
              
              //Propogated Rule
              rule = new RegistryAccessRule(LOGON\_USER\_NAME, RegistryRights.FullControl, InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.InheritOnly, AccessControlType.Allow); 
              security.AddAccessRule(rule);
      

      This works for the registry, but not for the directory permissions. Any thoughts? Regards Tris

      ------------------------------- Carrier Bags - 21st Century Tumbleweed.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups