Handle not installed for named pipe on WS 2008 R2

I have unsuccessfully opened a named pipe on Windows Server 2008 R2 Prestaged Hosting and yet I had no problem developing this code at all while developing a WS 2008 R2 host (which should be configured identically) and testing this pipe to work.

The application has a WCF RESTful web service in IIS that connects to a Windows service through a named pipe. The Windows service then queries the Oracle DB through a Perl script. But in a pre-production intermediate plant, we never get that far because the pipe won't open.

The first problem was an access violation. When I cured that with the PipeSecurity instance I get the missing handle exception. I all work as an Administrator for both hosts. I made all linked folders available on the pre-host (yes, I'll pin it again once it works). the IIS logs show nothing unusual about the WCF service.

Here's the code from the development host that worked out of the box with no problems.

ClientPipe = new NamedPipeClientStream(
".", "QueryPipe", PipeDirection.InOut, PipeOptions.None,
TokenImpersonationLevel.None);

ClientPipe.Connect();

      

Simple and straightforward.

Here is the code from a pre-production staging node that I fiddled with endlessly to try and get it to work.

ClientPipe =
    new NamedPipeClientStream(".", "QueryPipe",
      PipeAccessRights.FullControl,
      PipeOptions.None,
      TokenImpersonationLevel.None,
      HandleInheritability.None);

PipeSecurity _ps = new PipeSecurity();

  _ps.AddAccessRule(new PipeAccessRule(
  WindowsIdentity.GetCurrent().User,
    PipeAccessRights.FullControl, AccessControlType.Allow));

_  ps.AddAccessRule(new PipeAccessRule(
    "SYSTEM", PipeAccessRights.FullControl, AccessControlType.Allow));

ClientPipe.SetAccessControl(_ps);

ClientPipe.Connect();

      

Using the PipeSecurity class cured the initial access permissions issue (thanks to Chris Dixon's 2010 answer on configuring pipe access).

But after setting access control I get this exception:

** Pipe Error: System.InvalidOperationException:
Pipe handle has not been set. 
Did your PipeStream implementation call InitializeHandle?

      

I have Googled it to blue at my fingertips but didn’t get a helpful answer. It seems like I should have already set the handle just using the constructor. InitializeHandle shouldn't be applied here.

So, I look at your experience in these matters.

+3


source to share


1 answer


It may have a rights issue: therefore, you need to grant the required access rights.

PipeSecurity _pipeSecurity = new PipeSecurity();
                PipeAccessRule psEveryone = new PipeAccessRule("Everyone", PipeAccessRights.FullControl, System.Security.AccessControl.AccessControlType.Allow);


           _pipeSecurity.AddAccessRule(psEveryone);

            NamedPipeServerStream pipeServer = new NamedPipeServerStream(PipeName,
                               PipeDirection.In, 1, PipeTransmissionMode.Message, PipeOptions.Asynchronous, 4, 4, _pipeSecurity);

      



And to solve the listening problem only once, follow this setting: Right click on the appropriate service> Properties> Logon> Log on as: Local System Account and click "Allow Service" to interact with the desktop. Or go to the ServiceProcessInstaller property and set the account as LocalSystem.

0


source







All Articles