Пример #1
0
        /// <summary>
        /// Convert a security descriptor to SDDL string
        /// </summary>
        /// <param name="sd">The security descriptor</param>
        /// <param name="security_information">Indicates what parts of the security descriptor to include</param>
        /// <returns>The SDDL string</returns>
        /// <exception cref="NtException">Thrown if cannot convert to a SDDL string.</exception>
        public static string SecurityDescriptorToSddl(byte[] sd, SecurityInformation security_information)
        {
            if (!Win32NativeMethods.ConvertSecurityDescriptorToStringSecurityDescriptor(sd,
                                                                                        1, security_information, out SafeLocalAllocHandle handle, out int return_length))
            {
                throw new NtException(NtObjectUtils.MapDosErrorToStatus());
            }

            using (handle)
            {
                return(Marshal.PtrToStringUni(handle.DangerousGetHandle()));
            }
        }