Home All Groups Group Topic Archive Search About

Allow inheritable permissions form the parent to propagate...

Author
18 May 2005 3:22 PM
Mark A. Richman
How do I turn this flag on from C#? I need to ensure files created in
the directory inherit that directory's ACL.

I am currently setting permissions like this:

ActiveDs.SecurityDescriptor sd = null;
ActiveDs.AccessControlEntryClass ace = null;

ADsSecurityUtilityClass asu = new ADsSecurityUtilityClass();
asu.SecurityMask = (int)(ADS_SECURITY_INFO_ENUM.ADS_SECURITY_INFO_OWNER
| ADS_SECURITY_INFO_ENUM.ADS_SECURITY_INFO_DACL);
sd = asu.GetSecurityDescriptor(folder,
(int)ADS_PATHTYPE_ENUM.ADS_PATH_FILE,
(int)ADS_SD_FORMAT_ENUM.ADS_SD_FORMAT_IID) as
ActiveDs.SecurityDescriptor;

AccessControlList dacl = sd.DiscretionaryAcl as AccessControlList;

if(dacl != null)
{
    ace = new AccessControlEntryClass();
    ace.Trustee = sid;
    ace.AccessMask = (int)perm; //  FILE_ALL_ACCESS, FILE_GENERIC_READ,
etc. from winnt.h
    ace.AceType = (int)ADS_ACETYPE_ENUM.ADS_ACETYPE_ACCESS_ALLOWED;
    ace.AceFlags = 3; // This value (0x3) is undocumented in Iads.h, but
it works...go figure.
    dacl.AddAce(ace);
    sd.DiscretionaryAcl = dacl;

    asu.SetSecurityDescriptor(folder,
(int)ADS_PATHTYPE_ENUM.ADS_PATH_FILE, sd,
(int)ADS_SD_FORMAT_ENUM.ADS_SD_FORMAT_IID);
}
return;

Thanks,
Mark

Author
19 May 2005 11:46 AM
Nicole Calinoiu
Given that the sample code you posted appears to be using types that are not
present in any available version of the .NET Framework, it's a wee bit
difficult to suggest a way to use these types to accomplish any goal. <g>
Are you using a publicly available helper library and, if so, where did you
get it?


Show quoteHide quote
"Mark A. Richman" <markarich***@gmail.com> wrote in message
news:1116429762.426088.115750@g47g2000cwa.googlegroups.com...
> How do I turn this flag on from C#? I need to ensure files created in
> the directory inherit that directory's ACL.
>
> I am currently setting permissions like this:
>
> ActiveDs.SecurityDescriptor sd = null;
> ActiveDs.AccessControlEntryClass ace = null;
>
> ADsSecurityUtilityClass asu = new ADsSecurityUtilityClass();
> asu.SecurityMask = (int)(ADS_SECURITY_INFO_ENUM.ADS_SECURITY_INFO_OWNER
> | ADS_SECURITY_INFO_ENUM.ADS_SECURITY_INFO_DACL);
> sd = asu.GetSecurityDescriptor(folder,
> (int)ADS_PATHTYPE_ENUM.ADS_PATH_FILE,
> (int)ADS_SD_FORMAT_ENUM.ADS_SD_FORMAT_IID) as
> ActiveDs.SecurityDescriptor;
>
> AccessControlList dacl = sd.DiscretionaryAcl as AccessControlList;
>
> if(dacl != null)
> {
> ace = new AccessControlEntryClass();
> ace.Trustee = sid;
> ace.AccessMask = (int)perm; //  FILE_ALL_ACCESS, FILE_GENERIC_READ,
> etc. from winnt.h
> ace.AceType = (int)ADS_ACETYPE_ENUM.ADS_ACETYPE_ACCESS_ALLOWED;
> ace.AceFlags = 3; // This value (0x3) is undocumented in Iads.h, but
> it works...go figure.
> dacl.AddAce(ace);
> sd.DiscretionaryAcl = dacl;
>
> asu.SetSecurityDescriptor(folder,
> (int)ADS_PATHTYPE_ENUM.ADS_PATH_FILE, sd,
> (int)ADS_SD_FORMAT_ENUM.ADS_SD_FORMAT_IID);
> }
> return;
>
> Thanks,
> Mark
>