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

发布于 2024-09-17 20:09:30 字数 986 浏览 4 评论 0原文

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

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

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;
      }

在创建命名管道时,我使用了

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

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

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 myServerName I have used .(Dot). I get GLE 5 (Access denied) while I run the client from another system.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

童话 2024-09-24 20:09:30

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

(这个问题出现的次数我都数不过来了!)

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!)

紅太極 2024-09-24 20:09:30

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

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文