Export (0) Print
Expand All

MessageQueue::SetPermissions Method (String, MessageQueueAccessRights, AccessControlEntryType)

Gives a computer, group, or user the specified access rights, with the specified access control type (allow, deny, revoke, or set).

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

public:
void SetPermissions(
	String^ user, 
	MessageQueueAccessRights rights, 
	AccessControlEntryType entryType
)

Parameters

user
Type: System::String

The individual, group, or computer that gets additional rights to the queue.

rights
Type: System.Messaging::MessageQueueAccessRights

A MessageQueueAccessRights that indicates the set of rights to the queue that Message Queuing assigns to the user passed in.

entryType
Type: System.Messaging::AccessControlEntryType

A AccessControlEntryType that specifies whether to grant, deny, or revoke the permissions specified by the rights parameter.

ExceptionCondition
MessageQueueException

An error occurred when accessing a Message Queuing method.

Use this overload to grant, deny, or revoke specified rights for an individual user. The user can be any valid trustee, which includes individual users, groups of users, or a computer. If the user is an individual, use the format DOMAIN\user for the user parameter. You can specify "." for the user parameter to indicate the local computer.

The permissions you assign through SetPermissions add rights to the existing list. By default, the creator of a public or private queue has full control, and the domain group Everyone has permission to get queue properties, get permissions, and write to the queue. When you call SetPermissions, the user and permissions information is appended to the bottom of the existing list.

The system examines each AccessControlEntry in sequence until one of the following events occurs:

  • An access-denied AccessControlEntry explicitly denies any of the requested access rights to one of the trustees listed in the thread's access token.

  • One or more access-allowed AccessControlEntry items for trustees listed in the thread's access token explicitly grant all the requested access rights.

  • All AccessControlEntry items have been checked and there is still at least one requested access right that has not been explicitly allowed, in which case, access is implicitly denied.

The rights to a queue, specified in the rights parameter, can be any combination of the following:

  • Full Control

  • Delete Message

  • Receive Message

  • Peek Message

  • Receive Journal Message

  • Get Queue Properties

  • Set Queue Properties

  • Get Permissions

  • Set Permissions

  • Take Queue Ownership

  • Write Message

The MessageQueueAccessRights enumeration represents a set of bit flags that you can combine using the bitwise operator OR to build the rights parameter.

The following table shows whether this method is available in various Workgroup modes.

Workgroup mode

Available

Local computer

Yes

Local computer and direct format name

Yes

Remote computer

No

Remote computer and direct format name

No

The following code example demonstrates the use of SetPermissions(String, MessageQueueAccessRights, AccessControlEntryType).


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

    // Grant all users in the "Everyone" user group the right to receive
    // messages from the queue.
    queue->SetPermissions("Everyone",
        MessageQueueAccessRights::ReceiveMessage,
        AccessControlEntryType::Allow);

    queue->Close();

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft