Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / .NET SDK / July 2004

Tip: Looking for answers? Try searching our database.

MessageQueue.Receive access denied

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
pl_dave - 18 Jun 2004 18:00 GMT
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!
pl_dave - 19 Jun 2004 05:43 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.

> 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;
Shell D00d - 05 Jul 2004 11:07 GMT
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;

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.