Home All Groups Group Topic Archive Search About

Security settings for Folder

Author
19 Jun 2006 8:55 PM
Tinu
Hi,

I am using below code to give access to a user but when I check in explorer
only "Special Permission' is checked instead of "FullControl"?




DirectoryInfo di = Directory.CreateDirectory("C:\\zDeleteMe");

DirectorySecurity dSecurity = di.GetAccessControl();

// Add the FileSystemAccessRule to the security settings.

dSecurity.AddAccessRule(new FileSystemAccessRule("MyDomain\\Myuser",

FileSystemRights.FullControl, AccessControlType.Allow));

// Set the new access settings.

di.SetAccessControl(dSecurity);


Thanks,

Author
21 Jun 2006 10:32 AM
Nicole Calinoiu
You need to specify the inheritance options when creating the access rule.
e.g.:

dSecurity.AddAccessRule(new FileSystemAccessRule("MyDomain\\Myuser",
    FileSystemRights.FullControl,
    InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit,
    PropagationFlags.None,
    AccessControlType.Allow));


Show quoteHide quote
"Tinu" <dhir***@icode.com> wrote in message
news:OvmfoK%23kGHA.4660@TK2MSFTNGP05.phx.gbl...
> Hi,
>
> I am using below code to give access to a user but when I check in
> explorer only "Special Permission' is checked instead of "FullControl"?
>
>
>
>
> DirectoryInfo di = Directory.CreateDirectory("C:\\zDeleteMe");
>
> DirectorySecurity dSecurity = di.GetAccessControl();
>
> // Add the FileSystemAccessRule to the security settings.
>
> dSecurity.AddAccessRule(new FileSystemAccessRule("MyDomain\\Myuser",
>
> FileSystemRights.FullControl, AccessControlType.Allow));
>
> // Set the new access settings.
>
> di.SetAccessControl(dSecurity);
>
>
> Thanks,
>
>
>
>
>