SemaphoreAccessRule 생성자

정의

SemaphoreAccessRule 클래스의 새 인스턴스를 초기화합니다.

오버로드

Name Description
SemaphoreAccessRule(IdentityReference, SemaphoreRights, AccessControlType)

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

SemaphoreAccessRule(String, SemaphoreRights, AccessControlType)

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

SemaphoreAccessRule(IdentityReference, SemaphoreRights, AccessControlType)

Source:
SemaphoreSecurity.cs
Source:
SemaphoreSecurity.cs
Source:
SemaphoreSecurity.cs
Source:
SemaphoreSecurity.cs
Source:
SemaphoreSecurity.cs
Source:
SemaphoreSecurity.cs

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

public:
 SemaphoreAccessRule(System::Security::Principal::IdentityReference ^ identity, System::Security::AccessControl::SemaphoreRights eventRights, System::Security::AccessControl::AccessControlType type);
public SemaphoreAccessRule(System.Security.Principal.IdentityReference identity, System.Security.AccessControl.SemaphoreRights eventRights, System.Security.AccessControl.AccessControlType type);
new System.Security.AccessControl.SemaphoreAccessRule : System.Security.Principal.IdentityReference * System.Security.AccessControl.SemaphoreRights * System.Security.AccessControl.AccessControlType -> System.Security.AccessControl.SemaphoreAccessRule
Public Sub New (identity As IdentityReference, eventRights As SemaphoreRights, type As AccessControlType)

매개 변수

identity
IdentityReference

규칙이 적용되는 사용자 또는 그룹입니다. 형식이거나 형식 SecurityIdentifier 으로 NTAccount 변환할 수 있는 형식 SecurityIdentifier이어야 합니다.

eventRights
SemaphoreRights

허용되거나 거부된 권한을 지정하는 값의 SemaphoreRights 비트 조합입니다.

type
AccessControlType

AccessControlType 권한이 허용 또는 거부되는지 여부를 지정하는 값 중 하나입니다.

예외

eventRights 은 잘못된 값을 지정합니다.

-또는-

type 은 잘못된 값을 지정합니다.

identitynull입니다.

-또는-

eventRights 가 0입니다.

identity형식이 아니거나 형식 SecurityIdentifier 으로 변환NTAccount할 수 있는 형식 SecurityIdentifier 이 아닙니다.

설명

예를 들어 메서드를 Semaphore호출 WaitOne 하여 입력하려면 사용자에게 액세스 권한이 SemaphoreRights.Synchronize 있어야 합니다. 세마포를 종료하려면 메서드를 Release 호출하여 사용자에게 액세스 권한이 SemaphoreRights.Modify 있어야 합니다.

적용 대상

SemaphoreAccessRule(String, SemaphoreRights, AccessControlType)

Source:
SemaphoreSecurity.cs
Source:
SemaphoreSecurity.cs
Source:
SemaphoreSecurity.cs
Source:
SemaphoreSecurity.cs
Source:
SemaphoreSecurity.cs
Source:
SemaphoreSecurity.cs

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

public:
 SemaphoreAccessRule(System::String ^ identity, System::Security::AccessControl::SemaphoreRights eventRights, System::Security::AccessControl::AccessControlType type);
public SemaphoreAccessRule(string identity, System.Security.AccessControl.SemaphoreRights eventRights, System.Security.AccessControl.AccessControlType type);
new System.Security.AccessControl.SemaphoreAccessRule : string * System.Security.AccessControl.SemaphoreRights * System.Security.AccessControl.AccessControlType -> System.Security.AccessControl.SemaphoreAccessRule
Public Sub New (identity As String, eventRights As SemaphoreRights, type As AccessControlType)

매개 변수

identity
String

규칙이 적용되는 사용자 또는 그룹의 이름입니다.

eventRights
SemaphoreRights

허용되거나 거부된 권한을 지정하는 값의 SemaphoreRights 비트 조합입니다.

type
AccessControlType

AccessControlType 권한이 허용 또는 거부되는지 여부를 지정하는 값 중 하나입니다.

예외

eventRights 은 잘못된 값을 지정합니다.

-또는-

type 은 잘못된 값을 지정합니다.

eventRights 가 0입니다.

identitynull입니다.

-또는-

identity 는 길이가 0인 문자열입니다.

-또는-

identity 가 512자보다 깁니다.

예제

다음 코드 예제에서는 개체를 만들기 SemaphoreAccessRule 위해이 생성자를 사용 하는 방법을 보여 줍니다. 이 예제에서는 개체를 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

설명

예를 들어 메서드를 Semaphore호출 WaitOne 하여 입력하려면 사용자에게 액세스 권한이 SemaphoreRights.Synchronize 있어야 합니다. 세마포를 종료하려면 메서드를 Release 호출하여 사용자에게 액세스 권한이 SemaphoreRights.Modify 있어야 합니다.

이 생성자는 생성자에 전달하고 새로 만든 개체를 NTAccount 생성자에 전달 identity 하여 개체를 만드는 NTAccount.NTAccount(String) 것과 NTAccountSemaphoreAccessRule(IdentityReference, SemaphoreRights, AccessControlType) 같습니다.

적용 대상