private ProgressInvokeSetting ProgressFunction(
            string object_name, Win32Error status, ProgressInvokeSetting invoke_setting, bool security_set)
        {
            if (Stopping)
            {
                return(ProgressInvokeSetting.CancelOperation);
            }

            if (ErrorOnly && status == Win32Error.SUCCESS)
            {
                return(invoke_setting);
            }

            if (ShowProgress)
            {
                ProgressRecord progress = new ProgressRecord(0, "Resetting Security", object_name);
                WriteProgress(progress);
            }

            if (PassThru)
            {
                WriteObject(new Win32SetSecurityDescriptorResult(object_name, status, security_set));
            }

            return(invoke_setting);
        }
 /// <summary>
 /// Set security using a named object.
 /// </summary>
 /// <param name="name">The name of the object.</param>
 /// <param name="type">The type of named object.</param>
 /// <param name="security_information">The security information to set.</param>
 /// <param name="security_descriptor">The security descriptor to set.</param>
 /// <param name="invoke_setting">Specify to indicate when to execute progress function.</param>
 /// <param name="action">The security operation to perform on the tree.</param>
 /// <param name="progress_function">Progress function.</param>
 public static void SetSecurityInfo(string name, SeObjectType type,
                                    SecurityInformation security_information,
                                    SecurityDescriptor security_descriptor,
                                    TreeSecInfo action,
                                    TreeProgressFunction progress_function,
                                    ProgressInvokeSetting invoke_setting
                                    )
 {
     SetSecurityInfo(name, type, security_information, security_descriptor, action, progress_function, invoke_setting, true);
 }
        /// <summary>
        /// Reset security using a named object.
        /// </summary>
        /// <param name="name">The name of the object.</param>
        /// <param name="type">The type of named object.</param>
        /// <param name="security_information">The security information to set.</param>
        /// <param name="security_descriptor">The security descriptor to set.</param>
        /// <param name="keep_explicit">True to keep explicit ACEs.</param>
        /// <param name="invoke_setting">Specify to indicate when to execute progress function.</param>

        /// <param name="progress_function">Progress function.</param>
        public static void ResetSecurityInfo(string name, SeObjectType type,
                                             SecurityInformation security_information,
                                             SecurityDescriptor security_descriptor,
                                             TreeProgressFunction progress_function,
                                             ProgressInvokeSetting invoke_setting,
                                             bool keep_explicit
                                             )
        {
            ResetSecurityInfo(name, type, security_information, security_descriptor,
                              progress_function, invoke_setting, keep_explicit, true);
        }
Exemple #4
0
 internal static extern Win32Error TreeResetNamedSecurityInfo(
     string pObjectName,
     SeObjectType ObjectType,
     SecurityInformation SecurityInfo,
     byte[] psidOwner,
     byte[] psidGroup,
     byte[] pDacl,
     byte[] pSacl,
     [MarshalAs(UnmanagedType.Bool)] bool KeepExplicit,
     TreeSetNamedSecurityProgress fnProgress,
     ProgressInvokeSetting ProgressInvokeSetting,
     IntPtr Args
     );
Exemple #5
0
 internal static extern Win32Error TreeSetNamedSecurityInfo(
     string pObjectName,
     SeObjectType ObjectType,
     SecurityInformation SecurityInfo,
     byte[] psidOwner,
     byte[] psidGroup,
     byte[] pDacl,
     byte[] pSacl,
     TreeSecInfo dwAction,
     TreeSetNamedSecurityProgress fnProgress,
     ProgressInvokeSetting ProgressInvokeSetting,
     IntPtr Args
     );
 /// <summary>
 /// Reset security using a named object.
 /// </summary>
 /// <param name="name">The name of the object.</param>
 /// <param name="type">The type of named object.</param>
 /// <param name="security_information">The security information to set.</param>
 /// <param name="security_descriptor">The security descriptor to set.</param>
 /// <param name="invoke_setting">Specify to indicate when to execute progress function.</param>
 /// <param name="keep_explicit">True to keep explicit ACEs.</param>
 /// <param name="progress_function">Progress function.</param>
 /// <param name="throw_on_error">True to throw on error.</param>
 /// <returns>The NT status code.</returns>
 public static NtStatus ResetSecurityInfo(string name, SeObjectType type,
                                          SecurityInformation security_information,
                                          SecurityDescriptor security_descriptor,
                                          TreeProgressFunction progress_function,
                                          ProgressInvokeSetting invoke_setting,
                                          bool keep_explicit,
                                          bool throw_on_error)
 {
     return(Win32NativeMethods.TreeResetNamedSecurityInfo(
                name, type, security_information,
                security_descriptor.Owner?.Sid.ToArray(),
                security_descriptor.Group?.Sid.ToArray(),
                security_descriptor.Dacl?.ToByteArray(),
                security_descriptor.Sacl?.ToByteArray(),
                keep_explicit,
                CreateCallback(progress_function),
                invoke_setting,
                IntPtr.Zero
                ).ToNtException(throw_on_error));
 }