Exemple #1
0
        private static Int32 SetSecurity(
            IntPtr FileSystemPtr,
            ref FullContext FullContext,
            UInt32 SecurityInformation,
            IntPtr ModificationDescriptor)
        {
            FileSystemBase FileSystem = (FileSystemBase)Api.GetUserContext(FileSystemPtr);

            try
            {
                Object FileNode, FileDesc;
                AccessControlSections Sections;
                Api.GetFullContext(ref FullContext, out FileNode, out FileDesc);
                Sections = AccessControlSections.None;
                if (0 != (SecurityInformation & 1 /*OWNER_SECURITY_INFORMATION*/))
                {
                    Sections |= AccessControlSections.Owner;
                }
                if (0 != (SecurityInformation & 2 /*GROUP_SECURITY_INFORMATION*/))
                {
                    Sections |= AccessControlSections.Group;
                }
                if (0 != (SecurityInformation & 4 /*DACL_SECURITY_INFORMATION*/))
                {
                    Sections |= AccessControlSections.Access;
                }
                if (0 != (SecurityInformation & 8 /*SACL_SECURITY_INFORMATION*/))
                {
                    Sections |= AccessControlSections.Audit;
                }
                return(FileSystem.SetSecurity(
                           FileNode,
                           FileDesc,
                           Sections,
                           Api.MakeSecurityDescriptor(ModificationDescriptor)));
            }
            catch (Exception ex)
            {
                return(ExceptionHandler(FileSystem, ex));
            }
        }