NegotiateStream Costruttori
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Inizializza una nuova istanza della classe NegotiateStream.
Overload
| Nome | Descrizione |
|---|---|
| NegotiateStream(Stream) |
Inizializza una nuova istanza della NegotiateStream classe utilizzando l'oggetto specificato Stream. |
| NegotiateStream(Stream, Boolean) |
Inizializza una nuova istanza della NegotiateStream classe utilizzando il comportamento di chiusura del flusso e specificato Stream . |
Commenti
Per impedire la chiusura del NegotiateStream flusso fornito, usare il NegotiateStream(Stream, Boolean) costruttore .
NegotiateStream(Stream)
- Origine:
- NegotiateStream.cs
- Origine:
- NegotiateStream.cs
- Origine:
- NegotiateStream.cs
- Origine:
- NegotiateStream.cs
- Origine:
- NegotiateStream.cs
Inizializza una nuova istanza della NegotiateStream classe utilizzando l'oggetto specificato 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)
Parametri
- innerStream
- Stream
Oggetto Stream utilizzato dall'oggetto per l'invio NegotiateStream e la ricezione di dati.
Esempio
Nell'esempio di codice seguente viene illustrata la chiamata a questo costruttore.
// 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);
Si applica a
NegotiateStream(Stream, Boolean)
- Origine:
- NegotiateStream.cs
- Origine:
- NegotiateStream.cs
- Origine:
- NegotiateStream.cs
- Origine:
- NegotiateStream.cs
- Origine:
- NegotiateStream.cs
Inizializza una nuova istanza della NegotiateStream classe utilizzando il comportamento di chiusura del flusso e specificato 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)
Parametri
- innerStream
- Stream
Oggetto Stream utilizzato dall'oggetto per l'invio NegotiateStream e la ricezione di dati.
- leaveInnerStreamOpen
- Boolean
true per indicare che la chiusura di questa NegotiateStream proprietà non ha alcun effetto su innerStream; false per indicare che la chiusura di questa NegotiateStream operazione chiude innerStreamanche .
Eccezioni
Esempio
Nell'esempio seguente viene illustrata la chiamata a questo costruttore. Questo esempio di codice fa parte di un esempio più ampio fornito per la NegotiateStream classe .
// 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)
Commenti
Quando si specifica true per il leaveStreamOpen parametro , la chiusura di NegotiateStream non ha alcun effetto sul innerStream flusso; è necessario chiudere innerStream in modo esplicito quando non è più necessaria.