Assembly: mscorlib (in mscorlib.dll)
An EventWaitHandleSecurity object specifies access rights for a named system wait handle, and also specifies the way access attempts are audited. Access rights to the wait handle are expressed as rules, with each access rule represented by an EventWaitHandleAccessRule object. Each auditing rule is represented by an EventWaitHandleAuditRule object.
This mirrors the underlying Windows security system, in which each securable object has at most one discretionary access control list (DACL) that controls access to the secured object, and at most one system access control list (SACL) that specifies which access attempts are audited. The DACL and SACL are ordered lists of access control entries (ACE) that specify access and auditing for users and groups. An EventWaitHandleAccessRule or EventWaitHandleAuditRule object might represent more than one ACE.
An EventWaitHandle object can represent a local wait handle or a named system wait handle. Windows access control security is meaningful only for named system wait handles.
The EventWaitHandleSecurity, EventWaitHandleAccessRule, and EventWaitHandleAuditRule classes hide the implementation details of ACLs and ACEs. They allow you to ignore the seventeen different ACE types and the complexity of correctly maintaining inheritance and propagation of access rights. These objects are also designed to prevent the following common access control errors:
Creating a security descriptor with a null DACL. A null reference to a DACL allows any user to add access rules to an object, potentially creating a denial-of-service attack. A new EventWaitHandleSecurity object always starts with an empty DACL, which denies all access for all users.
Violating the canonical ordering of ACEs. If the ACE list in the DACL is not kept in the canonical order, users might inadvertently be given access to the secured object. For example, denied access rights must always appear before allowed access rights. EventWaitHandleSecurity objects maintain the correct order internally.
Manipulating security descriptor flags, which should be under resource manager control only.
Creating invalid combinations of ACE flags.
Manipulating inherited ACEs. Inheritance and propagation are handled by the resource manager, in response to changes you make to access and audit rules.
Inserting meaningless ACEs into ACLs.
The only capabilities not supported by the .NET security objects are dangerous activities that should be avoided by the majority of application developers, such as the following:
Low-level tasks that are normally performed by the resource manager.
Adding or removing access control entries in ways that do not maintain the canonical ordering.
To modify Windows access control security for a named wait handle, use the EventWaitHandle.GetAccessControl method to get the EventWaitHandleSecurity object. Modify the security object by adding and removing rules, and then use the EventWaitHandle.SetAccessControl method to reattach it.
Changes you make to an EventWaitHandleSecurity object do not affect the access levels of the named wait handle until you call the EventWaitHandle.SetAccessControl method to assign the altered security object to the named wait handle.
To copy access control security from one wait handle to another, use the EventWaitHandle.GetAccessControl method to get an EventWaitHandleSecurity object representing the access and audit rules for the first wait handle, and then use the EventWaitHandle.SetAccessControl method, or a constructor that accepts an EventWaitHandleSecurity object, to assign those rules to the second wait handle.
Users with an investment in the security descriptor definition language (SDDL) can use the SetSecurityDescriptorSddlForm method to set access rules for a named wait handle, and the GetSecurityDescriptorSddlForm method to obtain a string that represents the access rules in SDDL format. This is not recommended for new development.
The following code example demonstrates the separation between Allow rules and Deny rules, and shows the combination of rights in compatible rules. The example creates an EventWaitHandleSecurity object, adds rules that allow and deny various rights for the current user, and displays the resulting pair of rules. The example then allows new rights for the current user and displays the result, showing that the new rights are merged with the existing Allow rule.
This example does not attach the security object to a EventWaitHandle object. Examples that attach security objects can be found in EventWaitHandle.GetAccessControl and EventWaitHandle.SetAccessControl.
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.