System.Net.Security.NegotiateAuthenticationType Enumeration

Specifies the authentication type to be used with the Negotiate security support provider (SSP).

Syntax

[FlagsAttribute]
public enum NegotiateAuthenticationType

Members

Kerberos

Specifies Kerberos as the authentication type.

Kerberos

NTLM

Specifies NTLM as the authentication type.

NTLM

Negotiate

Specifies the Negotiate security support provider (SSP), which selects the best authentication package available (either Kerberos or NTLM).

Negotiate

Remarks

The NegotiateAuthenticationType enumeration is used to specify the authentication protocol that the NegotiateSecurityContext class should attempt to use when establishing a security context.

When you specify Negotiate, the underlying operating system will attempt to use Kerberos authentication first. If Kerberos is not available or fails, it will fall back to NTLM authentication.

This enumeration is decorated with the FlagsAttribute, which means that members can be combined using the bitwise OR operator.

Example

The following C# code shows how to specify both NTLM and Negotiate authentication types for a NegotiateSecurityContext object.

using System;
using System.Net.Security;

public class Example
{
    public static void Main(string[] args)
    {
        // Create a NegotiateSecurityContext with NTLM and Negotiate authentication types
        NegotiateAuthenticationType authTypes = NegotiateAuthenticationType.NTLM | NegotiateAuthenticationType.Negotiate;
        
        // In a real scenario, you would use authTypes when creating a NegotiateSecurityContext
        // For example:
        // NegotiateSecurityContext context = new NegotiateSecurityContext(authTypes);
        
        Console.WriteLine($"Using authentication types: {authTypes}");

        // You can also check for specific types
        if ((authTypes & NegotiateAuthenticationType.NTLM) == NegotiateAuthenticationType.NTLM)
        {
            Console.WriteLine("NTLM is enabled.");
        }
        
        if ((authTypes & NegotiateAuthenticationType.Kerberos) == NegotiateAuthenticationType.Kerberos)
        {
            Console.WriteLine("Kerberos is enabled.");
        }

        if ((authTypes & NegotiateAuthenticationType.Negotiate) == NegotiateAuthenticationType.Negotiate)
        {
            Console.WriteLine("Negotiate (auto-select) is enabled.");
        }
    }
}

Requirements

Assembly File
System.Net.Primitives System.Net.Primitives.dll

See Also

Note: The specific authentication protocols supported and their behavior may depend on the underlying operating system and its configuration.