AuthenticationSchemes Enumeration
Collapse the table of content
Expand the table of content

AuthenticationSchemes Enumeration


Specifies protocols for authentication.

Namespace:   System.Net
Assembly:  System (in System.dll)

public enum AuthenticationSchemes

Member nameDescription

Specifies anonymous authentication.


Specifies basic authentication.


Specifies digest authentication.


Specifies Windows authentication.


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


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.


Specifies NTLM authentication.

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

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

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.");

Universal Windows Platform
Available since 4.5
.NET Framework
Available since 2.0
Portable Class Library
Supported in: portable .NET platforms
Windows Phone Silverlight
Available since 8.1
Windows Phone
Available since 8.1
Return to top
© 2015 Microsoft