.net – Sending message to private MSMQ queue with Authenticate checkbox checked

msmqmsmqintegrationbindingnetwcf

Before posting this question, I searched through all forum threads. I found that my issue is similar to the Sending to authenticated queue However that thread doesn't really answered my question.

I have following setup (using .NET applications and MSMQ)

  • Installed MSMQ with Active Directory Services Integrated mode on my Windows7 64 bit machine.
  • I have created two private Queues (PQ1 and PQ2) as a Transactional queues and configured its Security tab to give full access to domain user id (domain user id which is also Administartor on Win7 machine).
  • In my project I have three .NET 4.0 applications which are hosted by Windows Service (running with the access rights of same domain user id) on this Windows 7 machine
  • First .NET application is running on its own thread that reads data from database and sends MSMQ message to PQ1 queue
  • Second and third are WCF applications (say wcfA and wcfB) self hosted from Windows service.
  • wcfA and wcfB are configured for MsmqIntegrationBinding with Transport security mode with properties mqAuthenticationMode set to "WindowsDomain" and msmqProtectionLevel set to "EncryptAndSign"
  • wcfA picks up messages from PQ1 and then processes the message and send another MSMQ message to PQ2
  • wcfB picks up the messages from PQ2 and proccesses it

Note that everything works OK in above setup.

However the issue starts when I enable the "Authenticated" checkbox for the private Queues PQ1 and PQ2 on its General tab. After this settings, the first application sends the MSMQ message to private queue but it ends up in "Transaction dead-letter messages" queue.
I tried adding Authenticated Users group to the Queue security tab and giving full access but it did not work.

Further to this I also observed that the Sender tab on Property page of the message that goes to dead-letter queue reads Authenticated: No

Your help is highly appreciated to make the applications work with Authenticated Queue.

Best Answer

After initializing a Message object, set the UseAuthentication property to true.

Example for sending a message to an authenticated queue:

private void SendToQueue(string queueMessage)
{
   var message = new System.Messaging.Message(queueMessage);
   message.UseDeadLetterQueue = true;            

   // This line resolved issue for sending message to queue with Authenticate checkbox checked. 
   message.UseAuthentication = true; 

   var queue = new System.Messaging.MessageQueue(@"FormatName:Direct=OS:.\private$\PQ1");
   queue.Send(message, MessageQueueTransactionType.Single);
}
Related Topic