/// <summary> /// Get the security descriptor for a named resource. /// </summary> /// <param name="name">The name of the resource.</param> /// <param name="type">The type of the resource.</param> /// <param name="security_information">The security information to get.</param> /// <param name="throw_on_error">True to throw on error.</param> /// <returns>The security descriptor.</returns> public static NtResult <SecurityDescriptor> GetSecurityInfo( string name, SeObjectType type, SecurityInformation security_information, bool throw_on_error) { using (var result = Win32NativeMethods.GetNamedSecurityInfo(name, type, security_information, null, null, null, null, out SafeLocalAllocBuffer sd).MapDosErrorToStatus().CreateResult(throw_on_error, () => sd)) { if (!result.IsSuccess) { return(result.Cast <SecurityDescriptor>()); } return(SecurityDescriptor.Parse(result.Result, GetNativeType(type), throw_on_error)); } }