This documentation is archived and is not being maintained.
MessageQueuePermissionAttribute Class
Visual Studio 2010
Allows declarative MessageQueue permission checks.
System::Object
System::Attribute
System.Security.Permissions::SecurityAttribute
System.Security.Permissions::CodeAccessSecurityAttribute
System.Messaging::MessageQueuePermissionAttribute
System::Attribute
System.Security.Permissions::SecurityAttribute
System.Security.Permissions::CodeAccessSecurityAttribute
System.Messaging::MessageQueuePermissionAttribute
Assembly: System.Messaging (in System.Messaging.dll)
[SerializableAttribute] [AttributeUsageAttribute(AttributeTargets::Assembly|AttributeTargets::Class|AttributeTargets::Struct|AttributeTargets::Constructor|AttributeTargets::Method|AttributeTargets::Event, AllowMultiple = true, Inherited = false)] public ref class MessageQueuePermissionAttribute : public CodeAccessSecurityAttribute
The MessageQueuePermissionAttribute type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | MessageQueuePermissionAttribute | Initializes a new instance of the MessageQueuePermissionAttribute class. |
| Name | Description | |
|---|---|---|
![]() | Action | Gets or sets a security action. (Inherited from SecurityAttribute.) |
![]() | Category | Gets or sets the queue category. |
![]() | Label | Gets or sets the queue description. |
![]() | MachineName | Gets or sets the name of the computer where the Message Queuing queue is located. |
![]() | Path | Gets or sets the queue's path. |
![]() | PermissionAccess | Gets or sets the permission access levels used in the permissions request. |
![]() | TypeId | When implemented in a derived class, gets a unique identifier for this Attribute. (Inherited from Attribute.) |
![]() | Unrestricted | Gets or sets a value indicating whether full (unrestricted) permission to the resource protected by the attribute is declared. (Inherited from SecurityAttribute.) |
| Name | Description | |
|---|---|---|
![]() | CreatePermission | Creates the permission based on the requested access levels, category, label, computer name, and path that are set through the PermissionAccess, Category, Label, MachineName, and Path properties on the attribute. (Overrides SecurityAttribute::CreatePermission().) |
![]() | Equals | Infrastructure. Returns a value that indicates whether this instance is equal to a specified object. (Inherited from Attribute.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetHashCode | Returns the hash code for this instance. (Inherited from Attribute.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | IsDefaultAttribute | When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from Attribute.) |
![]() | Match | When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from Attribute.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
| Name | Description | |
|---|---|---|
![]() ![]() | _Attribute::GetIDsOfNames | Maps a set of names to a corresponding set of dispatch identifiers. (Inherited from Attribute.) |
![]() ![]() | _Attribute::GetTypeInfo | Retrieves the type information for an object, which can be used to get the type information for an interface. (Inherited from Attribute.) |
![]() ![]() | _Attribute::GetTypeInfoCount | Retrieves the number of type information interfaces that an object provides (either 0 or 1). (Inherited from Attribute.) |
![]() ![]() | _Attribute::Invoke | Provides access to properties and methods exposed by an object. (Inherited from Attribute.) |
For more information about using attributes, see Extending Metadata Using Attributes.
The following code example demonstrates the use of 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); } }
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Show:
