PrivLevel
MSMQQueueInfo MSMQMessage

Optional. The PrivLevel property specifies the privacy level of a queue or message.

For queues, this property specifies whether or not the queue accepts private (encrypted) messages, non-private messages, or both.

For messages, this property specifies whether or not the message is private (encrypted).

Quick Info

Type: Long
Run time: read/write

Syntax

object.PrivLevel
 
Syntax Element Description
object For queues, the queue information (MSMQQueueInfo) object that defines the queue.

For messages, the message (MSMQMessage) object that defines the message.


Settings

For queues, set PrivLevel to one of the following values:

MQ_PRIV_LEVEL_NONE
The queue accepts only non-private (clear) messages.
MQ_PRIV_LEVEL_BODY
The queue accepts only private (encrypted) messages.
MQ_PRIV_LEVEL_OPTIONAL
The default. The queue does not force privacy. It accepts private (encrypted) messages and non-private (clear) messages.

For messages, set PrivLevel to one of the following values:

MQMSG_PRIV_LEVEL_NONE
The default. The message is a non-private (clear) message.
MQMSG_PRIV_LEVEL_BODY
The message is private (encrypted) message.

Remarks

Queue Privacy Level
The application can set the privacy level of queues and messages. If the privacy level of the message does not correspond to the privacy level of the queue, the message is rejected by the queue, and, if the sending application requested a negative acknowledgment message when it sent the message, MQMSG_CLASS_BAD_ENCRYPTION is returned to the sending application to indicate the message was rejected.

To specify the privacy level when creating the queue, set PrivLevel and call the MSMQQueueInfo object's Create method.

To reset the privacy level of a queue after the queue is created, set PrivLevel to a new level and, if the queue is open, call the MSMQQueueInfo object's Update method. If the queue is not open do not call Update, the queue's properties are updated automatically when the queue is opened.

To find out the privacy level of a queue, call the MSMQQueueInfo object's Refresh method.


Message Privacy Level
MSMQ can send private messages throughout the MSMQ enterprise. When sending a private message the source Queue manager encrypts the body of the message and the target queue manager decrypts the message body. For a discussion of private messages, see Private Messages.

When encrypting and decrypting messages, MSMQ uses the algorithm specified in EncryptAlgorithm.

For a complete example of sending a private message (including setting the privacy level of a queue), see Sending Private Messages.

Example: Setting the privacy level of a queue

This example creates a private queue on the local machine, setting the queue's privacy level to MQ_PRIV_LEVEL_OPTIONAL. To try this example using Microsoft Visual Basic (version 5.0), paste the code into the Code window of a form, and then run the example and click the form.

Dim qinfo As MSMQQueueInfo
   
Private Sub Form_Click()
    
  Set qinfo = New MSMQQueueInfo
  qinfo.PathName = ".\PRIVATE$\PrivacyLevelTest"
  qinfo.Label = "Test Queue"
  qinfo.PrivLevel = MQ_PRIV_LEVEL_OPTIONAL
  qinfo.Create
   
  MsgBox "Queue's Format name is: " + qinfo.FormatName

End Sub
 

Example: Setting the privacy level of a message

This example opens a queue that can only accept private messages, then sends a private message to the queue.

To try this example using Microsoft Visual Basic (version 5.0), paste the code into the Code window of a form, and then run the example and click the form.

Dim qinfo As MSMQQueueInfo
Dim q As MSMQQueue
Dim msg As New MSMQMessage

Private Sub Form_Click()
  '**********************
  ' Create queue
  '**********************
  Set qinfo = New MSMQQueueInfo
  qinfo.PathName = ".\PrivacyTest"
  qinfo.Label = "Test Queue"
  qinfo.PrivLevel = MQ_PRIV_LEVEL_BODY
  qinfo.Create
  '*********************
  ' Open queue.
  '*********************
  Set q = qinfo.Open(MQ_SEND_ACCESS, MQ_DENY_NONE)
  '*********************
  ' Send message.
  '*********************
  msg.Label = "Test Message"
  msg.Body = "This is a private message."
  msg.PrivLevel = MQMSG_PRIV_LEVEL_BODY
  
  msg.Send q
      
  q.Close
    
End Sub
 

See Also

Body, Create, Label, MSMQMessage, MSMQQueue, MSMQQueueInfo, Open, PathName, Refresh, Send, Update


© 1997 by Microsoft Corporation. All rights reserved.