Sending Messages While Impersonating Another User

Sending messages while impersonating another user requires that security context information is used. The security information must be retrieved from the certificate using MQGetSecurityContext, regardless of the type of certificate you are using.

    To send an authenticated message
  1. Call MQGetSecurityContext. When using an external certificate, specify the certificate you want to use. When using the internal certificate provided by MSMQ, specify NULL. MQGetSecurityContext must always be used when impersonating a user.
  2. Set PROPID_M_SECURITY_CONTEXT to the returned handle.
  3. Send the message.

After the message is sent, the remaining work is done by MSMQ. For information on what MSMQ does to authenticate the message, see How MSMQ Authenticates Messages.