NegotiateStreamとは? わかりやすく解説

NegotiateStream クラス

メモ : このクラスは、.NET Framework version 2.0 で新しく追加されたものです。

クライアント サーバー通信で Negotiate セキュリティ プロトコルを使用してクライアントの認証と、オプションでサーバーの認証を行うストリームを提供します。

名前空間: System.Net.Security
アセンブリ: System (system.dll 内)
構文構文

Public Class NegotiateStream
    Inherits AuthenticatedStream
Dim instance As NegotiateStream
public class NegotiateStream : AuthenticatedStream
public ref class NegotiateStream : public
 AuthenticatedStream
public class NegotiateStream extends AuthenticatedStream
public class NegotiateStream extends
 AuthenticatedStream
解説解説

NegotiateStream クラスを使用して認証を行い、クライアントとサーバー間で送信される情報のセキュリティ保護を支援します。NegotiateStream を使用すると、次の操作を行うことができます。

情報を送信する前に、認証を行う必要があります。クライアントは、認証が完了するまでブロックする同期メソッドの AuthenticateAsClient、または認証の完了を待機する間ブロックしない非同期メソッドの BeginAuthenticateAsClient を使用して認証を要求します。サーバーは、同期メソッドの AuthenticateAsServer または非同期メソッドの BeginAuthenticateAsServer を使用して認証を要求します。クライアント (オプションでサーバー) は、Negotiate セキュリティ プロトコルを使用して認証されます。Windows 95 システムおよび Windows 98 システムの場合、認証に使用するプロトコルは Windows NT LAN Manager (NTLM) です。その他のプラットフォームでは、クライアントとサーバーの両方が Kerberos プロトコルをサポートしている場合、Kerberos が認証に使用されます。それ以外の場合は NTLM が使用されます。これらのプロトコルの詳細な説明については、http://msdn.microsoft.com/library/ にあるプラットフォーム SDK に関するドキュメントを参照してください。NegotiateStream クラスは、SSPI (Security Support Provider Interface) を使用して認証を実行します。

認証が成功したら、送信中のデータのセキュリティを保護するために、IsEncrypted プロパティと IsSigned プロパティをチェックして NegotiateStream で使用するセキュリティ サービスを確認する必要があります。相互認証が行われたかどうかを確認するには、IsMutuallyAuthenticated プロパティをチェックします。RemoteIdentity プロパティを使用して、リモート クライアントまたはリモート サーバーに関する情報を取得することもできます。

認証が失敗した場合、AuthenticationException または InvalidCredentialException を受け取ります。この場合は、異なる資格情報を使用して、認証を再試行できます。

データの送信には、同期メソッドの Write または非同期メソッドの BeginWrite を使用します。データの受信には、同期メソッドの Read または非同期メソッドの BeginRead を使用します。暗号化や署名などのセキュリティ サービスが有効化な場合、NegotiateStream によって、これらのサービスが自動的にデータに適用されます。

NegotiateStream は、NegotiateStream の作成時に提供するストリームを使用してデータを送信します。この基になるストリームを提供するときには、NegotiateStream を閉じたときに基になるストリームも閉じるかどうかを指定するオプションがあります。

使用例使用例

NegotiateStream を使用するクライアント サーバー接続のクライアント側のコード例を次に示します。クライアントは認証を行い、サーバーにメッセージを非同期的に送信します。

using System;
using System.Net;
using System.Net.Security;
using System.Net.Sockets;
using System.Text;

namespace Examples.NegotiateStreamExample
{
    public class ASynchronousAuthenticatingTcpClient
 
    {   
        static TcpClient client = null;

