How do I access the MSMQ private queue created by the NETWORK SERVICE account?

My application consists of two parts: a web service that sends queues to a private MSMQ queue and a Windows service that accepts queues and inserts them into the database. Everything is fine in my development machine, but when I deploy them to the server, the permission issue was raised:

  • The web service running inside IIS uses the NETWORK SERVICE account to create the queue.
  • the service itself, works as an administrator, and then cannot access the queue.

I tried to add permissions for the administrator account, but failed with the "Access denied" error. I can’t even delete these queues.

How can i fix this? Thank you very much

+4
source share
2 answers

When a web service creates a queue, it must ensure that it has the appropriate access rights. If you are using .NET, you can use the MessageQueue.SetPermissions method to change the queue permissions after it is created.

This C # code will create a new message queue and give the local administrators group full control over it:

var messageQueue = MessageQueue.Create(path, true); messageQueue.SetPermissions( "Administrators", MessageQueueAccessRights.FullControl ); 
+5
source

Add NETWORK SERVICE and administrator rights. during queue creation.

and if you want to delete the queue, then complete this step ...

fooobar.com/questions/423181 / ...

+1
source

All Articles