代码之家  ›  专栏  ›  技术社区  ›  Simsons

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

  •  1
  • Simsons  · 技术社区  · 14 年前

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

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

    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 .(Dot) . 当我从另一个系统运行客户端时,我得到了gle5(拒绝访问)。

    2 回复  |  直到 14 年前
        1
  •  1
  •   Ragster    14 年前

    (出现这个问题的次数多得数不清!)

        2
  •  1
  •   dyp    14 年前

    AFAIR Windows Vista中匿名访问命名管道的安全性发生了变化。
    当您想从匿名帐户打开它(具有写访问权限)时,您可能需要更改管道的安全属性,如下所述 here