HttpListener.UnsafeConnectionNtlmAuthentication Properti
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Mendapatkan atau menetapkan Boolean nilai yang mengontrol apakah, ketika NTLM digunakan, permintaan tambahan menggunakan koneksi Protokol Kontrol Transmisi (TCP) yang sama diperlukan untuk mengautentikasi.
public:
property bool UnsafeConnectionNtlmAuthentication { bool get(); void set(bool value); };
public bool UnsafeConnectionNtlmAuthentication { get; set; }
member this.UnsafeConnectionNtlmAuthentication : bool with get, set
Public Property UnsafeConnectionNtlmAuthentication As Boolean
Nilai Properti
true
IIdentity jika permintaan pertama akan digunakan untuk permintaan berikutnya pada koneksi yang sama; jika tidak, false
. Nilai defaultnya adalah false
.
Pengecualian
Objek ini telah ditutup.
Contoh
Contoh kode berikut menunjukkan pengaturan properti ini.
public static void SimpleListenerWithUnsafeAuthentication(string[] prefixes)
{
// URI prefixes are required,
// for example "http://contoso.com:8080/index/".
if (prefixes == null || prefixes.Length == 0)
throw new ArgumentException("prefixes");
// Set up a listener.
HttpListener listener = new HttpListener();
foreach (string s in prefixes)
{
listener.Prefixes.Add(s);
}
listener.Start();
// Specify Negotiate as the authentication scheme.
listener.AuthenticationSchemes = AuthenticationSchemes.Negotiate;
// If NTLM is used, we will allow multiple requests on the same
// connection to use the authentication information of first request.
// This improves performance but does reduce the security of your
// application.
listener.UnsafeConnectionNtlmAuthentication = true;
// This listener does not want to receive exceptions
// that occur when sending the response to the client.
listener.IgnoreWriteExceptions = true;
Console.WriteLine("Listening...");
// ... process requests here.
listener.Close();
}
Public Shared Sub SimpleListenerWithUnsafeAuthentication(ByVal prefixes As String())
' URI prefixes are required,
' for example "http://contoso.com:8080/index/".
If prefixes Is Nothing OrElse prefixes.Length = 0 Then Throw New ArgumentException("prefixes")
' Set up a listener.
Dim listener As HttpListener = New HttpListener()
For Each s As String In prefixes
listener.Prefixes.Add(s)
Next
listener.Start()
' Specify Negotiate as the authentication scheme.
listener.AuthenticationSchemes = AuthenticationSchemes.Negotiate
' If NTLM Is used, we will allow multiple requests on the same
' connection to use the authentication information of first request.
' This improves performance but does reduce the security of your
' application.
listener.UnsafeConnectionNtlmAuthentication = True
' This listener does Not want to receive exceptions
' that occur when sending the response to the client.
listener.IgnoreWriteExceptions = True
Console.WriteLine("Listening...")
' ... process requests here.
listener.Close()
End Sub
Keterangan
Ketika properti ini diatur ke true
dan permintaan pertama melalui koneksi TCP tertentu diautentikasi menggunakan NTLM, permintaan berikutnya melalui koneksi TCP yang sama diproses menggunakan informasi autentikasi (IIdentity) dari permintaan awal.
Properti ini tidak berpengaruh ketika NTLM bukan protokol autentikasi. Ketika Negosiasi ditentukan sebagai protokol autentikasi, properti ini memiliki efek hanya jika NTLM adalah protokol aktual yang digunakan untuk autentikasi.
Catatan
Saat mengatur properti ini untuk true
meningkatkan performa karena HttpListener tidak mengirim tantangan autentikasi NTLM tambahan, ada risiko keamanan dalam tidak mengharuskan semua permintaan untuk memberikan informasi autentikasi. Anda harus menentukan apakah peningkatan performa sepadan dengan risiko ini.