3.10.4.1.26 Create (Opnum 32)

The Create method is received by the server in an RPC_REQUEST packet. In response, the server creates a new public or private ApplicationQueue.

 HRESULT Create(
   [in, optional] VARIANT* IsTransactional,
   [in, optional] VARIANT* IsWorldReadable
 );

IsTransactional: A VARIANT pointer to a BOOLEAN value (VT_BOOL) that specifies whether the queue is transactional. If the value is TRUE (0x00000001), the queue is transactional. If the value is FALSE (0x00000000), the queue is not transactional. If the value is unspecified, the server MUST assume that this value is FALSE.

IsWorldReadable: A VARIANT pointer to a BOOLEAN value (VT_BOOL) that, if set to TRUE (0x00000001), specifies that the queue is accessible to everyone. If the value is not specified, the server MUST use FALSE (0x00000000), which specifies that the queue will be accessible only to the owner and system administrators.

Return Values: The method MUST return S_OK (0x00000000) on success or an implementation-specific error HRESULT on failure.

When processing this call, the server MUST abide by the following contract:

  • If refQueue.PathName equals NULL:

    • Return an error HRESULT, and take no further action.

  • Identify the computer name and the queue name from the refQueue.PathName.

  • If the computer name or queue name cannot be identified:

    • Return an error HRESULT, and take no further action.

  • Define IsLocal as a BOOLEAN value that equals True if the local QueueManager.ComputerName equals the identified computer name.

  • Define IsPublic as a BOOLEAN value that equals True if the Queue.PathName instance variable describes a public queue. Otherwise, IsPublic equals False.

  • IfIsLocal equals False and IsPublic equals False:

    • Return an error HRESULT, and take no further action.

  • Define OwnerQueueManager as a QueueManager.

  • If IsLocal equals True:

    • Set OwnerQueueManager to the QueueManager.

  • Else:

    • Set OwnerQueueManager to QueueManager for which the ComputerName property equals the identified computer name.

  • Check whether the OwnerQueueManager has an ApplicationQueue for which the Pathname property equals the identified queue name.

  • If ApplicationQueue exists:

    • Return an error HRESULT, and take no further action.

  • Else:

    • If IsPublic equals False:

      • Perform an access check by invoking the Access Check Algorithm ([MS-DTYP] section 2.5.3.2) with the following parameters:

      • SecurityDescriptor: OwnerQueueManager.Security.

      • Token: the security token of the caller.<44>

      • Access Request mask: MQSEC_CREATE_QUEUE as defined in section 2.2.24 of [MS-MQMQ].

      • Object Tree: NULL.

      • PrincipalSelfSubst SID: NULL.

    • If the Access Check Algorithm does not return success:

      • Return an error HRESULT, and take no further action.

  • Instantiate a new Queue object, referred to as newQueue. Copy all attributes of refQueue over to newQueue.

  • Set newQueue.Transactional to the value of the IsTransactional input parameter.

  • Set the security descriptor in newQueue.Security according to the steps in section 3.10.4.1.26.1

  • Generate the CreateQueue ([MS-MQDMPR] section 3.1.7.1.3) event with the following arguments:

    • iQueue = MUST be set to a reference to newQueue.

    • iSkipDirectory = False.

  • If the CreateQueue event does not return success:

    • Return an rStatus status code, and take no further action.

  • Set IsQueueCreated to True.

  • Set IsApplicationQueue to True.

  • Return S_OK (0x00000000), and take no further action.