windows 从另一个系统访问命名管道时访问被拒绝

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3667144/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 15:12:22  来源:igfitidea点击:

Getting Access Denied While Accessing the Named Pipe from Another System

c++windowsnamed-pipesaccess-deniedgetlasterror

提问by Simsons

I have a Named Pipe and It Works Fine While I access it using a Client which runs on My System

我有一个命名管道,当我使用在我的系统上运行的客户端访问它时它工作正常

The Client tries to open the File using following code:

客户端尝试使用以下代码打开文件:

LPTSTR lpszPipename = TEXT("\\smyServerName\pipe\iPipe01"); 

      hPipe = CreateFile( 
         lpszPipename,   // pipe name 
         GENERIC_READ |  // read and write access 
         GENERIC_WRITE, 
         0,              // no sharing 
         NULL,           // default security attributes
         OPEN_EXISTING,  // opens existing pipe 
         0,              // default attributes 
         NULL);     


      if (hPipe != INVALID_HANDLE_VALUE) 
         break; 

      // Exit if an error other than ERROR_PIPE_BUSY occurs. 

      if (GetLastError() != ERROR_PIPE_BUSY) 
      {
         _tprintf( TEXT("Could not open pipe. GLE=%d\n"), GetLastError() ); 
         return -1;
      }

While Creating the Named Pipe I have used

在创建我使用的命名管道时

lpszPipename = TEXT("\\.\pipe\iPipe01"); 

Instead of myServerNameI have used .(Dot). I get GLE 5 (Access denied) while I run the client from another system.

而不是myServerName我使用了.(Dot). 当我从另一个系统运行客户端时,我得到 GLE 5(拒绝访问)。

采纳答案by Ragster

First things first - check your permissions and firewall. Almost always, when something works locally but not on the network, it's permissions.

首先要做的事情 - 检查您的权限和防火墙。几乎总是,当某些东西在本地运行但不在网络上时,它是权限。

(Had this problem more times than I can count!)

(遇到这个问题的次数多得我数不过来!)

回答by dyp

AFAIR there was a change of security of anonymous access to named pipes in Windows Vista.
When you want to open it (with write access) from the anonymous account, you may have to change the pipe's security attributes as described here.

AFAIR 在 Windows Vista 中匿名访问命名管道的安全性发生了变化。
当您想从匿名帐户打开它(具有写访问权限)时,您可能必须按照此处所述更改管道的安全属性。