示例#1
0
 /// <summary>
 /// Set the global SACL.
 /// </summary>
 /// <param name="type">The global SACL type.</param>
 /// <param name="security_descriptor">The SACL to set in an Security Descriptor.</param>
 /// <param name="throw_on_error">True to throw on error.</param>
 /// <returns>The NT status code.</returns>
 public static NtStatus SetGlobalSacl(AuditGlobalSaclType type, SecurityDescriptor security_descriptor, bool throw_on_error)
 {
     if (!security_descriptor.SaclPresent)
     {
         throw new ArgumentException("Must specify a SACL.");
     }
     using (var buffer = security_descriptor.Sacl.ToSafeBuffer()) {
         if (!SecurityNativeMethods.AuditSetGlobalSacl(type.ToString(), buffer))
         {
             return(NtObjectUtils.MapDosErrorToStatus().ToNtException(throw_on_error));
         }
         return(NtStatus.STATUS_SUCCESS);
     }
 }
示例#2
0
 /// <summary>
 /// Query the global SACL.
 /// </summary>
 /// <param name="type">The global SACL type.</param>
 /// <param name="throw_on_error">True to throw on error.</param>
 /// <returns>The global SACL in a Security Descriptor.</returns>
 public static NtResult <SecurityDescriptor> QueryGlobalSacl(AuditGlobalSaclType type, bool throw_on_error)
 {
     if (!SecurityNativeMethods.AuditQueryGlobalSacl(type.ToString(), out SafeAuditBuffer buffer))
     {
         return(NtObjectUtils.MapDosErrorToStatus().CreateResultFromError <SecurityDescriptor>(throw_on_error));
     }
     using (buffer) {
         NtType nt_type = type == AuditGlobalSaclType.File ? NtType.GetTypeByType <NtFile>() : NtType.GetTypeByType <NtKey>();
         return(new SecurityDescriptor(nt_type)
         {
             Sacl = new Acl(buffer.DangerousGetHandle(), false)
         }.CreateResult());
     }
 }
 /// <summary>
 /// Set the global SACL.
 /// </summary>
 /// <param name="type">The global SACL type.</param>
 /// <param name="security_descriptor">The SACL to set in an Security Descriptor.</param>
 /// <returns>The NT status code.</returns>
 public static void SetGlobalSacl(AuditGlobalSaclType type, SecurityDescriptor security_descriptor)
 {
     SetGlobalSacl(type, security_descriptor, true);
 }
 /// <summary>
 /// Query the global SACL.
 /// </summary>
 /// <param name="type">The global SACL type.</param>
 /// <returns>The global SACL in a Security Descriptor.</returns>
 public static SecurityDescriptor QueryGlobalSacl(AuditGlobalSaclType type)
 {
     return(QueryGlobalSacl(type, true).Result);
 }