Exemple #1
0
 /// <summary>
 /// Get security descriptor as a byte array
 /// </summary>
 /// <param name="security_information">What parts of the security descriptor to retrieve</param>
 /// <param name="throw_on_error">True to throw on error.</param>
 /// <return>The NT status result and security descriptor.</return>
 public NtResult <byte[]> GetSecurityDescriptorBytes(SecurityInformation security_information, bool throw_on_error)
 {
     using (var buffer = NtSecurity.GetSecurityDescriptor(Handle, security_information, throw_on_error))
     {
         return(buffer.Map(b => b.ToArray()));
     }
 }
Exemple #2
0
        /// <summary>
        /// Get the security descriptor specifying which parts to retrieve
        /// </summary>
        /// <param name="security_information">What parts of the security descriptor to retrieve</param>
        /// <param name="throw_on_error">True to throw on error.</param>
        /// <returns>The security descriptor</returns>
        public NtResult <SecurityDescriptor> GetSecurityDescriptor(SecurityInformation security_information, bool throw_on_error)
        {
            using (var buffer = NtSecurity.GetSecurityDescriptor(Handle, security_information, throw_on_error)) {
                if (!buffer.IsSuccess)
                {
                    return(buffer.Cast <SecurityDescriptor>());
                }

                return(SecurityDescriptor.Parse(buffer.Result, NtType, IsContainer, throw_on_error));
            }
        }
        /// <summary>
        /// Get security descriptor as a byte array
        /// </summary>
        /// <param name="security_information">What parts of the security descriptor to retrieve</param>
        /// <param name="throw_on_error">True to throw on error.</param>
        /// <return>The NT status result and security descriptor.</return>
        public NtResult <byte[]> GetSecurityDescriptorBytes(SecurityInformation security_information, bool throw_on_error)
        {
            // Just do a check here, no point checking if ReadControl not available.
            if (!IsAccessMaskGranted(GenericAccessRights.ReadControl))
            {
                return(NtStatus.STATUS_ACCESS_DENIED.CreateResultFromError <byte[]>(throw_on_error));
            }

            using (var buffer = NtSecurity.GetSecurityDescriptor(Handle, security_information, throw_on_error))
            {
                return(buffer.Map(b => b.ToArray()));
            }
        }