NegotiateStream コンストラクター
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
NegotiateStream クラスの新しいインスタンスを初期化します。
オーバーロード
| 名前 | 説明 |
|---|---|
| NegotiateStream(Stream) |
指定したNegotiateStreamを使用して、Stream クラスの新しいインスタンスを初期化します。 |
| NegotiateStream(Stream, Boolean) |
指定したNegotiateStreamとストリーム クロージャの動作を使用して、Stream クラスの新しいインスタンスを初期化します。 |
注釈
指定したストリームを NegotiateStream が閉じないようにするには、 NegotiateStream(Stream, Boolean) コンストラクターを使用します。
NegotiateStream(Stream)
指定したNegotiateStreamを使用して、Stream クラスの新しいインスタンスを初期化します。
public:
NegotiateStream(System::IO::Stream ^ innerStream);
public NegotiateStream(System.IO.Stream innerStream);
new System.Net.Security.NegotiateStream : System.IO.Stream -> System.Net.Security.NegotiateStream
Public Sub New (innerStream As Stream)
パラメーター
- innerStream
- Stream
データの送受信にStreamによって使用されるNegotiateStream オブジェクト。
例
次のコード例は、このコンストラクターの呼び出しを示しています。
// 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(Stream, Boolean)
指定したNegotiateStreamとストリーム クロージャの動作を使用して、Stream クラスの新しいインスタンスを初期化します。
public:
NegotiateStream(System::IO::Stream ^ innerStream, bool leaveInnerStreamOpen);
public NegotiateStream(System.IO.Stream innerStream, bool leaveInnerStreamOpen);
new System.Net.Security.NegotiateStream : System.IO.Stream * bool -> System.Net.Security.NegotiateStream
Public Sub New (innerStream As Stream, leaveInnerStreamOpen As Boolean)
パラメーター
- innerStream
- Stream
データの送受信にStreamによって使用されるNegotiateStream オブジェクト。
- leaveInnerStreamOpen
- Boolean
trueこのNegotiateStreamを閉じることがinnerStreamに影響を与えないことを示す場合は。このfalseを閉じるとNegotiateStreamも閉じることを示す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);
' Establish the remote endpoint for the socket.
' For this example, use the local machine.
Dim ipHostInfo = Dns.GetHostEntry("localhost")
Dim ipAddress = ipHostInfo.AddressList(0)
' Client and server use port 11000.
Dim remoteEP As 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.
Dim clientStream = client.GetStream()
Dim authStream As New NegotiateStream(clientStream, False)
注釈
true パラメーターにleaveStreamOpenを指定した場合、NegotiateStreamを閉じるとinnerStream ストリームには影響しません。不要になったら、innerStreamを明示的に閉じる必要があります。