Здравствуйте, Sinix, Вы писали:
S>К сожалению, в .Net нет метода GetEffectivePermissions и гугл не знает о готовых решениях.
Может Вы имели в виду GetEffectiveRightsFromAcl? То есть типа этого?
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct Trustee
{
public IntPtr pMultipleTrustee;
public int MultipleTrusteeOperation;
public int TrusteeForm;
public int TrusteeType;
[MarshalAs(UnmanagedType.LPTStr)]
public string name;
}
[DllImport("advapi32.dll", CharSet = CharSet.Unicode)]
internal static extern int GetEffectiveRightsFromAclW(
byte[] pAcl, ref Trustee pTrustee, out uint pAccessMask);
FileSecurity fss = new FileSecurity(
"SomeFile.bin", AccessControlSections.Access);
byte[] rawsd = fss.GetSecurityDescriptorBinaryForm();
CommonSecurityDescriptor csd
= new CommonSecurityDescriptor(true, false, rawsd, 0);
int aclLen = csd.DiscretionaryAcl.BinaryLength;
byte[] rawAcl = new byte[aclLen];
csd.DiscretionaryAcl.GetBinaryForm(rawAcl, 0);
uint mask;
Trustee trustee = new Trustee();
trustee.TrusteeForm = 1;
trustee.TrusteeType = 1;
trustee.name = "SomeUser";
int result = GetEffectiveRightsFromAclW(rawAcl, ref trustee, out mask);
if (result == 0)
Console.WriteLine((FileSystemRights)mask);
else
Console.WriteLine("Error: {0}", result);