Export (0) Print
Expand All

MessageQueuePermissionEntry Class

Defines the smallest unit of a code access security permission set for messaging.

Namespace: System.Messaging
Assembly: System.Messaging (in system.messaging.dll)

'Declaration
<SerializableAttribute> _
Public Class MessageQueuePermissionEntry
'Usage
Dim instance As MessageQueuePermissionEntry

/** @attribute SerializableAttribute() */ 
public class MessageQueuePermissionEntry
SerializableAttribute 
public class MessageQueuePermissionEntry
Not applicable.

For more information, see Code Access Security.

The following code example demonstrates the use of MessageQueuePermissionEntry.

No code example is currently available or this language may not be supported.
import System.*;
import System.Messaging.*;

public class MessageQueuePermissionEntryExample
{
    public static void main(String[] args)
    {
        // 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();
    } //main

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

    // 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.get_Path());
    } //CreateEntry1
    
    // 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.get_MachineName(), queue.get_Label(),
            queue.get_Category().ToString());
    } //CreateEntry2
    
    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.get_MachineName(), queue.get_Label(),
            queue.get_Category().ToString());
        // Display the value of the entry's Category property.
        Console.WriteLine("Category: {0}", entry.get_Category().ToString());
    } //CategoryExample

    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.get_MachineName(), queue.get_Label(),
            queue.get_Category().ToString());
        // Display the value of the entry's Label property.
        Console.WriteLine("Label: {0}", entry.get_Label());
    } //LabelExample

    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.get_MachineName(), queue.get_Label(),
            queue.get_Category().ToString());
        // Display the value of the entry's MachineName property.
        Console.WriteLine("MachineName: {0}", entry.get_MachineName());
    } //MachineNameExample

    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.get_Path());
        // Display the value of the entry's Path property.
        Console.WriteLine("Path: {0}", entry.get_Path());
    } //PathExample
    
    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.get_MachineName(), queue.get_Label(),
            queue.get_Category().ToString());
        // Display the value of the entry's PermissionAccess property.
        Console.WriteLine("PermissionAccess: {0}", entry.get_PermissionAccess());
    } //PermissionAccessExample
} //MessageQueuePermissionEntryExample

System.Object
  System.Messaging.MessageQueuePermissionEntry

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft