Mutex.GetAccessControl Method ()

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Gets a MutexSecurity object that represents the access control security for the named mutex.

Namespace:   System.Threading
Assembly:  mscorlib (in mscorlib.dll)

member GetAccessControl : unit -> MutexSecurity

Return Value

Type: System.Security.AccessControl.MutexSecurity

A MutexSecurity object that represents the access control security for the named mutex.

Exception Condition
UnauthorizedAccessException

The current Mutex object represents a named system mutex, but the user does not have MutexRights.ReadPermissions.

-or-

The current Mutex object represents a named system mutex, and was not opened with MutexRights.ReadPermissions.

NotSupportedException

Not supported for Windows 98 or Windows Millennium Edition.

The GetAccessControl method uses the following combination of flags (combined using the bitwise OR operation) to search for permissions: AccessControlSections.Access, AccessControlSections.Owner, and AccessControlSections.Group.

The user must have MutexRights.ReadPermissions to call this method, and the mutex must have been opened with MutexRights.ReadPermissions.

The following code example demonstrates the cross-process behavior of a named mutex with access control security. The example uses the OpenExisting(String) method overload to test for the existence of a named mutex.

If the mutex does not exist, it is created with initial ownership and access control security that denies the current user the right to use the mutex, but grants the right to read and change permissions on the mutex.

If you run the compiled example from two command windows, the second copy will throw an access violation exception on the call to OpenExisting(String). The exception is caught, and the example uses the OpenExisting(String, MutexRights) method overload to open the mutex with the rights needed to read and change the permissions, using the GetAccessControl and SetAccessControl methods.

After the permissions are changed, the mutex is opened with the rights required to enter and release it. If you run the compiled example from a third command window, it runs using the new permissions.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 2.0
Return to top
Show: