AuthenticationSchemes AuthenticationSchemes AuthenticationSchemes AuthenticationSchemes Enum


Specifies protocols for authentication.

This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.

public enum class AuthenticationSchemes
public enum AuthenticationSchemes
type AuthenticationSchemes = 
Public Enum AuthenticationSchemes


Anonymous Anonymous Anonymous Anonymous 32768

Specifies anonymous authentication.

Basic Basic Basic Basic 8

Specifies basic authentication.

Digest Digest Digest Digest 1

Specifies digest authentication.

IntegratedWindowsAuthentication IntegratedWindowsAuthentication IntegratedWindowsAuthentication IntegratedWindowsAuthentication 6

Specifies Windows authentication.

Negotiate Negotiate Negotiate 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.

None None None 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.

Ntlm Ntlm Ntlm Ntlm 4

Specifies NTLM authentication.


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

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 ;
    Console.WriteLine("Client has invalid certificate.");
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
    Console.WriteLine("Client has invalid certificate.")
    Continue Do
End If


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


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

Applies to