        public static void
 Main(String[] args)  
        {
            // Establish the remote endpoint for the socket.
            // For this example, use the local machine.
            IPHostEntry ipHostInfo = Dns.GetHostEntry("localhost");
            IPAddress ipAddress = ipHostInfo.AddressList[0];
            // Client and server use port 11000. 
            IPEndPoint remoteEP = new IPEndPoint(ipAddress, 11000);
            // Create a TCP/IP socket.
            client = new TcpClient();
            // Connect the socket to the remote endpoint.
            client.Connect(remoteEP);
            Console.WriteLine("Client connected to {0}.", remoteEP.ToString());
            // Ensure the client does not close when there is 
            // still data to be sent to the server.
            client.LingerState = (new LingerOption(true,
 0));
            // Request authentication.
            NetworkStream clientStream = client.GetStream();
            NegotiateStream authStream = new NegotiateStream(clientStream,
 false); 
            // Pass the NegotiateStream as the AsyncState object 
            // so that it is available to the callback delegate.
            IAsyncResult ar = authStream.BeginAuthenticateAsClient(
                new AsyncCallback(EndAuthenticateCallback),
                authStream
                );
            Console.WriteLine("Client waiting for authentication...");
            // Wait until the result is available.
            ar.AsyncWaitHandle.WaitOne();
            // Display the properties of the authenticated stream.
            AuthenticatedStreamReporter.DisplayProperties(authStream);
            // Send a message to the server.
            // Encode the test data into a byte array.
            byte[] message = Encoding.UTF8.GetBytes("Hello from the client.");
            ar = authStream.BeginWrite(message, 0, message.Length,
                new AsyncCallback(EndWriteCallback),
                authStream);
            ar.AsyncWaitHandle.WaitOne();
            Console.WriteLine("Sent {0} bytes.", message.Length);
            // Close the client connection.
            authStream.Close();
            Console.WriteLine("Client closed.");
        }
        // The following method is called when the authentication completes.
        public static void
 EndAuthenticateCallback (IAsyncResult ar)
        {
            Console.WriteLine("Client ending authentication...");
            NegotiateStream authStream = (NegotiateStream) ar.AsyncState;

            // End the asynchronous operation.
            authStream.EndAuthenticateAsClient(ar);
//         Console.WriteLine("AllowedImpersonation: {0}",
 authStream.AllowedImpersonation);
        }
        // The following method is called when the write operation completes.
        public static void
 EndWriteCallback (IAsyncResult ar)
        {
            Console.WriteLine("Client ending write operation...");
            NegotiateStream authStream = (NegotiateStream) ar.AsyncState;

            // End the asynchronous operation.
            authStream.EndWrite(ar);
        }
    }

    // The following class displays the properties of an authenticatedStream.
    public class AuthenticatedStreamReporter
{
    public static void DisplayProperties(AuthenticatedStream
 stream)
   {
        Console.WriteLine("IsAuthenticated: {0}", stream.IsAuthenticated);
        Console.WriteLine("IsMutuallyAuthenticated: {0}", stream.IsMutuallyAuthenticated);
        Console.WriteLine("IsEncrypted: {0}", stream.IsEncrypted);
        Console.WriteLine("IsSigned: {0}", stream.IsSigned);
        Console.WriteLine("IsServer: {0}", stream.IsServer);
    }
}
}

クライアント サーバー接続のクライアント側が NegotiateStream を使用してクライアントの認証およびクライアントから送信されたメッセージの読み取りを行うコード例を次に示します。

using System;
using System.Net;
using System.Net.Security;
using System.Net.Sockets;
using System.Security.Authentication;
using System.Security.Principal;
using System.Text;
using System.IO;
using System.Threading;

namespace Examples.NegotiateStreamExample
{
    public class AsynchronousAuthenticatingTcpListener
 
    {
        public static void
 Main() 
        {   
            // Create an IPv4 TCP/IP socket. 
            TcpListener listener = new TcpListener(IPAddress.Any,
 11000);
            // Listen for incoming connections.
            listener.Start();
            while (true) 
            {
                TcpClient clientRequest = null;
                // Application blocks while waiting for an incoming
 connection.
                // Type CNTL-C to terminate the server.
                clientRequest = listener.AcceptTcpClient();
                Console.WriteLine("Client connected.");
                // A client has connected. 
                try
                {
                    AuthenticateClient (clientRequest);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    continue;
                }

            }
        
        }
        public static void
 AuthenticateClient(TcpClient clientRequest)
        {
            NetworkStream stream = clientRequest.GetStream(); 
            // Create the NegotiateStream.
            NegotiateStream authStream = new NegotiateStream(stream,
 false); 
            // Save the current client and NegotiateStream instance
 
            // in a ClientState object.
            ClientState cState = new ClientState(authStream, clientRequest);
            // Listen for the client authentication request.
            authStream.BeginAuthenticateAsServer (
                new AsyncCallback(EndAuthenticateCallback),
                cState
                );
            // Wait until the authentication completes.
            cState.Waiter.WaitOne();
            cState.Waiter.Reset();
            authStream.BeginRead(cState.Buffer, 0, cState.Buffer.Length, 
                   new AsyncCallback(EndReadCallback), 
                   cState);
            cState.Waiter.WaitOne();
            // Finished with the current client.
            authStream.Close();
            clientRequest.Close();
        }
        // The following method is invoked by the
        // BeginAuthenticateAsServer callback delegate.

        public static void
 EndAuthenticateCallback (IAsyncResult ar)
        {
            // Get the saved data.
            ClientState cState = (ClientState) ar.AsyncState;
            TcpClient clientRequest = cState.Client;
            NegotiateStream authStream = (NegotiateStream) cState.AuthenticatedStream;
            Console.WriteLine("Ending authentication.");
            // Any exceptions that occurred during authentication are
            // thrown by the EndAuthenticateAsServer method.
            try 
            {
                // This call blocks until the authentication is complete.
                authStream.EndAuthenticateAsServer(ar);
            }
            catch (AuthenticationException e)
            {
                Console.WriteLine(e);
                Console.WriteLine("Authentication failed - closing connection.");
                cState.Waiter.Set();
                return;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                Console.WriteLine("Closing connection.");
                cState.Waiter.Set();
                return;
            }
            // Display properties of the authenticated client.
            IIdentity id = authStream.RemoteIdentity;
            Console.WriteLine("{0} was authenticated using
 {1}.", 
                id.Name, 
                id.AuthenticationType
                );
            cState.Waiter.Set();

    }
        public static void
 EndReadCallback(IAsyncResult ar)
        {
            // Get the saved data.
            ClientState cState = (ClientState) ar.AsyncState;
            TcpClient clientRequest = cState.Client;
            NegotiateStream authStream = (NegotiateStream) cState.AuthenticatedStream;
 
            // Get the buffer that stores the message sent by the client.
            int bytes = -1;
            // Read the client message.
            try
            {
                    bytes = authStream.EndRead(ar);
                    cState.Message.Append(Encoding.UTF8.GetChars(cState.Buffer, 0,
 bytes));
                    if (bytes != 0)
                    {
                         authStream.BeginRead(cState.Buffer, 0, cState.Buffer.Length,
 
                               new AsyncCallback(EndReadCallback),
 
                               cState);
                               return;
                 }
            }
            catch (Exception e)
            {
                // A real application should do something
                // useful here, such as logging the failure.
                Console.WriteLine("Client message exception:");
                Console.WriteLine(e);
                cState.Waiter.Set();
                return;
            }
            IIdentity id = authStream.RemoteIdentity;
            Console.WriteLine("{0} says {1}", id.Name, cState.Message.ToString());
            cState.Waiter.Set();
        }
    }
    // ClientState is the AsyncState object.
    internal class ClientState
    {
        private AuthenticatedStream authStream = null;
        private  TcpClient client = null;
        byte[] buffer = new byte[2048];
        StringBuilder message = null;
        ManualResetEvent waiter = new ManualResetEvent(false);
        internal ClientState(AuthenticatedStream a, TcpClient theClient)
        {
            authStream = a;
            client = theClient;
        }
        internal TcpClient Client
        { 
            get { return client;}
        }
        internal AuthenticatedStream AuthenticatedStream
        {
            get { return authStream;}
        }
        internal byte[] Buffer
        {
              get { return buffer;}
        }
        internal StringBuilder Message
        {
            get 
            { 
                if (message == null)
                    message = new StringBuilder();
                return message;
             }
        }
        internal ManualResetEvent Waiter
        {
            get 
            { 
                return waiter;
             }
        }
    }
}
継承階層継承階層
System.Object
   System.MarshalByRefObject
     System.IO.Stream
       System.Net.Security.AuthenticatedStream
        System.Net.Security.NegotiateStream
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
NegotiateStream メンバ
System.Net.Security 名前空間

