SetSecurityDescriptorBinaryForm() public method

public SetSecurityDescriptorBinaryForm ( byte binaryForm ) : void
binaryForm byte
return void
Exemplo n.º 1
0
        /// <summary>Sort ACEs according to canonical form for this <see cref="ObjectSecurity"/>.</summary>
        /// <param name="objectSecurity">The object security whose DiscretionaryAcl will be made canonical.</param>
        public static void CanonicalizeAccessRules(this ObjectSecurity objectSecurity)
        {
            if (objectSecurity == null)
            {
                throw new ArgumentNullException(nameof(objectSecurity));
            }
            if (objectSecurity.AreAccessRulesCanonical)
            {
                return;
            }

            // Get raw SD from objectSecurity and canonicalize DACL
            var sd = new RawSecurityDescriptor(objectSecurity.GetSecurityDescriptorBinaryForm(), 0);

            sd.DiscretionaryAcl.Canonicalize();

            // Convert SD back into objectSecurity
            objectSecurity.SetSecurityDescriptorBinaryForm(sd.GetBinaryForm());
        }