MessageQueuePermissionAttribute Klas
Definitie
Belangrijk
Bepaalde informatie heeft betrekking op een voorlopige productversie die aanzienlijk kan worden gewijzigd voordat deze wordt uitgebracht. Microsoft biedt geen enkele expliciete of impliciete garanties met betrekking tot de informatie die hier wordt verstrekt.
Hiermee staat u declaratieve MessageQueue machtigingscontroles toe.
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
- Overname
- Kenmerken
Voorbeelden
In het volgende codevoorbeeld ziet u het gebruik van 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();
}
}
Opmerkingen
Zie Kenmerken voor meer informatie over het gebruik van kenmerken.
Constructors
| Name | Description |
|---|---|
| MessageQueuePermissionAttribute(SecurityAction) |
Initialiseert een nieuw exemplaar van de MessageQueuePermissionAttribute klasse. |
Eigenschappen
| Name | Description |
|---|---|
| Action |
Haalt een beveiligingsactie op of stelt deze in. (Overgenomen van SecurityAttribute) |
| Category |
Hiermee haalt u de wachtrijcategorie op of stelt u deze in. |
| Label |
Hiermee wordt de beschrijving van de wachtrij opgehaald of ingesteld. |
| MachineName |
Hiermee haalt u de naam op van de computer waar de Message Queuing-wachtrij zich bevindt. |
| Path |
Hiermee wordt het pad van de wachtrij opgehaald of ingesteld. |
| PermissionAccess |
Hiermee haalt u de machtigingstoegangsniveaus op die worden gebruikt in de machtigingsaanvraag. |
| TypeId |
Wanneer deze wordt geïmplementeerd in een afgeleide klasse, krijgt u Attributehiervoor een unieke id. (Overgenomen van Attribute) |
| Unrestricted |
Hiermee wordt een waarde opgehaald of ingesteld die aangeeft of volledige (onbeperkte) machtiging voor de resource die door het kenmerk wordt beveiligd, wordt gedeclareerd. (Overgenomen van SecurityAttribute) |
Methoden
| Name | Description |
|---|---|
| CreatePermission() |
Hiermee maakt u de machtiging op basis van de aangevraagde toegangsniveaus, categorie, label, computernaam en pad dat is ingesteld via het PermissionAccesskenmerk , Category, LabelMachineNameen Path eigenschappen op het kenmerk. |
| Equals(Object) |
Retourneert een waarde die aangeeft of dit exemplaar gelijk is aan een opgegeven object. (Overgenomen van Attribute) |
| GetHashCode() |
Retourneert de hash-code voor dit exemplaar. (Overgenomen van Attribute) |
| GetType() |
Hiermee haalt u de Type huidige instantie op. (Overgenomen van Object) |
| IsDefaultAttribute() |
Wanneer deze wordt overschreven in een afgeleide klasse, geeft u aan of de waarde van dit exemplaar de standaardwaarde is voor de afgeleide klasse. (Overgenomen van Attribute) |
| Match(Object) |
Wanneer deze wordt overschreven in een afgeleide klasse, wordt een waarde geretourneerd die aangeeft of dit exemplaar gelijk is aan een opgegeven object. (Overgenomen van Attribute) |
| MemberwiseClone() |
Hiermee maakt u een ondiepe kopie van de huidige Object. (Overgenomen van Object) |
| ToString() |
Retourneert een tekenreeks die het huidige object vertegenwoordigt. (Overgenomen van Object) |
Expliciete interface-implementaties
| Name | Description |
|---|---|
| _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) |
Hiermee wordt een set namen toegewezen aan een bijbehorende set verzend-id's. (Overgenomen van Attribute) |
| _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) |
Hiermee haalt u de typegegevens voor een object op, die kan worden gebruikt om de typegegevens voor een interface op te halen. (Overgenomen van Attribute) |
| _Attribute.GetTypeInfoCount(UInt32) |
Hiermee wordt het aantal type-informatieinterfaces opgehaald dat een object biedt (0 of 1). (Overgenomen van Attribute) |
| _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) |
Biedt toegang tot eigenschappen en methoden die door een object worden weergegeven. (Overgenomen van Attribute) |