英語で読む

次の方法で共有


AuthenticationSchemes 列挙型

定義

認証用のプロトコルを指定します。

この列挙体は、メンバー値のビットごとの組み合わせをサポートしています。

[System.Flags]
public enum AuthenticationSchemes
継承
AuthenticationSchemes
属性

フィールド

名前 説明
Anonymous 32768

匿名認証を指定します。

Basic 8

基本認証を指定します。

Digest 1

ダイジェスト認証を指定します。

IntegratedWindowsAuthentication 6

Windows 認証を指定します。

Negotiate 2

クライアントとネゴシエートし、認証方式を決定します。 クライアントとサーバーの両方が Kerberos をサポートする場合は、この方式が使用されます。それ以外の場合は NTLM が使用されます。

None 0

認証は使用できません。 このフラグが設定された HttpListener オブジェクトを要求するクライアントは、常に "403 アクセス不可" のステータスを受け取ります。 リソースをクライアントに提供できない場合にこのフラグを使用します。

Ntlm 4

NTLM 認証を指定します。

次のコード例では、Negotiate 列挙値を使用して、Negotiate セキュリティ プロトコルを使用してクライアントが認証されるように指定する方法を示します。

Console.WriteLine("Listening for {0} prefixes...", listener.Prefixes.Count);
HttpListenerContext context = listener.GetContext();
HttpListenerRequest request = context.Request;
Console.WriteLine("Received a request.");
// This server requires a valid client certificate
// for requests that are not sent from the local computer.

// Did the client omit the certificate or send an invalid certificate?
if (request.IsAuthenticated &&
    request.GetClientCertificate() == null ||
    request.ClientCertificateError != 0)
{
    // Send a 403 response.
    HttpListenerResponse badCertificateResponse = context.Response ;
    SendBadCertificateResponse(badCertificateResponse);
    Console.WriteLine("Client has invalid certificate.");
    continue;
}

注釈

この列挙は、オブジェクトによって HttpListener 処理されるクライアント要求を認証するために使用されるメソッドを指定するために使用されます。

重要

基本認証ではパスワードの交換が必要であるため、セキュリティで保護された暗号化された接続の場合を除き、避ける必要があります。

基本認証とダイジェスト認証の詳細については、「 RFC2617 - HTTP 認証: 基本認証とダイジェスト認証」を参照してください。 このドキュメントは で https://www.rfc-editor.org入手できます。

適用対象

製品 バージョン
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0