MessageQueuePermissionEntry クラス
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
メッセージのためのコード アクセス セキュリティのアクセス許可セットの最小単位を定義します。
public ref class MessageQueuePermissionEntry
[System.Serializable]
public class MessageQueuePermissionEntry
[<System.Serializable>]
type MessageQueuePermissionEntry = class
Public Class MessageQueuePermissionEntry
- 継承
-
MessageQueuePermissionEntry
- 属性
例
次のコード例は、MessageQueuePermissionEntry の使用方法を示します。
#using <System.Messaging.dll>
#using <System.dll>
using namespace System;
using namespace System::Messaging;
public ref class MessageQueuePermissionEntryExample
{
// Creates a new queue.
public:
static 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 MessageQueuePermission constructor:
// public #ctor (MessageQueuePermissionAccess permissionAccess,
// String path)
public:
void CreateEntryShortCtor()
{
// Connect to a queue on the local computer.
MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue");
// Create a new instance of MessageQueuePermissionEntry.
MessageQueuePermissionEntry^ entry = gcnew MessageQueuePermissionEntry(
MessageQueuePermissionAccess::Receive,
queue->Path);
queue->Close();
}
// Demonstrates the following MessageQueuePermission constructor:
// public #ctor (MessageQueuePermissionAccess permissionAccess,
// String machineName, String label, String category)
public:
void CreateEntryLongCtor()
{
// Connect to a queue on the local computer.
MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue");
// Create a new instance of MessageQueuePermissionEntry.
MessageQueuePermissionEntry^ entry = gcnew MessageQueuePermissionEntry(
MessageQueuePermissionAccess::Receive,
queue->MachineName,
queue->Label,
queue->Category.ToString());
queue->Close();
}
public:
void CategoryExample()
{
// Connect to a queue on the local computer.
MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue");
// Create a new instance of MessageQueuePermissionEntry.
MessageQueuePermissionEntry^ entry = gcnew MessageQueuePermissionEntry(
MessageQueuePermissionAccess::Receive,
queue->MachineName,
queue->Label,
queue->Category.ToString());
// Display the value of the entry's Category property.
Console::WriteLine("Category: {0}", entry->Category->ToString());
queue->Close();
}
public:
void LabelExample()
{
// Connect to a queue on the local computer.
MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue");
// Create a new instance of MessageQueuePermissionEntry.
MessageQueuePermissionEntry^ entry = gcnew MessageQueuePermissionEntry(
MessageQueuePermissionAccess::Receive,
queue->MachineName,
queue->Label,
queue->Category.ToString());
// Display the value of the entry's Label property.
Console::WriteLine("Label: {0}", entry->Label);
queue->Close();
}
public:
void MachineNameExample()
{
// Connect to a queue on the local computer.
MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue");
// Create a new instance of MessageQueuePermissionEntry.
MessageQueuePermissionEntry^ entry = gcnew MessageQueuePermissionEntry(
MessageQueuePermissionAccess::Receive,
queue->MachineName,
queue->Label,
queue->Category.ToString());
// Display the value of the entry's MachineName property.
Console::WriteLine("MachineName: {0}", entry->MachineName);
queue->Close();
}
public:
void PathExample()
{
// Connect to a queue on the local computer.
MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue");
// Create a new instance of MessageQueuePermissionEntry.
MessageQueuePermissionEntry^ entry = gcnew MessageQueuePermissionEntry(
MessageQueuePermissionAccess::Receive,
queue->Path);
// Display the value of the entry's Path property.
Console::WriteLine("Path: {0}", entry->Path);
queue->Close();
}
public:
void PermissionAccessExample()
{
// Connect to a queue on the local computer.
MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue");
// Create a new instance of MessageQueuePermissionEntry.
MessageQueuePermissionEntry^ entry = gcnew MessageQueuePermissionEntry(
MessageQueuePermissionAccess::Receive,
queue->MachineName,
queue->Label,
queue->Category.ToString());
// Display the value of the entry's PermissionAccess property.
Console::WriteLine("PermissionAccess: {0}", entry->PermissionAccess);
queue->Close();
}
};
int main()
{
// Create a new instance of the class.
MessageQueuePermissionEntryExample^ example =
gcnew MessageQueuePermissionEntryExample();
try
{
// Create a non-transactional queue on the local computer.
// Note that the queue might not be immediately accessible, and
// therefore this example might throw an exception of type
// System.Messaging.MessageQueueException when trying to send a
// message to the newly created queue.
example->CreateQueue(".\\exampleQueue", false);
// Demonstrate MessageQueuePermissionEntry's constructors.
example->CreateEntryShortCtor();
example->CreateEntryLongCtor();
// Demonstrate MessageQueuePermissionEntry's properties.
example->CategoryExample();
example->LabelExample();
example->MachineNameExample();
example->PathExample();
example->PermissionAccessExample();
}
catch (InvalidOperationException^)
{
Console::WriteLine("Please install Message Queuing.");
}
catch (MessageQueueException^ ex)
{
// Write the exception information to the console.
Console::WriteLine(ex->Message);
}
}
using System;
using System.Messaging;
public class MessageQueuePermissionEntryExample
{
public static void Main()
{
// Create a new instance of the class.
MessageQueuePermissionEntryExample example =
new MessageQueuePermissionEntryExample();
// Create a non-transactional queue on the local computer.
CreateQueue(".\\exampleQueue", false);
// Demonstrate MessageQueuePermissionEntry's constructors.
example.CreateEntry1();
example.CreateEntry2();
// Demonstrate MessageQueuePermissionEntry's properties.
example.CategoryExample();
example.LabelExample();
example.MachineNameExample();
example.PathExample();
example.PermissionAccessExample();
}
// 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 MessageQueuePermission constructor:
// public #ctor (MessageQueuePermissionAccess permissionAccess,
// String path)
public void CreateEntry1()
{
// Connect to a queue on the local computer.
MessageQueue queue = new MessageQueue(".\\exampleQueue");
// Create a new instance of MessageQueuePermissionEntry.
MessageQueuePermissionEntry entry = new MessageQueuePermissionEntry(
MessageQueuePermissionAccess.Receive,
queue.Path);
}
// Demonstrates the following MessageQueuePermission constructor:
// public #ctor (MessageQueuePermissionAccess permissionAccess,
// String machineName, String label, String category)
public void CreateEntry2()
{
// Connect to a queue on the local computer.
MessageQueue queue = new MessageQueue(".\\exampleQueue");
// Create a new instance of MessageQueuePermissionEntry.
MessageQueuePermissionEntry entry = new MessageQueuePermissionEntry(
MessageQueuePermissionAccess.Receive,
queue.MachineName,
queue.Label,
queue.Category.ToString());
}
public void CategoryExample()
{
// Connect to a queue on the local computer.
MessageQueue queue = new MessageQueue(".\\exampleQueue");
// Create a new instance of MessageQueuePermissionEntry.
MessageQueuePermissionEntry entry = new MessageQueuePermissionEntry(
MessageQueuePermissionAccess.Receive,
queue.MachineName,
queue.Label,
queue.Category.ToString());
// Display the value of the entry's Category property.
Console.WriteLine("Category: {0}", entry.Category.ToString());
}
public void LabelExample()
{
// Connect to a queue on the local computer.
MessageQueue queue = new MessageQueue(".\\exampleQueue");
// Create a new instance of MessageQueuePermissionEntry.
MessageQueuePermissionEntry entry = new MessageQueuePermissionEntry(
MessageQueuePermissionAccess.Receive,
queue.MachineName,
queue.Label,
queue.Category.ToString());
// Display the value of the entry's Label property.
Console.WriteLine("Label: {0}", entry.Label);
}
public void MachineNameExample()
{
// Connect to a queue on the local computer.
MessageQueue queue = new MessageQueue(".\\exampleQueue");
// Create a new instance of MessageQueuePermissionEntry.
MessageQueuePermissionEntry entry = new MessageQueuePermissionEntry(
MessageQueuePermissionAccess.Receive,
queue.MachineName,
queue.Label,
queue.Category.ToString());
// Display the value of the entry's MachineName property.
Console.WriteLine("MachineName: {0}", entry.MachineName);
}
public void PathExample()
{
// Connect to a queue on the local computer.
MessageQueue queue = new MessageQueue(".\\exampleQueue");
// Create a new instance of MessageQueuePermissionEntry.
MessageQueuePermissionEntry entry = new MessageQueuePermissionEntry(
MessageQueuePermissionAccess.Receive,
queue.Path);
// Display the value of the entry's Path property.
Console.WriteLine("Path: {0}", entry.Path);
}
public void PermissionAccessExample()
{
// Connect to a queue on the local computer.
MessageQueue queue = new MessageQueue(".\\exampleQueue");
// Create a new instance of MessageQueuePermissionEntry.
MessageQueuePermissionEntry entry = new MessageQueuePermissionEntry(
MessageQueuePermissionAccess.Receive,
queue.MachineName,
queue.Label,
queue.Category.ToString());
// Display the value of the entry's PermissionAccess property.
Console.WriteLine("PermissionAccess: {0}", entry.PermissionAccess);
}
}
注釈
詳細については、「 Code Access Security」を参照してください。
コンストラクター
MessageQueuePermissionEntry(MessageQueuePermissionAccess, String) |
アクセス許可のアクセス レベルとキューのパスを指定して、MessageQueuePermissionEntry クラスの新しいインスタンスを初期化します。 |
MessageQueuePermissionEntry(MessageQueuePermissionAccess, String, String, String) |
アクセス許可のアクセス レベル、キューが存在するコンピューターの名前、キューの説明、およびキュー カテゴリを指定して、MessageQueuePermissionEntry クラスの新しいインスタンスを初期化します。 |
プロパティ
Category |
キュー カテゴリを取得します。 |
Label |
キューの説明を取得します。 |
MachineName |
メッセージ キューのキューが存在するコンピューターの名前を取得します。 |
Path |
キューのパスを取得します。 |
PermissionAccess |
アクセス許可要求に使用するアクセス許可のアクセス レベルを取得します。 |
メソッド
Equals(Object) |
指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。 (継承元 Object) |
GetHashCode() |
既定のハッシュ関数として機能します。 (継承元 Object) |
GetType() |
現在のインスタンスの Type を取得します。 (継承元 Object) |
MemberwiseClone() |
現在の Object の簡易コピーを作成します。 (継承元 Object) |
ToString() |
現在のオブジェクトを表す文字列を返します。 (継承元 Object) |
適用対象
こちらもご覧ください
.NET