.NETGURU
MessageQueue.Receive access denied
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.sdk.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Post a new message to this list...

pl dave (VIP)
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!
Reply to this message...
 
    
pl dave (VIP)
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.

"pl_dave" wrote:

[Original message clipped]

Reply to this message...
 
    
Klaus H. Probst
You could have also taken ownership of the queue.

--
Klaus H. Probst, MVP
http://www.vbbox.com/

"pl_dave" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
> 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.
[Original message clipped]

message queue exception saying access denied. the CanRead property is
false.
[Original message clipped]

same error if i browse to the private queue.
[Original message clipped]

settings.
[Original message clipped]

Reply to this message...
 
    
Shell D00d
"pl_dave" <Click here to reveal e-mail address> wrote in message news:<Click here to reveal e-mail address>...
> 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;
Reply to this message...
 
    
Shell D00d
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;
Reply to this message...
 
 
System.Environment
System.Messaging.AccessControlList
System.Messaging.MessageQueueAccessControlEntry
System.Messaging.MessageQueueAccessRights
System.Messaging.Trustee
System.Messaging.TrusteeType
System.Security.Principal.WindowsIdentity




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification