Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set full control to a directory

Tags:

c#

I am using the following code to set full control

DirectorySecurity myDirectorySecurity = source.GetAccessControl();
string User = "Srinivass\\Admin";
myDirectorySecurity.AddAccessRule(new FileSystemAccessRule(
                        User,
                        FileSystemRights.Modify,
                        InheritanceFlags.ObjectInherit,
                        PropagationFlags.InheritOnly,
                        AccessControlType.Allow)
                    );

source.SetAccessControl(myDirectorySecurity);

But it is giving special permissions to this folder only. I want to give full controll permissions to all subfolders.

Please anyone can help me.

like image 272
Srinivas Sabbani Avatar asked May 09 '11 10:05

Srinivas Sabbani


People also ask

How do I chmod everything in a directory?

Changing permissions with chmod To modify the permission flags on existing files and directories, use the chmod command ("change mode"). It can be used for individual files or it can be run recursively with the -R option to change permissions for all of the subdirectories and files within a directory.

How do I give a directory full permissions in Linux?

You can set permissions like read, write, or execute the folder through the “chmod” command in a terminal. You can use the “chmod” command to modify permission settings in two different ways: Absolute Mode (numeric mode) Symbolic Mode.


1 Answers

Try changing PropagationFlags parameter to PropagationFlags.None.

Your access rule should look like:

 new FileSystemAccessRule( 
          User, 
          FileSystemRights.FullControl,
          InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit,
          PropagationFlags.None,
          AccessControlType.Allow 
  );

Then, check the Security tab in Windows Explorer, and you should see the folder (and any newly created objects going forward) having Full Control.

like image 164
Brian Chavez Avatar answered Oct 13 '22 12:10

Brian Chavez