4

My application consists of two part: a web service, which sends queues to a private MSMQ queue, and a Windows service, which takes queues and inserts them to database. In my development machine, everything's fine, but when I deploy them to the server, a permission issue was risen:

  • The webservice, runs inside IIS, use NETWORK SERVICE account to create the queue.
  • the service itself, runs as administrator, and then cannot access the queue.

I tried to add permissions for administrator account, but failed with error "Access is denied". I even cannot delete these queues.

How can I fix this? Thank you very much

Delta76
  • 13,931
  • 30
  • 95
  • 128

2 Answers2

5

When the webservice creates the queue it should make sure that it has appropriate access rights. If you are using .NET you can use the MessageQueue.SetPermissions method to modify the permissions of the queue after it has been 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
);
Martin Liversage
  • 104,481
  • 22
  • 209
  • 256
1

Add NETWORK SERVICE and Administrators rights both. at the time of Create queue.

and if you want to delete queue then follow this step...

https://stackoverflow.com/a/11430249/672891

Community
  • 1
  • 1
Rikin Patel
  • 8,848
  • 7
  • 70
  • 78