See Also: MutexSecurity Members
A System.Security.AccessControl.MutexSecurity object specifies access rights for a named system mutex, and also specifies how access attempts are audited. Access rights to the mutex are expressed as rules, with each access rule represented by a System.Security.AccessControl.MutexAccessRule object. Each auditing rule is represented by a System.Security.AccessControl.MutexAuditRule 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. A System.Security.AccessControl.MutexAccessRule or System.Security.AccessControl.MutexAuditRule object might represent more than one ACE.
A System.Threading.Mutex object can represent a local mutex or a named system mutex. Windows access control security is meaningful only for named system mutexes.
The System.Security.AccessControl.MutexSecurity, System.Security.AccessControl.MutexAccessRule, and System.Security.AccessControl.MutexAuditRule 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 System.Security.AccessControl.MutexSecurity 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. System.Security.AccessControl.MutexSecurity 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 mutex, use the System.Threading.Mutex.GetAccessControl method to get the System.Security.AccessControl.MutexSecurity object. Modify the security object by adding and removing rules, and then use the System.Threading.Mutex.SetAccessControl(MutexSecurity) method to reattach it.
Changes you make to a System.Security.AccessControl.MutexSecurity object do not affect the access levels of the named mutex until you call the System.Threading.Mutex.SetAccessControl(MutexSecurity) method to assign the altered security object to the named mutex.
To copy access control security from one mutex to another, use the System.Threading.Mutex.GetAccessControl method to get a System.Security.AccessControl.MutexSecurity object representing the access and audit rules for the first mutex, and then use the System.Threading.Mutex.SetAccessControl(MutexSecurity) method, or a constructor that accepts a System.Security.AccessControl.MutexSecurity object, to assign those rules to the second mutex.
Users with an investment in the security descriptor definition language (SDDL) can use the ObjectSecurity.SetSecurityDescriptorSddlForm(string) method to set access rules for a named mutex, and the ObjectSecurity.GetSecurityDescriptorSddlForm(AccessControlSections) method to obtain a string that represents the access rules in SDDL format. This is not recommended for new development.
Security on synchronization objects is not supported for Windows 98 or Windows Millennium Edition.