MessageQueuePermissionAttribute 클래스

정의

MessageQueue 권한을 선언적으로 확인할 수 있습니다.

public ref class MessageQueuePermissionAttribute : System::Security::Permissions::CodeAccessSecurityAttribute
[System.AttributeUsage(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Constructor | System.AttributeTargets.Event | System.AttributeTargets.Method | System.AttributeTargets.Struct, AllowMultiple=true, Inherited=false)]
[System.Serializable]
public class MessageQueuePermissionAttribute : System.Security.Permissions.CodeAccessSecurityAttribute
[<System.AttributeUsage(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Constructor | System.AttributeTargets.Event | System.AttributeTargets.Method | System.AttributeTargets.Struct, AllowMultiple=true, Inherited=false)>]
[<System.Serializable>]
type MessageQueuePermissionAttribute = class
    inherit CodeAccessSecurityAttribute
Public Class MessageQueuePermissionAttribute
Inherits CodeAccessSecurityAttribute
상속
특성

예제

다음 코드 예제에서는 MessageQueuePermissionAttribute의 사용법을 보여줍니다.


#using <System.Messaging.dll>
#using <System.dll>

using namespace System;
using namespace System::Messaging;

// Creates a new queue.
void CreateQueue(String^ queuePath, bool transactional)
{
    if (!MessageQueue::Exists(queuePath))
    {
        MessageQueue^ queue = MessageQueue::Create(queuePath, transactional);
        queue->Close();       
    }
    else
    {
        Console::WriteLine("{0} already exists.", queuePath);
    }
}

// Demonstrates the following MessageQueuePermissionAttribute constructor:
// public #ctor (SecurityAction action)
void CreateAttribute()
{

    // Create a new instance of MessageQueuePermissionAttribute.
    MessageQueuePermissionAttribute^ attribute =
        gcnew MessageQueuePermissionAttribute(
        System::Security::Permissions::SecurityAction::Assert);

}


void CategoryExample()
{

    // Connect to a queue on the local computer.
    MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue");

    // Create a new instance of MessageQueuePermissionAttribute.
    MessageQueuePermissionAttribute^ attribute =
        gcnew MessageQueuePermissionAttribute(
        System::Security::Permissions::SecurityAction::Assert);

    // Set the attribute's Category property value, based on the queue's
    // Category property value.
    attribute->Category = queue->Category.ToString();

    // Display the new value of the attribute's Category property.
    Console::WriteLine("attribute->Category: {0}",
        attribute->Category);

    queue->Close();
}

void LabelExample()
{

    // Connect to a queue on the local computer.
    MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue");

    // Create a new instance of MessageQueuePermissionAttribute.
    MessageQueuePermissionAttribute^ attribute =
        gcnew MessageQueuePermissionAttribute(
        System::Security::Permissions::SecurityAction::Assert);

    // Set the attribute's Label property value, based on the queue's Label
    // property value.
    attribute->Label = queue->Label;

    // Display the new value of the attribute's Label property.
    Console::WriteLine("attribute->Label: {0}", attribute->Label);

    queue->Close();
}


void MachineNameExample()
{

    // Connect to a queue on the local computer.
    MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue");

    // Create a new instance of MessageQueuePermissionAttribute.
    MessageQueuePermissionAttribute^ attribute =
        gcnew MessageQueuePermissionAttribute(
        System::Security::Permissions::SecurityAction::Assert);

    // Set the attribute's MachineName property value, based on the queue's
    // MachineName property value.
    attribute->MachineName = queue->MachineName;

    // Display the new value of the attribute's MachineName property.
    Console::WriteLine("attribute->MachineName: {0}",
        attribute->MachineName);

    queue->Close();
}

void PathExample()
{

    // Connect to a queue on the local computer.
    MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue");

    // Create a new instance of MessageQueuePermissionAttribute.
    MessageQueuePermissionAttribute^ attribute =
        gcnew MessageQueuePermissionAttribute(
        System::Security::Permissions::SecurityAction::Assert);

    // Set the attribute's Path property value, based on the queue's Path
    // property value.
    attribute->Path = queue->Path;

    // Display the new value of the attribute's Path property.
    Console::WriteLine("attribute->Path: {0}", attribute->Path);

    queue->Close();
}

void PermissionAccessExample()
{

    // Connect to a queue on the local computer.
    MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue");

    // Create a new instance of MessageQueuePermissionAttribute.
    MessageQueuePermissionAttribute^ attribute =
        gcnew MessageQueuePermissionAttribute(
        System::Security::Permissions::SecurityAction::Assert);

    // Set the attribute's PermissionAccess property value.
    attribute->PermissionAccess = MessageQueuePermissionAccess::Receive;

    // Display the new value of the attribute's PermissionAccess property.
    Console::WriteLine("attribute->PermissionAccess: {0}",
        attribute->PermissionAccess);

    queue->Close();
}

