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. C#
  4. Directory Security

Directory Security

Scheduled Pinned Locked Moved C#
questionsecurity
2 Posts 2 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.
  • Z Offline
    Z Offline
    ziwez0
    wrote on last edited by
    #1

    Hi guys im creating a folder then adding a user with permissions to that folder but how do I then set this security permission to apply to this folder, sub folders and files within this folder? currently it just applys to this folder only.(so when the app creates a file within this folder the file does not inherit the permission's from the folder)

    DirectorySecurity dirSec = Directory.GetAccessControl(_dbPath);
    dirSec.AddAccessRule(new FileSystemAccessRule("Everyone", FileSystemRights.Write, AccessControlType.Allow));
    dirSec.AddAccessRule(new FileSystemAccessRule("Everyone", FileSystemRights.ReadAndExecute, AccessControlType.Allow));
    dirSec.AddAccessRule(new FileSystemAccessRule("Everyone", FileSystemRights.CreateFiles, AccessControlType.Allow));
    dirSec.AddAccessRule(new FileSystemAccessRule(IdentityReference, FileSystemRights.WriteData,InheritanceLevel,PropagationFlags., AccessControlType.Allow));
    Directory.SetAccessControl(_dbPath, dirSec);

    S 1 Reply Last reply
    0
    • Z ziwez0

      Hi guys im creating a folder then adding a user with permissions to that folder but how do I then set this security permission to apply to this folder, sub folders and files within this folder? currently it just applys to this folder only.(so when the app creates a file within this folder the file does not inherit the permission's from the folder)

      DirectorySecurity dirSec = Directory.GetAccessControl(_dbPath);
      dirSec.AddAccessRule(new FileSystemAccessRule("Everyone", FileSystemRights.Write, AccessControlType.Allow));
      dirSec.AddAccessRule(new FileSystemAccessRule("Everyone", FileSystemRights.ReadAndExecute, AccessControlType.Allow));
      dirSec.AddAccessRule(new FileSystemAccessRule("Everyone", FileSystemRights.CreateFiles, AccessControlType.Allow));
      dirSec.AddAccessRule(new FileSystemAccessRule(IdentityReference, FileSystemRights.WriteData,InheritanceLevel,PropagationFlags., AccessControlType.Allow));
      Directory.SetAccessControl(_dbPath, dirSec);

      S Offline
      S Offline
      Saksida Bojan
      wrote on last edited by
      #2

      try this:

      dirSec.AddAccessRule(new FileSystemAccessRule(IdentityReference, FileSystemRights.WriteData,
      InheritanceFlags.ObjectInherit, PropagationFlags.InheritOnly, AccessControlType.Allow));

      Edit: Splitted message, because it isn't rendered correctly

      modified on Saturday, November 28, 2009 5:23 AM

      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