Edit

Share via


AuthenticationSchemes Enum

Definition

Specifies protocols for authentication.

This enumeration supports a bitwise combination of its member values.

C#
[System.Flags]
public enum AuthenticationSchemes
Inheritance
AuthenticationSchemes
Attributes

Fields

Name Value Description
None 0

No authentication is allowed. A client requesting an HttpListener object with this flag set will always receive a 403 Forbidden status. Use this flag when a resource should never be served to a client.

Digest 1

Specifies digest authentication.

Negotiate 2

Negotiates with the client to determine the authentication scheme. If both client and server support Kerberos, it is used; otherwise, NTLM is used.

Ntlm 4

Specifies NTLM authentication.

IntegratedWindowsAuthentication 6

Specifies Windows authentication.

Basic 8

Specifies basic authentication.

Anonymous 32768

Specifies anonymous authentication.

Examples

The following code example demonstrates using the Negotiate enumeration value to specify that clients are authenticated using the Negotiate security protocol.

C#
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;
}

Remarks

This enumeration is used to specify the method used to authenticate client requests being processed by HttpListener objects.

Important

Basic authentication requires the exchange of a password and should therefore be avoided except in the case of secure, encrypted connections.

For additional information on basic and digest authentication, see RFC2617 - HTTP Authentication: Basic and Digest Authentication. This document is available at https://www.rfc-editor.org.

Applies to

Product Versions
.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