HttpListener.UnsafeConnectionNtlmAuthentication プロパティ

定義

NTLM が使用されているときに、同じ TCP (Transmission Control Protocol) 接続を使用した別の要求を認証する必要があるかどうかを制御する Boolean 値を取得または設定します。

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

プロパティ値

最初の要求の IIdentity が同じ接続でなされる後続の要求に使用される場合は true。それ以外の場合は false。 既定値は false です。

例外

このオブジェクトは閉じられました。

次のコード例では、このプロパティの設定を示します。

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

注釈

このプロパティが に true 設定され、特定の TCP 接続に対する最初の要求が NTLM を使用して認証されると、同じ TCP 接続経由の後続の要求は、最初の要求の認証情報 (IIdentity) を使用して処理されます。

NTLM が認証プロトコルではない場合、このプロパティは無効です。 Negotiate が認証プロトコルとして指定されている場合、このプロパティは NTLM が認証に使用される実際のプロトコルである場合にのみ有効です。

注意

このプロパティを に true 設定すると、追加の HttpListener NTLM 認証チャレンジが送信されないため、パフォーマンスが向上しますが、すべての要求で認証情報を提供する必要がないため、セキュリティ上のリスクがあります。 パフォーマンスの向上がリスクよりも重要であるかどうかを判断する必要があります。

適用対象