2012-11-01 28 views
9

NamedPipeServerStreamに接続するNamedPipeClientStreamがあります。 NamedPipeServerStreamがクライアントパイプを再作成して引き続きリスニングしている間に、それらは2つのメッセージを交換し、NamedPipeClientStreamを閉じる。 (私は非同期のサーバーパイプを作れませんでしたので、これは何らかの犬の爪です)NamedPipeClientStreamはセッション0でNamedPipeServerStreamにアクセスできません

クライアントのストリームが正常なユーザーセッションから起動されている間、クライアントとサーバーのやりとりはうまく動作します。

しかし、Win7とwin2008サーバー上でセッション0からクライアントパイプが起動される状況があります。これが起こるとき、私はクライアントのストリームにエラーました:

「パスへのアクセスが拒否されましたが、」

問題は何ですか?それを避ける方法は?

申し訳ありません申し訳ありませんが、例外についての詳細を教えてください。私はログにこのメッセージしか持っていません。そして、ゼロセッションから私のプログラムをデバッグすることはできませんか?

サーバーストリームコード:

PipeSecurity ps = new PipeSecurity(); 
System.Security.Principal.SecurityIdentifier sid = new System.Security.Principal.SecurityIdentifier(System.Security.Principal.WellKnownSidType.BuiltinUsersSid, null); 
PipeAccessRule par = new PipeAccessRule(sid, PipeAccessRights.ReadWrite, System.Security.AccessControl.AccessControlType.Allow); 
ps.AddAccessRule(par); 
pipeClientConnection = new NamedPipeServerStream(General.PIPENAME, PipeDirection.InOut, 1, PipeTransmissionMode.Byte, PipeOptions.Asynchronous, General.BUFFERSIZE, General.BUFFERSIZE, ps); 
Console.Write("Waiting for client connection..."); 
IAsyncResult result = pipeClientConnection.BeginWaitForConnection(OnPipeConnected, pipeClientConnection); 

たぶん何かがセキュリティ設定が間違っていますか?

そして、クライアントコード:

using (NamedPipeClientStream pipeStream = new NamedPipeClientStream(".", General.PIPENAME, PipeDirection.InOut)) 
{ 
    try 
    { 
     Console.WriteLine("Connecting with pipe..."); 
     pipeStream.Connect(General.CONNECTIONTIMEOUT); 
     Console.WriteLine("Pipe connection established"); 
     //..do something.. 
    } 
    //... 
} 

サーバはLocalSystemの下で、Windowsサービスとして起動されます。クライアント - はシンプルなコンソールアプリケーションです。 LocalSystemサービスから起動された別のアプリケーションによって起動されます。問題は、ここでのセキュリティ設定にあったよう

答えて

12

はルックス:

System.Security.Principal.SecurityIdentifier sid = new System.Security.Principal.SecurityIdentifier(System.Security.Principal.WellKnownSidType.BuiltinUsersSid, null); 

は次のようになります。

System.Security.Principal.SecurityIdentifier sid = new System.Security.Principal.SecurityIdentifier(System.Security.Principal.WellKnownSidType.WorldSid, null); 

おかげmicrosoft communnity

+9

リンクが壊れています。私はマイクロソフトがウェブサイトを再編成し、何百万ものリンクをインターネット上に残していることを嫌っている。 – RenniePet

関連する問題