public string GetSddlForm(AccessControlSections sections)
        {
            StringBuilder result = new StringBuilder();

            if (Owner != null && sections.HasFlag(AccessControlSections.Owner))
            {
                result.AppendFormat(CultureInfo.InvariantCulture, "O:{0}", Owner.Value.GetSddlForm());
            }

            if (Group != null && sections.HasFlag(AccessControlSections.Group))
            {
                result.AppendFormat(CultureInfo.InvariantCulture, "G:{0}", Group.Value.GetSddlForm());
            }

            if (sections.HasFlag(AccessControlSections.Access) && this.controlFlags.HasFlag(SECURITY_DESCRIPTOR_Control.DACLPresent))
            {
                result.AppendFormat(CultureInfo.InvariantCulture, "D:{0}", dacl.GetSddlForm(controlFlags, true));
            }

            if (sections.HasFlag(AccessControlSections.Audit) && this.controlFlags.HasFlag(SECURITY_DESCRIPTOR_Control.SACLPresent))
            {
                result.AppendFormat(CultureInfo.InvariantCulture, "S:{0}", sacl.GetSddlForm(controlFlags, false));
            }

            return(result.ToString());
        }
Ejemplo n.º 2
0
        public NtStatus GetFileSecurity(string fileName, out FileSystemSecurity security, AccessControlSections sections, DokanFileInfo info)
        {
            Log.Trace(fileName);

            var identity = WindowsIdentity.GetCurrent().Owner;
            FileSystemSecurity result = info.IsDirectory
                ? (FileSystemSecurity) new DirectorySecurity()
                : (FileSystemSecurity) new FileSecurity();

            if (sections.HasFlag(AccessControlSections.Access))
            {
                result.SetAccessRule(new FileSystemAccessRule(identity, FileSystemRights.FullControl, AccessControlType.Allow));
                result.SetAccessRuleProtection(false, true);
            }

            if (sections.HasFlag(AccessControlSections.Owner))
            {
                result.SetOwner(identity);
            }

            security = result;
            return(DokanResult.Success);
        }