void CreatePermissionExample()
{

    // Connect to a queue on the local computer.
    MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue");

    // Create a new instance of MessageQueuePermissionAttribute.
    MessageQueuePermissionAttribute^ attribute =
        gcnew MessageQueuePermissionAttribute(
        System::Security::Permissions::SecurityAction::Assert);

    // Set the attribute's Path property value, based on the queue's Path
    // property value.
    attribute->Path = queue->Path;

    // Get an IPermission interface by calling the attribute's
    // CreatePermission() method.
    System::Security::IPermission^ permission = attribute->CreatePermission();

    queue->Close();
}

int main()
{
    try
    {

        // Create a non-transactional queue on the local computer.
        CreateQueue(".\\exampleQueue", false);

        // Demonstrate the members of MessageQueuePermissionAttribute.
        // Note that the Path, FormatName, MachineName, Label, and Category
        // property values cannot all be set on the same instance of
        // MessageQueuePermissionAttribute. Trying to do so will throw an
        // exception of type System.InvalidOperationException.

        CreateAttribute();
        CategoryExample();
        LabelExample();
        MachineNameExample();
        PathExample();
        PermissionAccessExample();
        CreatePermissionExample();
    }

    catch (InvalidOperationException^)
    {
        Console::WriteLine("Please install Message Queuing.");
    }

    catch (MessageQueueException^ ex)
    {
        Console::WriteLine(ex->Message);
    }
}

using System;
using System.Messaging;

public class MessageQueuePermissionAttributeExample
{
    public static void Main()
    {
        // Create a new instance of the class.
        MessageQueuePermissionAttributeExample example =
            new MessageQueuePermissionAttributeExample();

        // Create a non-transactional queue on the local computer.
        CreateQueue(".\\exampleQueue", false);

        // Demonstrate the members of MessageQueuePermissionAttribute.
        // Note that the Path, FormatName, MachineName, Label, and Category
        // property values cannot all be set on the same instance of
        // MessageQueuePermissionAttribute. Trying to do so will throw an
        // exception of type System.InvalidOperationException.
        example.CreateAttribute();
        example.CategoryExample();
        example.LabelExample();
        example.MachineNameExample();
        example.PathExample();
        example.PermissionAccessExample();
        example.CreatePermissionExample();
    }

    // Creates a new queue.
    public static void CreateQueue(string queuePath, bool transactional)
    {
        if(!MessageQueue.Exists(queuePath))
        {
            MessageQueue.Create(queuePath, transactional);
        }
        else
        {
            Console.WriteLine(queuePath + " already exists.");
        }
    }

    // Demonstrates the following MessageQueuePermissionAttribute constructor:
    // public #ctor (SecurityAction action)
    public void CreateAttribute()
    {

        // Create a new instance of MessageQueuePermissionAttribute.
        MessageQueuePermissionAttribute attribute =
            new MessageQueuePermissionAttribute(
            System.Security.Permissions.SecurityAction.Assert);

    }

    public void CategoryExample()
    {

        // Connect to a queue on the local computer.
        MessageQueue queue = new MessageQueue(".\\exampleQueue");

        // Create a new instance of MessageQueuePermissionAttribute.
        MessageQueuePermissionAttribute attribute =
            new MessageQueuePermissionAttribute(
            System.Security.Permissions.SecurityAction.Assert);

        // Set the attribute's Category property value, based on the queue's
        // Category property value.
        attribute.Category = queue.Category.ToString();

        // Display the new value of the attribute's Category property.
        Console.WriteLine("attribute.Category: {0}",
            attribute.Category.ToString());

    }

    public void LabelExample()
    {

        // Connect to a queue on the local computer.
        MessageQueue queue = new MessageQueue(".\\exampleQueue");

        // Create a new instance of MessageQueuePermissionAttribute.
        MessageQueuePermissionAttribute attribute =
            new MessageQueuePermissionAttribute(
            System.Security.Permissions.SecurityAction.Assert);

        // Set the attribute's Label property value, based on the queue's Label
        // property value.
        attribute.Label = queue.Label;

        // Display the new value of the attribute's Label property.
        Console.WriteLine("attribute.Label: {0}", attribute.Label);

    }

    public void MachineNameExample()
    {

        // Connect to a queue on the local computer.
        MessageQueue queue = new MessageQueue(".\\exampleQueue");

        // Create a new instance of MessageQueuePermissionAttribute.
        MessageQueuePermissionAttribute attribute =
            new MessageQueuePermissionAttribute(
            System.Security.Permissions.SecurityAction.Assert);

        // Set the attribute's MachineName property value, based on the queue's
        // MachineName property value.
        attribute.MachineName = queue.MachineName;

        // Display the new value of the attribute's MachineName property.
        Console.WriteLine("attribute.MachineName: {0}",
            attribute.MachineName);

    }

