Updated: July 19, 2016

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

(Write-only.) The PROPID_M_SECURITY_CONTEXT property specifies a handle to a security context structure that contains a user certificate, the corresponding private key, the user's SID, and other information needed to attach the certificate to a message.

Property ID


Type Indicator




Handle to a security context buffer returned by MQGetSecurityContextEx.

The sending application should use PROPID_M_SECURITY_CONTEXT when using the same certificate to send a large number of authenticated messages. The Message Queuing runtime uses the handle to the security context structure specified by PROPID_M_SECURITY_CONTEXT to attach the certificate to the messages for you.

All the information in a security context structure is stored locally on the source computer and has no meaning to the receiving application.

To create a security context structure, call MQGetSecurityContextEx. The certificate included can be an internal or external certificate.

When using a security context structure to attach a certificate, do not set PROPID_M_SENDER_CERT. The Message Queuing runtime will attach the certificate for you. If the Message Queuing runtime finds a different certificate in PROPID_M_SENDER_CERT, it will ignore any information in PROPID_M_SECURITY_CONTEXT.

When the sending application is impersonating a user, it must use the security context of the impersonated user.

The PROPID_M_SECURITY_CONTEXT property is write-only. If the receiving application attempts to retrieve the PROPID_M_SECURITY_CONTEXT property, MQReceiveMessage or MQReceiveMessageByLookupId returns the warning MQ_INFORMATION_PROPERTY, the individual result for the PROPID_M_SECURITY_CONTEXT property is MQ_INFORMATION_PROPERTY_IGNORED, and the other properties are received correctly.

When the current security context structure is no longer needed, call MQFreeSecurityContext to clear the memory allocated for this structure.

For information onSee
Attaching the security context using a COM methodMSMQMessage.AttachCurrentSecurityContext
Using a security context structureWhen to Use a Security Context Structure
How to retrieve the security context of another userImpersonating a User

Message Properties

Community Additions