NegotiateStream コンストラクタ (Stream, Boolean)

メモ : このコンストラクタは、.NET Framework version 2.0 で新しく追加されたものです。

指定した Stream とストリームを閉じる動作を使用して、NegotiateStream クラスの新しいインスタンスを初期化します。

名前空間: System.Net.Security
アセンブリ: System (system.dll 内)
構文構文

Public Sub New ( _
    innerStream As Stream, _
    leaveInnerStreamOpen As Boolean _
)
Dim innerStream As Stream
Dim leaveInnerStreamOpen As Boolean

Dim instance As New NegotiateStream(innerStream,
 leaveInnerStreamOpen)
public NegotiateStream (
    Stream innerStream,
    bool leaveInnerStreamOpen
)
public:
NegotiateStream (
    Stream^ innerStream, 
    bool leaveInnerStreamOpen
)
public NegotiateStream (
    Stream innerStream, 
    boolean leaveInnerStreamOpen
)
public function NegotiateStream (
    innerStream : Stream, 
    leaveInnerStreamOpen : boolean
)

パラメータ

innerStream

NegotiateStream がデータの送受信に使用する Stream オブジェクト。

leaveInnerStreamOpen

この NegotiateStream を閉じても、innerstream が影響を受けないことを示す場合は true。この NegotiateStream を閉じると、innerStream も閉じられることを示す場合は false。詳細については「解説」を参照してください。

例外例外
例外の種類条件

ArgumentNullException

innerStream が null 参照 (Visual Basic では Nothing) です。

または

innerStream と Null が等価です。

解説解説

leaveStreamOpen パラメータに true を指定すると、NegotiateStream を閉じても innerStream ストリームには影響しません。innerStream が不要になった場合は、明示的に閉じる必要があります。

使用例使用例

このコンストラクタを実際に呼び出すコード例を次に示します。このコード例は、NegotiateStream クラスのトピックで取り上げているコード例の一部分です。

// Establish the remote endpoint for the socket.
// For this example, use the local machine.
IPHostEntry ipHostInfo = Dns.GetHostEntry("localhost");
IPAddress ipAddress = ipHostInfo.AddressList[0];
// Client and server use port 11000. 
IPEndPoint remoteEP = new IPEndPoint(ipAddress, 11000);
// Create a TCP/IP socket.
client = new TcpClient();
// Connect the socket to the remote endpoint.
client.Connect(remoteEP);
Console.WriteLine("Client connected to {0}.", remoteEP.ToString());
// Ensure the client does not close when there is 
// still data to be sent to the server.
client.LingerState = (new LingerOption(true,
 0));
// Request authentication.
NetworkStream clientStream = client.GetStream();
NegotiateStream authStream = new NegotiateStream(clientStream,
 false); 
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
NegotiateStream クラス
NegotiateStream メンバ
System.Net.Security 名前空間

NegotiateStream コンストラクタ

NegotiateStream クラスの新しいインスタンスを初期化します。

ユーザーが指定するストリームを NegotiateStream が閉じないようにするには、NegotiateStream(Stream,Boolean) コンストラクタを使用します。


オーバーロードの一覧オーバーロードの一覧
参照参照

関連項目

NegotiateStream クラス
NegotiateStream メンバ
System.Net.Security 名前空間

NegotiateStream コンストラクタ (Stream)

メモ : このコンストラクタは、.NET Framework version 2.0 で新しく追加されたものです。