    public void PathExample()
    {

        // Connect to a queue on the local computer.
        MessageQueue queue = new MessageQueue(".\\exampleQueue");

        // Create a new instance of MessageQueuePermissionAttribute.
        MessageQueuePermissionAttribute attribute =
            new MessageQueuePermissionAttribute(
            System.Security.Permissions.SecurityAction.Assert);

        // Set the attribute's Path property value, based on the queue's Path
        // property value.
        attribute.Path = queue.Path;

        // Display the new value of the attribute's Path property.
        Console.WriteLine("attribute.Path: {0}", attribute.Path);

    }

    public void PermissionAccessExample()
    {

        // Connect to a queue on the local computer.
        MessageQueue queue = new MessageQueue(".\\exampleQueue");

        // Create a new instance of MessageQueuePermissionAttribute.
        MessageQueuePermissionAttribute attribute =
            new MessageQueuePermissionAttribute(
            System.Security.Permissions.SecurityAction.Assert);

        // Set the attribute's PermissionAccess property value.
        attribute.PermissionAccess = MessageQueuePermissionAccess.Receive;

        // Display the new value of the attribute's PermissionAccess property.
        Console.WriteLine("attribute.PermissionAccess: {0}",
            attribute.PermissionAccess);

    }

    public void CreatePermissionExample()
    {

        // Connect to a queue on the local computer.
        MessageQueue queue = new MessageQueue(".\\exampleQueue");

        // Create a new instance of MessageQueuePermissionAttribute.
        MessageQueuePermissionAttribute attribute =
            new MessageQueuePermissionAttribute(
            System.Security.Permissions.SecurityAction.Assert);

        // Set the attribute's Path property value, based on the queue's Path
        // property value.
        attribute.Path = queue.Path;

        // Get an IPermission interface by calling the attribute's
        // CreatePermission() method.
        System.Security.IPermission permission = attribute.CreatePermission();

    }
}

설명

특성을 사용 하는 방법에 대 한 자세한 내용은 참조 하세요. 특성합니다.

생성자

MessageQueuePermissionAttribute(SecurityAction)

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

속성

Action

보안 동작을 가져오거나 설정합니다.

(다음에서 상속됨 SecurityAttribute)
Category

큐 범주를 가져오거나 설정합니다.

Label

큐 설명을 가져오거나 설정합니다.

MachineName

메시지 큐가 있는 컴퓨터의 이름을 가져오거나 설정합니다.

Path

큐의 경로를 가져오거나 설정합니다.

PermissionAccess

사용 권한 요청에서 사용되는 권한 액세스 수준을 가져오거나 설정합니다.

TypeId

파생 클래스에서 구현된 경우 이 Attribute에 대한 고유 식별자를 가져옵니다.

(다음에서 상속됨 Attribute)
Unrestricted

해당 특성에 의해 보호되는 리소스에 대해 전체(무제한) 권한이 선언되는지 여부를 나타내는 값을 가져오거나 설정합니다.

(다음에서 상속됨 SecurityAttribute)

메서드

CreatePermission()

해당 특성에 있는 PermissionAccess, Category, Label, MachineNamePath 속성을 통해 설정되는 요청된 액세스 수준, 범주, 레이블, 컴퓨터 이름 및 경로에 따라 사용 권한을 만듭니다.

Equals(Object)

이 인스턴스가 지정된 개체와 같은지를 나타내는 값을 반환합니다.

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

이 인스턴스의 해시 코드를 반환합니다.

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

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

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

파생 클래스에서 재정의된 경우 이 인스턴스 값이 파생 클래스에 대한 기본값인지 여부를 표시합니다.

(다음에서 상속됨 Attribute)
Match(Object)

파생 클래스에서 재정의된 경우 이 인스턴스가 지정된 개체와 같은지 여부를 나타내는 값을 반환합니다.

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

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

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

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

(다음에서 상속됨 Object)

명시적 인터페이스 구현

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

이름 집합을 해당하는 디스패치 식별자 집합에 매핑합니다.

(다음에서 상속됨 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

인터페이스의 형식 정보를 가져오는 데 사용할 수 있는 개체의 형식 정보를 검색합니다.

(다음에서 상속됨 Attribute)
_Attribute.GetTypeInfoCount(UInt32)

개체에서 제공하는 형식 정보 인터페이스의 수를 검색합니다(0 또는 1).

(다음에서 상속됨 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

개체에서 노출하는 메서드와 속성에 대한 액세스를 제공합니다.

(다음에서 상속됨 Attribute)

적용 대상

추가 정보