AuthenticationSchemes Enum

Definition

Anger protokoll för autentisering.

Den här uppräkningen stöder en bitvis kombination av dess medlemsvärden.

public enum class AuthenticationSchemes
[System.Flags]
public enum AuthenticationSchemes
[<System.Flags>]
type AuthenticationSchemes = 
Public Enum AuthenticationSchemes
Arv
AuthenticationSchemes
Attribut

Fält

Name Värde Description
None 0

Ingen autentisering tillåts. En klient som begär ett HttpListener objekt med den här flagguppsättningen får alltid statusen 403 Förbjuden. Använd den här flaggan när en resurs aldrig ska hanteras till en klient.

Digest 1

Anger sammandragsautentisering.

Negotiate 2

Förhandlar med klienten för att fastställa autentiseringsschemat. Om både klient och server stöder Kerberos används det. annars används NTLM.

Ntlm 4

Anger NTLM-autentisering.

IntegratedWindowsAuthentication 6

Anger Windows-autentisering.

Basic 8

Anger grundläggande autentisering.

Anonymous 32768

Anger anonym autentisering.

Exempel

Följande kodexempel visar hur du använder uppräkningsvärdet Förhandla för att ange att klienter autentiseras med hjälp av säkerhetsprotokollet 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;
}
Console.WriteLine("Listening for {0} prefixes...", listener.Prefixes.Count)
Dim context As HttpListenerContext = listener.GetContext()
Dim request As HttpListenerRequest = 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 AndAlso request.GetClientCertificate() Is Nothing OrElse request.ClientCertificateError <> 0 Then
    ' Send a 403 response.
    Dim badCertificateResponse As HttpListenerResponse = context.Response
    SendBadCertificateResponse(badCertificateResponse)
    Console.WriteLine("Client has invalid certificate.")
    Continue Do
End If

Kommentarer

Den här uppräkningen används för att ange den metod som används för att autentisera klientbegäranden som bearbetas av HttpListener objekt.

Important

Grundläggande autentisering kräver utbyte av ett lösenord och bör därför undvikas förutom vid säkra, krypterade anslutningar.

Mer information om grundläggande och sammanfattad autentisering finns i RFC2617 – HTTP-autentisering: Grundläggande och sammanfattad autentisering. Det här dokumentet finns på https://www.rfc-editor.org.

Gäller för