Stream を指定して、NegotiateStream クラスの新しいインスタンスを初期化します。

名前空間: System.Net.Security
アセンブリ: System (system.dll 内)
構文構文

Public Sub New ( _
    innerStream As Stream _
)
Dim innerStream As Stream

Dim instance As New NegotiateStream(innerStream)
public NegotiateStream (
    Stream innerStream
)
public:
NegotiateStream (
    Stream^ innerStream
)
public NegotiateStream (
    Stream innerStream
)
public function NegotiateStream (
    innerStream : Stream
)

パラメータ

innerStream

NegotiateStream がデータの送受信に使用する Stream オブジェクト。

使用例使用例

このコンストラクタを実際に呼び出すコード例を次に示します。

 // Establish the remote endpoint for the socket.
 // For this example, use the local machine.
 IPHostEntry ipHostInfo = Dns.GetHostEntry(Dns.GetHostName());
 IPAddress ipAddress = ipHostInfo.AddressList[0];
 // Client and server use port 11000. 
 IPEndPoint remoteEP = new IPEndPoint(ipAddress,11000);
 // Create a TCP/IP socket.
TcpClient client = new TcpClient();
 // Connect the socket to the remote endpoint.
 client.Connect(remoteEP);
 Console.WriteLine("Client connected to {0}.",
     remoteEP.ToString());
 // Ensure the client does not close when there is 
 // still data to be sent to the server.
 client.LingerState = (new LingerOption(true
,0));
 // Request authentication.
 NetworkStream clientStream = client.GetStream();
 NegotiateStream authStream = new NegotiateStream(clientStream);
 
 // Request authentication for the client only (no mutual authentication).
 // Authenicate using the client's default credetials.
 // Permit the server to impersonate the client to access resources
 on the server only.
 // Request that data be transmitted using encryption and data signing.
 authStream.AuthenticateAsClient(
      (NetworkCredential) CredentialCache.DefaultCredentials, 
      "",
      ProtectionLevel.EncryptAndSign,
      TokenImpersonationLevel.Impersonation);
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
NegotiateStream クラス
NegotiateStream メンバ
System.Net.Security 名前空間

NegotiateStream プロパティ


パブリック プロパティパブリック プロパティ

( プロテクト プロパティ も参照)
  名前 説明
パブリック プロパティ CanRead オーバーライドされます。 基になるストリームが読み取り可能かどうかを示す Boolean 値を取得します。
パブリック プロパティ CanSeek オーバーライドされます。 基になるストリームがシーク可能かどうかを示す Boolean 値を取得します。
パブリック プロパティ CanTimeout オーバーライドされます。 基になるストリームがタイムアウトをサポートしているかどうかを示す Boolean 値を取得します。
パブリック プロパティ CanWrite オーバーライドされます。 基になるストリームが書き込み可能かどうかを示す Boolean 値を取得します。
パブリック プロパティ ImpersonationLevel サーバーでクライアントの資格情報を使用する方法を示す値を取得します。
パブリック プロパティ IsAuthenticated オーバーライドされます。 認証が成功したかどうかを示す Boolean 値を取得します。
パブリック プロパティ IsEncrypted オーバーライドされます。 この NegotiateStream がデータの暗号化を使用するかどうかを示す Boolean 値を取得します。
パブリック プロパティ IsMutuallyAuthenticated オーバーライドされます。 サーバーとクライアントの両方が認証されているかどうかを示す Boolean 値を取得します。
パブリック プロパティ IsServer オーバーライドされます。 この NegotiateStream が使用する接続のローカル側がサーバーとして認証されたかどうかを示す Boolean 値を取得します。
パブリック プロパティ IsSigned オーバーライドされます。 このストリームを使用して送信されるデータに署名するかどうかを示す Boolean 値を取得します。
パブリック プロパティ LeaveInnerStreamOpen  この AuthenticatedStream がデータの送受信に使用するストリームが、開いたままになっているかどうかを示す値を取得します。 ( AuthenticatedStream から継承されます。)
パブリック プロパティ Length オーバーライドされます。 基になるストリームの長さを取得します。
パブリック プロパティ Position オーバーライドされます。 基になるストリーム内の現在位置を取得または設定します。
パブリック プロパティ ReadTimeout オーバーライドされます。 読み取り操作がブロックしてデータを待機する時間を取得または設定します。
パブリック プロパティ RemoteIdentity この認証されたストリームを共有するリモート側の ID に関する情報を取得します。
パブリック プロパティ WriteTimeout オーバーライドされます。 書き込み操作がブロックしてデータを待機する時間を取得または設定します。
プロテクト プロパティプロテクト プロパティ
  名前 説明
