Share via


MutexAccessRule 클래스

정의

사용자 또는 그룹에 대해 허용 또는 거부된 액세스 권한 집합을 나타냅니다. 이 클래스는 상속될 수 없습니다.

public ref class MutexAccessRule sealed : System::Security::AccessControl::AccessRule
public sealed class MutexAccessRule : System.Security.AccessControl.AccessRule
[System.Security.SecurityCritical]
public sealed class MutexAccessRule : System.Security.AccessControl.AccessRule
type MutexAccessRule = class
    inherit AccessRule
[<System.Security.SecurityCritical>]
type MutexAccessRule = class
    inherit AccessRule
Public NotInheritable Class MutexAccessRule
Inherits AccessRule
상속
특성

예제

다음 코드 예제에서는 개체를 만들고 사용하는 방법을 MutexAccessRule 보여 줍니다. 이 예제에서는 개체를 MutexSecurity 만들고, 현재 사용자에 대한 다양한 권한을 허용 및 거부하는 규칙을 추가하고, 결과 규칙 쌍을 표시합니다. 그런 다음 현재 사용자에 대한 새 권한을 허용하고 결과를 표시하여 새 권한이 기존 규칙과 병합됨을 보여 줍니다 Allow .

참고

이 예제에서는 보안 개체를 개체에 Mutex 연결하지 않습니다. 보안 개체를 연결하는 예제는 및 Mutex.SetAccessControl에서 Mutex.GetAccessControl 찾을 수 있습니다.

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.
        MutexSecurity mSec = new MutexSecurity();

        // Add a rule that grants the current user the 
        // right to enter or release the mutex.
        MutexAccessRule rule = new MutexAccessRule(user, 
            MutexRights.Synchronize | MutexRights.Modify, 
            AccessControlType.Allow);
        mSec.AddAccessRule(rule);

        // Add a rule that denies the current user the 
        // right to change permissions on the mutex.
        rule = new MutexAccessRule(user, 
            MutexRights.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 mutex. This rule
        // is merged with the existing Allow rule.
        rule = new MutexAccessRule(user, 
            MutexRights.ReadPermissions, 
            AccessControlType.Allow);
        mSec.AddAccessRule(rule);

        ShowSecurity(mSec);
    }

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

        foreach(MutexAccessRule 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.MutexRights);
            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
 */
Imports System.Threading
Imports System.Security.AccessControl
Imports System.Security.Principal

