Getting An "Access Is Denied" Error When Opening A MailSlot Created By Another User

We have a VB6 app that creates a mailslot, and we have a VB.NET service that writes to the mailslot. When the two run as the same user, or if the service runs as the LocalSystemAccount, everything works fine. But if I have the service run as another user, even if the user has Admin privileges, the service gets an "Access Is Denied" error when opening the mailslot.

I can't find any info on setting a mailslot's access level.

VB6 Code:
    sa.bInheritHandle = True
    sa.lpSecurityDescriptor = 0
    sa.nLength = Len(sa)
    hMailSlot = CreateMailslot("\\.\mailslot\uniquemailslotname", Len(mm), 0, sa)

                sa.nLength = Len(sa)
                sa.bInheritHandle = True
                mHandle = New IntPtr(CreateFile("\\.\mailslot\uniquemailslotname", _
                                    GENERIC_READ Or GENERIC_WRITE, _
                                    FILE_SHARE_READ Or FILE_SHARE_WRITE, _
                                    sa, _
                                    OPEN_EXISTING, _
                                    FILE_ATTRIBUTE_NORMAL, _

    mHandle.ToInt32 will equal INVALID_HANDLE_VALUE
    Calling FormatMessage(Marshal.GetLastWin32Error)) returns "Access is denied."

Any help is appreciated!
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sgutmannAuthor Commented:
Solved my own problem...

Turns out there are a few workarounds:
1. Simply use the computer name instead of a . and that forces the mailslot to grant access to everyone.
2. Set the security descriptor (sa.lpSecurityDescriptor) to a DACL with the proper read/write acccess.
Because you have presented a solution to your own problem which may be helpful to future searches, this question is now PAQed and your points have been refunded.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.