プロテクト プロパティ InnerStream  この AuthenticatedStream がデータの送受信に使用するストリームを取得します。 ( AuthenticatedStream から継承されます。)
参照参照

関連項目

NegotiateStream クラス
System.Net.Security 名前空間

NegotiateStream メソッド


パブリック メソッドパブリック メソッド

( プロテクト メソッド も参照)
  名前 説明
パブリック メソッド AuthenticateAsClient オーバーロードされます。 クライアントによって呼び出され、クライアントとサーバー間の接続でクライアントと (オプションで) サーバーを認証します。
パブリック メソッド AuthenticateAsServer オーバーロードされます。 クライアント サーバー接続の認証のサーバー側を処理します。
パブリック メソッド BeginAuthenticateAsClient オーバーロードされます。 クライアントとサーバー間の接続のクライアント側を認証する非同期操作を開始します。
パブリック メソッド BeginAuthenticateAsServer オーバーロードされます。 クライアントとサーバー間の接続のサーバー側の認証を処理する非同期操作を開始します。
パブリック メソッド BeginRead オーバーライドされます。 ストリームからデータを読み取り、指定した配列に格納する非同期読み取り操作を開始します。
パブリック メソッド BeginWrite オーバーライドされます。 指定したバッファからストリームに Byte を書き込む非同期書き込み操作を開始します。
パブリック メソッド Close  現在のストリームを閉じ、現在のストリームに関連付けられているすべてのリソース (ソケット、ファイル ハンドルなど) を解放します。 ( Stream から継承されます。)
パブリック メソッド CreateObjRef  リモート オブジェクトとの通信に使用するプロキシの生成に必要な情報をすべて格納しているオブジェクトを作成します。 ( MarshalByRefObject から継承されます。)
パブリック メソッド Dispose オーバーロードされます。  
パブリック メソッド EndAuthenticateAsClient BeginAuthenticateAsClient の呼び出しで開始した保留中の非同期のクライアント認証操作を終了します。
パブリック メソッド EndAuthenticateAsServer BeginAuthenticateAsServer の呼び出しで開始した保留中の非同期のクライアント認証操作を終了します。
パブリック メソッド EndRead オーバーライドされます。 BeginRead の呼び出しで開始された、非同期の読み取り操作を終了します。
パブリック メソッド EndWrite オーバーライドされます。 BeginWrite の呼び出しで開始された、非同期の書き込み操作を終了します。
パブリック メソッド Equals  オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。)
パブリック メソッド Flush オーバーライドされます。 バッファに格納されたデータが基になるデバイスに書き込まれるようにします。
パブリック メソッド GetHashCode  特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。)
パブリック メソッド GetLifetimeService  対象のインスタンスの有効期間ポリシーを制御する、現在の有効期間サービス オブジェクトを取得します。 ( MarshalByRefObject から継承されます。)
パブリック メソッド GetType  現在のインスタンスの Type を取得します。 ( Object から継承されます。)
パブリック メソッド InitializeLifetimeService  対象のインスタンスの有効期間ポリシーを制御する、有効期間サービス オブジェクトを取得します。 ( MarshalByRefObject から継承されます。)
パブリック メソッド Read オーバーライドされます。 このストリームからデータを読み取り、指定した配列に格納します。
パブリック メソッド ReadByte  ストリームから 1 バイトを読み取り、ストリーム内の位置を 1 バイト進めます。ストリームの末尾の場合は -1 を返します。 ( Stream から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。)
パブリック メソッド Seek オーバーライドされます。 NotSupportedException をスローします。
パブリック メソッド SetLength オーバーライドされます。 基になるストリームの長さを設定します。
パブリック メソッド Synchronized  指定した Stream オブジェクトをラップするスレッド セーフな (同期された) ラッパーを作成します。 ( Stream から継承されます。)
パブリック メソッド ToString  現在の Object を表す String を返します。 ( Object から継承されます。)
パブリック メソッド Write オーバーライドされます。 指定したバッファとオフセットを使用して、基になるストリームに指定した Byte 数を書き込みます。
パブリック メソッド WriteByte  ストリームの現在位置にバイトを書き込み、ストリームの位置を 1 バイトだけ進めます。 ( Stream から継承されます。)
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

