i wrote a simple app that creates and uses a private message queue. the Send completes without errors, however when i call Receive i always get a message queue exception saying access denied. the CanRead property is false.
the messagequeue constructor does not ask for exclusive access. there is no other program using this private queue. the server explorer gets the same error if i browse to the private queue.
this is running on an XP pro platform under an administrator account. there is a lot of stuff installed for development, but no special security settings.
any ideas about what's causing this? thanks!
the problem was that the queue was created by a service that i wrote. since that service was not running under my account, i was not the creator of the queue. even as administrator, i didn't have authority to read or delete the queue. so to solve the problem, i made the service delete the queue and then recreated it by using the computer management console. now it's all working fine.
> i wrote a simple app that creates and uses a private message queue. the Send completes without errors, however when i call Receive i always get a message queue exception saying access denied. the CanRead property is false.
>
[quoted text clipped - 3 lines]
>
> any ideas about what's causing this? thanks!
Klaus H. Probst - 30 Jun 2004 22:20 GMT
You could have also taken ownership of the queue.

Signature
Klaus H. Probst, MVP
http://www.vbbox.com/
> the problem was that the queue was created by a service that i wrote. since that service was not running under my account, i was not the creator
of the queue. even as administrator, i didn't have authority to read or
delete the queue. so to solve the problem, i made the service delete the
queue and then recreated it by using the computer management console. now
it's all working fine.
> > i wrote a simple app that creates and uses a private message queue. the Send completes without errors, however when i call Receive i always get a
message queue exception saying access denied. the CanRead property is
false.
> > the messagequeue constructor does not ask for exclusive access. there is no other program using this private queue. the server explorer gets the
same error if i browse to the private queue.
> > this is running on an XP pro platform under an administrator account. there is a lot of stuff installed for development, but no special security
settings.
> > any ideas about what's causing this? thanks!
Shell D00d - 05 Jul 2004 11:12 GMT
> the problem was that the queue was created by a service that i wrote. since that service was not running under my account, i was not the creator of the queue. even as administrator, i didn't have authority to read or delete the queue. so to solve the problem, i made the service delete the queue and then recreated it by using the computer management console. now it's all working fine.
Hi,
I've just posted code that allows the current user to access the
queue. However, I posted it under your previous post as I hadn't seen
this one! (silly me). Here it is again, anyway:
using System.Messaging;
AccessControlList acl = new AccessControlList();
Trustee trustee = new Trustee("SYSTEM", Environment.MachineName,
System.Messaging.TrusteeType.Group);
Trustee owner = new Trustee(System.Security.Principal.WindowsIdentity.GetCurrent().Name,
Environment.MachineName, System.Messaging.TrusteeType.User);
MessageQueueAccessControlEntry aceSystem = new
System.Messaging.MessageQueueAccessControlEntry(trustee,
System.Messaging.MessageQueueAccessRights.FullControl);
MessageQueueAccessControlEntry aceOwner = new
System.Messaging.MessageQueueAccessControlEntry(owner,
System.Messaging.MessageQueueAccessRights.FullControl);
acl.Add(aceSystem);
acl.Add(aceOwner);
myQueue.Permissions = acl;
Hi,
I've noticed the same problem when creating a queue programatically in
both XP and 2k, but only on some machines. I'm not sure... I think it
has something to do with security policy or something.
Anyway, I sort of solved the problem by setting the security
permissions on the queue manually while creating the queue. Not a very
elegant solution, but it served my purpose at the time:
using System.Messaging;
AccessControlList acl = new AccessControlList();
Trustee trustee = new Trustee("SYSTEM", Environment.MachineName,
System.Messaging.TrusteeType.Group);
Trustee owner = new Trustee(System.Security.Principal.WindowsIdentity.GetCurrent().Name,
Environment.MachineName, System.Messaging.TrusteeType.User);
MessageQueueAccessControlEntry aceSystem = new
System.Messaging.MessageQueueAccessControlEntry(trustee,
System.Messaging.MessageQueueAccessRights.FullControl);
MessageQueueAccessControlEntry aceOwner = new
System.Messaging.MessageQueueAccessControlEntry(owner,
System.Messaging.MessageQueueAccessRights.FullControl);
acl.Add(aceSystem);
acl.Add(aceOwner);
myQueue.Permissions = acl;