Public Class Example

    Public Shared Sub Main()

        ' Create a string representing the current user.
        Dim user As String = Environment.UserDomainName _ 
            & "\" & Environment.UserName

        ' Create a security object that grants no access.
        Dim mSec As New MutexSecurity()

        ' Add a rule that grants the current user the 
        ' right to enter or release the mutex.
        Dim rule As New MutexAccessRule(user, _
            MutexRights.Synchronize _
            Or MutexRights.Modify, _
            AccessControlType.Allow)
        mSec.AddAccessRule(rule)

        ' Add a rule that denies the current user the 
        ' right to change permissions on the mutex.
        rule = New MutexAccessRule(user, _
            MutexRights.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 mutex. This rule
        ' is merged with the existing Allow rule.
        rule = New MutexAccessRule(user, _
            MutexRights.ReadPermissions, _
            AccessControlType.Allow)
        mSec.AddAccessRule(rule)

        ShowSecurity(mSec)

    End Sub 

    Private Shared Sub ShowSecurity(ByVal security As MutexSecurity)
        Console.WriteLine(vbCrLf & "Current access rules:" & vbCrLf)

        For Each ar As MutexAccessRule In _
            security.GetAccessRules(True, True, GetType(NTAccount))

            Console.WriteLine("        User: {0}", ar.IdentityReference)
            Console.WriteLine("        Type: {0}", ar.AccessControlType)
            Console.WriteLine("      Rights: {0}", ar.MutexRights)
            Console.WriteLine()
        Next

    End Sub
End Class 

'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

설명

클래스는 MutexAccessRule 명명된 시스템 뮤텍스에서 Windows 액세스 제어 보안을 관리하기 위해 .NET Framework 제공하는 클래스 집합 중 하나입니다. 이러한 클래스의 개요 및 기본 Windows 액세스 제어 구조와의 관계는 를 참조하세요 MutexSecurity.

참고

Windows 액세스 제어 보안은 명명된 시스템 뮤텍스에만 의미가 있습니다. 개체가 Mutex 로컬 뮤텍스를 나타내는 경우 액세스 제어는 관련이 없습니다.

명명된 뮤텍스에 현재 적용된 규칙 목록을 가져오려면 메서드를 사용하여 Mutex.GetAccessControl 개체를 MutexSecurity 가져온 다음 해당 메서드를 GetAccessRules 사용하여 개체 컬렉션을 MutexAccessRule 가져옵니다.

MutexAccessRule 개체는 기본 DACL(임의 액세스 제어 목록)의 액세스 제어 항목과 일대일로 매핑되지 않습니다. 뮤텍스에 대한 모든 액세스 규칙 집합을 가져오는 경우 집합에는 현재 모든 액세스 제어 항목을 표현하는 데 필요한 최소 규칙 수가 포함됩니다.

참고

규칙을 적용하고 제거하면 기본 액세스 제어 항목이 변경됩니다. 가능한 경우 규칙의 정보가 병합되어 가장 적은 수의 액세스 제어 항목을 유지 관리합니다. 따라서 현재 규칙 목록을 읽을 때 추가한 모든 규칙 목록과 정확히 일치하지 않을 수 있습니다.

개체를 사용하여 MutexAccessRule 사용자 또는 그룹을 허용하거나 거부할 액세스 권한을 지정합니다. 개체는 MutexAccessRule 항상 허용되는 액세스 또는 액세스 거부를 나타내며 둘 다 그렇지 않습니다.

명명된 시스템 뮤텍스에 규칙을 적용하려면 메서드를 Mutex.GetAccessControl 사용하여 개체를 MutexSecurity 가져옵니다. 메서드를 사용하여 개체를 MutexSecurity 수정하여 규칙을 추가한 다음 메서드를 Mutex.SetAccessControl 사용하여 보안 개체를 다시 연결합니다.

중요

변경한 개체는 메서드를 MutexSecurity 호출 Mutex.SetAccessControl 하여 변경된 보안 개체를 명명된 뮤텍스에 할당할 때까지 명명된 뮤텍스의 액세스 수준에 영향을 미치지 않습니다.

MutexAccessRule 개체는 변경할 수 없습니다. 뮤텍스에 대한 보안은 규칙을 추가하거나 제거하는 클래스의 MutexSecurity 메서드를 사용하여 수정됩니다. 이렇게 하면 기본 액세스 제어 항목이 수정됩니다.

생성자

MutexAccessRule(IdentityReference, MutexRights, AccessControlType)

MutexAccessRule 클래스의 새 인스턴스를 초기화하여 규칙을 적용할 사용자 또는 그룹, 액세스 권한 및 지정된 액세스 권한의 허용 또는 거부를 지정합니다.

MutexAccessRule(String, MutexRights, AccessControlType)

MutexAccessRule 클래스의 새 인스턴스를 초기화하여 규칙을 적용할 사용자 또는 그룹의 이름, 액세스 권한 및 지정된 액세스 권한의 허용 또는 거부 여부를 지정합니다.

속성

AccessControlType

AccessControlType 개체와 관련된 AccessRule 값을 가져옵니다.

(다음에서 상속됨 AccessRule)
AccessMask

이 규칙의 액세스 마스크를 가져옵니다.

(다음에서 상속됨 AuthorizationRule)
IdentityReference

이 규칙이 적용되는 IdentityReference를 가져옵니다.

(다음에서 상속됨 AuthorizationRule)
InheritanceFlags

이 규칙이 자식 개체에서 상속되는 방식을 결정하는 플래그 값을 가져옵니다.

(다음에서 상속됨 AuthorizationRule)
IsInherited

이 규칙이 명시적으로 설정되는지 아니면 부모 컨테이너 개체에서 상속되는지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 AuthorizationRule)
MutexRights

액세스 규칙에 의해 허용 또는 거부된 권한을 가져옵니다.

PropagationFlags

이 규칙의 상속이 자식 개체에 전파되는 방법을 결정하는 전파 플래그의 값을 가져옵니다. 이 속성은 InheritanceFlags 열거형의 값이 None이 아닐 때만 중요합니다.

(다음에서 상속됨 AuthorizationRule)

메서드

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상

추가 정보