Applies To: Windows 10, Windows 7, Windows 8, Windows 8.1, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, Windows Server 2012 R2, Windows Server Technical Preview, Windows Vista
The MQGetQueueSecurity function retrieves information from the access control security descriptor of the specified queue.
HRESULT APIENTRY MQGetQueueSecurity( LPCWSTR lpwcsFormatName, SECURITY_INFORMATION SecurityInformation, PSECURITY_DESCRIPTOR pSecurityDescriptor, DWORD nLength, LPDWORD lpnLengthNeeded );
[in] Pointer to the format name string of the queue whose security information will be retrieved. A public or private format name can be used to specify the queue. You can use a direct format name only to obtain information from the security descriptor of a local private queue. See "Remarks" for limitations on private queues.
[in] Specifies a SECURITY_INFORMATION value that identifies the component or components of access control information being requested. The information requested is placed in the security descriptor buffer pointed to by the pSecurityDescriptor parameter. The following SECURITY_INFORMATION bit flags or a combination of these bit flags can be used to identify the components of security information being retrieved.
Indicates that the discretionary access control list (DACL) is being retrieved.
Indicates that the primary group security identifier is being retrieved.
Indicates that the owner's security identifier (SID) is being retrieved.
Indicates that the system access control list (SACL) is being retrieved.
Message Queuing does not support the use of the following bit flags in this parameter.
[out] Pointer to the SECURITY_DESCRIPTOR structure (security descriptor buffer) that receives the components of the queue's security information requested. The SECURITY_DESCRIPTOR structure is returned in the self-relative format. Setting this parameter to NULL is not recommended.
[in] Specifies the size, in bytes, of the security descriptor buffer (see pSecurityDescriptor).
[out] Pointer to a variable that indicates if any additional length is needed for the security descriptor. If the security descriptor fits in the buffer, this variable indicates the actual size of the security descriptor.
If the security descriptor buffer is too small for the security descriptor (the value of lpnLengthNeeded is greater than the value of nLength), this variable indicates the size of the buffer needed to hold the security descriptor. When this happens, the security descriptor is not copied to the buffer and MQ_ERROR_SECURITY_DESCRIPTOR_TOO_SMALL is returned.
The access rights for getting the queue's security descriptor are not allowed for the calling process. For more information on queue access rights, see Access Control.
To change access rights of the queue, call MQSetQueueSecurity.
The lpwcsFormatName parameter specified an illegal format name.
A connection with the directory service cannot be established. Verify permissions for accessing the directory service.
The process does not have the proper privilege to read the queue's system access control list.
The buffer pointed to by pSecurityDescriptor is too small to hold the security descriptor; the returned value of lpnLengthNeeded is greater than the supplied value of nLength.
The format name specified in the lpwcsFormatName parameter cannot be used. You cannot reference a public queue or a remote private queue in a call to this function using a direct format name, nor can you get the security descriptor of a journal, dead-letter, or connector queue.
Apart from generic Message Queuing error codes, this function may return ADSI and LDAP error codes. For example, LDAP_BUSY (0x8007200E) is returned when the directory service server is busy.
The queue's security descriptor is initially set when the queue is created (see MQCreateQueue). Access to the following queue operations can be controlled: creating, deleting, and opening the queue for sending messages to and reading messages from the queue; getting and setting the queue's properties; and getting and setting the queue's security descriptor.
The security descriptor of a local or remote public queue can be retrieved, but you can only retrieve the security descriptor of a private queue if it is located on your local computer.
The security descriptor of a journal, dead-letter, connector, and foreign queue cannot be retrieved.
To read the security descriptor of a queue, the calling process must be allowed READ_CONTROL access or be the owner of the queue. Access rights such as READ_CONTROL are set when the queue is created and can be modified by calling MQSetQueueSecurity.
To read the queue's system access control list, the caller must have SE_SECURITY_NAME privileges on the directory service server (for public queues) or on the local computer (for private queues).
A public queue's security descriptor cannot be retrieved if there is no connection to the directory service. This restriction applies to dependent client computers, independent client computers that are working offline, and Message Queuing routing servers (FRS).
Reading the Access Mask of an Access Control Entry
The following flags can be used to interpret access rights in the access mask of an access control entry (ACE) in the security descriptor.
(MQSEC_DELETE_MESSAGE | MQSEC_PEEK_MESSAGE)
(MQSEC_DELETE_JOURNAL_MESSAGE | \
(MQSEC_GET_QUEUE_PROPERTIES | \
MQSEC_GET_QUEUE_PERMISSIONS | \
(MQSEC_RECEIVE_MESSAGE | \
MQSEC_RECEIVE_MESSAGE_JOURNAL | \
|For information on||See|
|Obtaining a format name for the queue||Obtaining Format Names|
|Offline operations||Message Queuing Offline Support|
|Access control and security descriptors||Access Control|
The following code examples are included in Using Message Queuing.
|For an example of||See|
|Retrieving the domain name (if applicable) and account name of a queue's owner||C/C++ Code Example: Retrieving the Queue Owner's Name|
|Displaying lists of the permissions of a queue that are granted or denied to trustees||C/C++ Code Example: Retrieving the Access Rights of a Queue|
Windows NT/2000/XP: Included in Windows NT 4.0 SP3 and later.
Windows 95/98/Me: Included in Windows 95 and later.
Header: Declared in Mq.h.
Library: Use Mqrt.lib.