共用方式為


PROPID_M_PROV_NAME

 

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 PROPID_M_PROV_NAME property specifies the name of the cryptographic provider used to generate the digital signature attached to the message.

Property ID

PROPID_M_PROV_NAME

Type Indicator

VT_LPWSTR

MQPROPVARIANT Field

pwszVal

Property Value

Unicode string specifying the provider name. For MSMQ 1.0 and MSMQ 2.0, the only supported string is "Microsoft Base Cryptographic Provider, v1.0". For MSMQ 3.0, "Microsoft Enhanced Cryptographic Provider, v1.0" is also supported. In all cases, the default is the name of the base provider.

Remarks

The PROPID_M_PROV_NAME property can be used when working with foreign queues. The name and type (PROPID_M_PROV_TYPE) of the cryptographic provider are required to validate the digital signatures attached to messages sent to a foreign queue or to messages passed to Message Queuing from a foreign messaging system.

To send the name of the cryptographic provider with the message, specify PROPID_M_PROV_NAME and PROPID_M_PROV_TYPE in the MQMSGPROPS structure and call MQSendMessage.

When PROPID_M_PROV_NAME is specified, Message Queuing automatically sets PROPID_M_PROV_NAME_LEN to the length of the provider name.

To retrieve the name of the cryptographic provider from a message, specify PROPID_M_PROV_NAME and PROPID_M_PROV_NAME_LEN in the MQMSGPROPS structure (the length property can be used to verify that the cryptographic provider name was sent). Then call MQReceiveMessage or MQReceiveMessageByLookupId and examine the returned values.

If the name of the cryptographic provider was not sent with the message, the name of the default cryptographic provider is retrieved.

If MQReceiveMessage or MQReceiveMessageByLookupId fails, returning an MQ_ERROR_PROV_NAME_BUFFER_TOO_SMALL error, use the returned value of PROPID_M_PROV_NAME_LEN to reallocate the provider name buffer and call the applicable function again.

Before using the cryptographic provider name, always check the length property PROPID_M_PROV_NAME_LEN to see if the cryptographic provider name was sent with the message. If the returned value of PROPID_M_PROV_NAME_LEN is 0, no format name was sent with the message. If the returned value is non-0, PROPID_M_PROV_NAME contains the name of the cryptographic provider.

Equivalent COM Property

With COM components, the equivalent property for setting and retrieving the name of the cryptographic provider is MSMQMessage.AuthenticationProviderName.

For information on See
Working with foreign queues Connector Services
Testing to see if a provider name was sent PROPID_M_PROV_NAME_LEN

Example Code

The following code fragments show how PROPID_M_PROV_NAME is specified in arrays that can be used to initialize an MQMSGPROPS structure for setting and retrieving the cryptographic provider.

To Send the Cryptographic Provider Name

aMsgPropId[i] = PROPID_M_PROV_NAME;               // Property ID  
aMsgPropVar[i].vt = VT_LPWSTR;                    // Type indicator  
aMsgPropVar[i].pwszVal = wszProviderName;  
i++;  
  
aMsgPropId[i] = PROPID_M_PROV_TYPE;               // Property ID  
aMsgPropVar[i].vt = VT_UI4;                       // Type indicator  
aMsgPropVar[i].ulVal = dwProviderType;  
i++;  

To Retrieve the Cryptographic Provider Name

ULONG ulProviderNameLength = 64;  
WCHAR * wszProviderNameBuffer = NULL;  
wszProviderNameBuffer = (WCHAR*)malloc(ulProviderNameLength*sizeof(WCHAR));  
if (wszProviderNameBuffer == NULL)  
{  
  return MQ_ERROR_INSUFFICIENT_RESOURCES;  
}  
memset(wszProviderNameBuffer, 0, ulProviderNameLength*sizeof(WCHAR));  
aMsgPropId[i] = PROPID_M_PROV_NAME_LEN;           // Property ID  
aMsgPropVar[i].vt = VT_UI4;                       // Type indicator  
aMsgPropVar[i].ulVal = ulProviderNameLength;  
i++;  
  
aMsgPropId[i] = PROPID_M_PROV_NAME;               // Property ID  
aMsgPropVar[i].vt = VT_LPWSTR;                    // Type indicator  
aMsgPropVar[i].pwszVal = wszProviderNameBuffer;  
i++;  
  
// Reallocate the cryptographic provider name buffer if necessary.  
wszProviderNameBuffer = (WCHAR*)realloc(wszProviderNameBuffer, aMsgPropVar[0].ulVal*sizeof(WCHAR));  
if (wszProviderNameBuffer == NULL)  
{  
  return MQ_ERROR_INSUFFICIENT_RESOURCES;  
}  
memset(wszProviderNameBuffer, 0, aMsgPropVar[0].ulVal*sizeof(WCHAR));  
aMsgPropVar[1].pwszVal = wszProviderNameBuffer;  // Pointer to the new buffer  

See Also

Message Properties
MQMSGPROPS
MQReceiveMessage
MQReceiveMessageByLookupId
MQSendMessage
MSMQMessage.AuthenticationProviderName
PROPID_M_PROV_NAME_LEN
PROPID_M_PROV_TYPE