SemaphoreAccessRule 클래스

정의

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

public ref class SemaphoreAccessRule sealed : System::Security::AccessControl::AccessRule
public sealed class SemaphoreAccessRule : System.Security.AccessControl.AccessRule
[System.Security.SecurityCritical]
public sealed class SemaphoreAccessRule : System.Security.AccessControl.AccessRule
[System.Runtime.InteropServices.ComVisible(false)]
public sealed class SemaphoreAccessRule : System.Security.AccessControl.AccessRule
type SemaphoreAccessRule = class
    inherit AccessRule
[<System.Security.SecurityCritical>]
type SemaphoreAccessRule = class
    inherit AccessRule
[<System.Runtime.InteropServices.ComVisible(false)>]
type SemaphoreAccessRule = class
    inherit AccessRule
Public NotInheritable Class SemaphoreAccessRule
Inherits AccessRule
상속
SemaphoreAccessRule
특성

예제

다음 코드 예제에서는 규칙과 규칙 간의 Allow 분리를 보여 줍니다 Deny . 호환되는 규칙의 권한 조합을 보여 줍니다. 이 예제에서는 개체를 SemaphoreSecurity 만들고, 현재 사용자에 대한 다양한 권한을 허용 및 거부하는 규칙을 추가하고, 결과 규칙 쌍을 표시합니다. 그런 다음 현재 사용자에 대한 새 권한을 허용하고 결과를 표시하여 새 권한이 기존 규칙과 병합됨을 Allow 보여 줍니다.

참고

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

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

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

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

        ShowSecurity(mSec);
    }

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

        foreach(SemaphoreAccessRule 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.SemaphoreRights);
            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 SemaphoreSecurity()

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

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

        ShowSecurity(mSec)

    End Sub 

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

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

            Console.WriteLine("        User: {0}", ar.IdentityReference)
            Console.WriteLine("        Type: {0}", ar.AccessControlType)
            Console.WriteLine("      Rights: {0}", ar.SemaphoreRights)
            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

설명

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

참고

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

명명된 세마포에 현재 적용된 규칙 목록을 가져오려면 메서드를 사용하여 Semaphore.GetAccessControl 개체를 SemaphoreSecurity 가져온 다음 해당 메서드를 GetAccessRules 사용하여 개체 컬렉션을 SemaphoreAccessRule 가져옵니다.

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

참고

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

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

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

중요

변경된 보안 개체를 명명된 세마포에 할당하기 SemaphoreSecurity 위해 메서드를 호출 Semaphore.SetAccessControl 할 때까지 개체를 변경하면 명명된 세마포의 액세스 수준에 영향을 미치지 않습니다.

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

생성자

SemaphoreAccessRule(IdentityReference, SemaphoreRights, AccessControlType)

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

SemaphoreAccessRule(String, SemaphoreRights, AccessControlType)

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

속성

AccessControlType

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

(다음에서 상속됨 AccessRule)
AccessMask

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

(다음에서 상속됨 AuthorizationRule)
IdentityReference

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

(다음에서 상속됨 AuthorizationRule)
InheritanceFlags

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

(다음에서 상속됨 AuthorizationRule)
IsInherited

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

(다음에서 상속됨 AuthorizationRule)
PropagationFlags

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

(다음에서 상속됨 AuthorizationRule)
SemaphoreRights

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

메서드

Equals(Object)

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

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

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

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

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

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

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

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

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

(다음에서 상속됨 Object)

적용 대상

추가 정보