开发者

How to access a private MSMQ queue created by NETWORK SERVICE account?

开发者 https://www.devze.com 2023-03-01 17:26 出处:网络
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, every

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


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
);


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

0

精彩评论

暂无评论...
验证码 换一张
取 消