Leer en inglés

Compartir a través de


EventWaitHandleRights Enumeración

Definición

Especifica los derechos de control de acceso que se pueden aplicar a los objetos de evento de sistema con nombre.

Esta enumeración admite una combinación bit a bit de sus valores de miembro.

C#
[System.Flags]
public enum EventWaitHandleRights
C#
[System.Flags]
[System.Security.SecurityCritical]
public enum EventWaitHandleRights
Herencia
EventWaitHandleRights
Atributos

Campos

Nombre Valor Description
ChangePermissions 262144

Derecho a cambiar la seguridad y las reglas de auditoría asociadas a un evento con nombre.

Delete 65536

Derecho a eliminar un evento con nombre.

FullControl 2031619

Derecho a ejercer el control completo sobre un evento con nombre y a modificar sus reglas de acceso y de auditoría.

Modify 2

El derecho a establecer o restablecer el estado señalado de un evento con nombre.

ReadPermissions 131072

Derecho a abrir y copiar las reglas de acceso y de auditoría para un evento con nombre.

Synchronize 1048576

Derecho a esperar en un evento con nombre.

TakeOwnership 524288

Derecho a cambiar el propietario de un evento con nombre.

Ejemplos

En el ejemplo de código siguiente se muestra el uso de EventWaitHandleRights valores al crear y usar EventWaitHandleAccessRule objetos . En el ejemplo se crea un EventWaitHandleSecurity objeto , se agregan reglas que permiten y deniegan varios derechos para el usuario actual y se muestra el par resultante de reglas. A continuación, el ejemplo permite nuevos derechos para el usuario actual y muestra el resultado, lo que muestra que los nuevos derechos se combinan con la regla existente AccessControlType.Allow .

Nota

En este ejemplo no se adjunta el objeto de seguridad a un EventWaitHandle objeto; vea EventWaitHandleSecurity, EventWaitHandle.GetAccessControl método y EventWaitHandle.SetAccessControl.

C#
using System;
using System.Threading;
using System.Security.AccessControl;
using System.Security.Principal;

public class Example
{
    public static void Main()
    {
        // Create a string representing the current user.
        string user = Environment.UserDomainName + "\\" + 
            Environment.UserName;

        // Create a security object that grants no access.
        EventWaitHandleSecurity mSec = new EventWaitHandleSecurity();

        // Add a rule that grants the current user the 
        // right to wait on or signal the event.
        EventWaitHandleAccessRule rule = new EventWaitHandleAccessRule(user, 
            EventWaitHandleRights.Synchronize | EventWaitHandleRights.Modify, 
            AccessControlType.Allow);
        mSec.AddAccessRule(rule);

        // Add a rule that denies the current user the 
        // right to change permissions on the event.
        rule = new EventWaitHandleAccessRule(user, 
            EventWaitHandleRights.ChangePermissions, 
            AccessControlType.Deny);
        mSec.AddAccessRule(rule);

        // Display the rules in the security object.
        ShowSecurity(mSec);

        // Add a rule that allows the current user the 
        // right to read permissions on the event. This rule
        // is merged with the existing Allow rule.
        rule = new EventWaitHandleAccessRule(user, 
            EventWaitHandleRights.ReadPermissions, 
            AccessControlType.Allow);
        mSec.AddAccessRule(rule);

        ShowSecurity(mSec);
    }

    private static void ShowSecurity(EventWaitHandleSecurity security)
    {
        Console.WriteLine("\r\nCurrent access rules:\r\n");

        foreach(EventWaitHandleAccessRule ar in 
            security.GetAccessRules(true, true, typeof(NTAccount)))
        {
            Console.WriteLine("        User: {0}", ar.IdentityReference);
            Console.WriteLine("        Type: {0}", ar.AccessControlType);
            Console.WriteLine("      Rights: {0}", ar.EventWaitHandleRights);
            Console.WriteLine();
        }
    }
}

/*This code example produces output similar to following:

Current access rules:

        User: TestDomain\TestUser
        Type: Deny
      Rights: ChangePermissions

        User: TestDomain\TestUser
        Type: Allow
      Rights: Modify, Synchronize


Current access rules:

        User: TestDomain\TestUser
        Type: Deny
      Rights: ChangePermissions

        User: TestDomain\TestUser
        Type: Allow
      Rights: Modify, ReadPermissions, Synchronize
 */

Comentarios

Use la EventWaitHandleRights enumeración para especificar derechos de control de acceso al crear EventWaitHandleAccessRule objetos. Para aplicar derechos de acceso a un evento del sistema con nombre, primero agregue EventWaitHandleAccessRule objetos a un EventWaitHandleSecurity objeto y, a continuación, adjunte el EventWaitHandleSecurity objeto al evento del sistema con nombre mediante el EventWaitHandle.EventWaitHandle(Boolean, EventResetMode, String, Boolean, EventWaitHandleSecurity) constructor o el EventWaitHandle.SetAccessControl método .

Se aplica a

Producto Versiones
.NET Core 1.0, Core 1.1, 6, 7, 8, 9
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

Consulte también