NegotiateStream クラス
System.Net.Security 名前空間

NegotiateStream メンバ

クライアント サーバー通信で Negotiate セキュリティ プロトコルを使用してクライアントの認証と、オプションでサーバーの認証を行うストリームを提供します。

NegotiateStream データ型で公開されるメンバを以下の表に示します。


パブリック コンストラクタパブリック コンストラクタ
パブリック プロパティパブリック プロパティ
( プロテクト プロパティ も参照)
  名前 説明
パブリック プロパティ CanRead オーバーライドされます。 基になるストリームが読み取り可能かどうかを示す Boolean 値を取得します。
パブリック プロパティ CanSeek オーバーライドされます。 基になるストリームがシーク可能かどうかを示す Boolean 値を取得します。
パブリック プロパティ CanTimeout オーバーライドされます。 基になるストリームがタイムアウトをサポートしているかどうかを示す Boolean 値を取得します。
パブリック プロパティ CanWrite オーバーライドされます。 基になるストリームが書き込み可能かどうかを示す Boolean 値を取得します。
パブリック プロパティ ImpersonationLevel サーバーでクライアントの資格情報を使用する方法を示す値を取得します。
パブリック プロパティ IsAuthenticated オーバーライドされます。 認証が成功したかどうかを示す Boolean 値を取得します。
パブリック プロパティ IsEncrypted オーバーライドされます。 この NegotiateStream がデータの暗号化を使用するかどうかを示す Boolean 値を取得します。
パブリック プロパティ IsMutuallyAuthenticated オーバーライドされます。 サーバーとクライアントの両方が認証されているかどうかを示す Boolean 値を取得します。
パブリック プロパティ IsServer オーバーライドされます。 この NegotiateStream が使用する接続のローカル側がサーバーとして認証されたかどうかを示す Boolean 値を取得します。
パブリック プロパティ IsSigned オーバーライドされます。 このストリームを使用して送信されるデータに署名するかどうかを示す Boolean 値を取得します。
パブリック プロパティ LeaveInnerStreamOpen  この AuthenticatedStream がデータの送受信に使用するストリームが、開いたままになっているかどうかを示す値を取得します。(AuthenticatedStream から継承されます。)
パブリック プロパティ Length オーバーライドされます。 基になるストリームの長さを取得します。
パブリック プロパティ Position オーバーライドされます。 基になるストリーム内の現在位置を取得または設定します。
パブリック プロパティ ReadTimeout オーバーライドされます。 読み取り操作がブロックしてデータを待機する時間を取得または設定します。
パブリック プロパティ RemoteIdentity この認証されたストリームを共有するリモート側の ID に関する情報を取得します。
パブリック プロパティ WriteTimeout オーバーライドされます。 書き込み操作がブロックしてデータを待機する時間を取得または設定します。
プロテクト プロパティプロテクト プロパティ
  名前 説明
プロテクト プロパティ InnerStream  この AuthenticatedStream がデータの送受信に使用するストリームを取得します。(AuthenticatedStream から継承されます。)
パブリック メソッドパブリック メソッド
( プロテクト メソッド も参照)
  名前 説明
パブリック メソッド AuthenticateAsClient オーバーロードされます。 クライアントによって呼び出され、クライアントとサーバー間の接続でクライアントと (オプションで) サーバーを認証します。
パブリック メソッド AuthenticateAsServer オーバーロードされます。 クライアント サーバー接続の認証のサーバー側を処理します。
パブリック メソッド BeginAuthenticateAsClient オーバーロードされます。 クライアントとサーバー間の接続のクライアント側を認証する非同期操作を開始します。
パブリック メソッド BeginAuthenticateAsServer オーバーロードされます。 クライアントとサーバー間の接続のサーバー側の認証を処理する非同期操作を開始します。
パブリック メソッド BeginRead オーバーライドされます。 ストリームからデータを読み取り、指定した配列に格納する非同期読み取り操作を開始します。
パブリック メソッド BeginWrite オーバーライドされます。 指定したバッファからストリームに Byte を書き込む非同期書き込み操作を開始します。
パブリック メソッド Close  現在のストリームを閉じ、現在のストリームに関連付けられているすべてのリソース (ソケット、ファイル ハンドルなど) を解放します。 (Stream から継承されます。)
パブリック メソッド CreateObjRef  リモート オブジェクトとの通信に使用するプロキシの生成に必要な情報をすべて格納しているオブジェクトを作成します。 (MarshalByRefObject から継承されます。)
パブリック メソッド Dispose オーバーロードされます。  
パブリック メソッド EndAuthenticateAsClient BeginAuthenticateAsClient の呼び出しで開始した保留中の非同期のクライアント認証操作を終了します。
パブリック メソッド EndAuthenticateAsServer BeginAuthenticateAsServer の呼び出しで開始した保留中の非同期のクライアント認証操作を終了します。
パブリック メソッド EndRead オーバーライドされます。 BeginRead の呼び出しで開始された、非同期の読み取り操作を終了します。
パブリック メソッド EndWrite オーバーライドされます。 BeginWrite の呼び出しで開始された、非同期の書き込み操作を終了します。
パブリック メソッド Equals  オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。)
パブリック メソッド Flush オーバーライドされます。 バッファに格納されたデータが基になるデバイスに書き込まれるようにします。
パブリック メソッド GetHashCode  特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。)
パブリック メソッド GetLifetimeService  対象のインスタンスの有効期間ポリシーを制御する、現在の有効期間サービス オブジェクトを取得します。 (MarshalByRefObject から継承されます。)
パブリック メソッド GetType  現在のインスタンスの Type を取得します。 (Object から継承されます。)
パブリック メソッド InitializeLifetimeService  対象のインスタンスの有効期間ポリシーを制御する、有効期間サービス オブジェクトを取得します。 (MarshalByRefObject から継承されます。)
パブリック メソッド Read オーバーライドされます。 このストリームからデータを読み取り、指定した配列に格納します。
パブリック メソッド ReadByte  ストリームから 1 バイトを読み取り、ストリーム内の位置を 1 バイト進めます。ストリームの末尾の場合は -1 を返します。 (Stream から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。)
パブリック メソッド Seek オーバーライドされます。 NotSupportedException をスローします。
パブリック メソッド SetLength オーバーライドされます。 基になるストリームの長さを設定します。
パブリック メソッド Synchronized  指定した Stream オブジェクトをラップするスレッド セーフな (同期された) ラッパーを作成します。 (Stream から継承されます。)
パブリック メソッド ToString  現在の Object を表す String を返します。 (Object から継承されます。)
パブリック メソッド Write オーバーライドされます。 指定したバッファとオフセットを使用して、基になるストリームに指定した Byte 数を書き込みます。
パブリック メソッド WriteByte  ストリームの現在位置にバイトを書き込み、ストリームの位置を 1 バイトだけ進めます。 (Stream から継承されます。)
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

NegotiateStream クラス
System.Net.Security 名前空間



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

「NegotiateStream」の関連用語

NegotiateStreamのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



NegotiateStreamのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS