Namespace: System.Net.Security
Type: Enumeration
Defines the authentication types that can be used to authenticate a client and server application.
public enum TmschAuthenticationTypes
| Member | Description |
|---|---|
| Anonymous | Specifies that the authentication is anonymous. No credentials are required. |
| Basic | Specifies that Basic authentication is used. Credentials are sent in clear text. |
| Digest | Specifies that Digest authentication is used. Credentials are sent as a hash. |
| Negotiate | Specifies that Negotiate authentication (e.g., Kerberos) is used. This is often the default for Windows environments. |
| Ntlm | Specifies that NTLM authentication is used. |
| MutualAuth | Specifies that mutual authentication is used, where both client and server authenticate each other. |
| Kerberos | Specifies that Kerberos authentication is used. |
| All | Specifies that all available authentication types are supported. |
The TmschAuthenticationTypes enumeration is used to specify the authentication mechanisms that can be employed when establishing a secure connection between a client and a server. This enumeration is particularly relevant in scenarios involving protocols like HTTP or FTP where authentication is crucial for security and access control.
When configuring a client or server application, you can specify one or more of these authentication types to determine how identities are verified. The All member allows for negotiation and selection of the most appropriate authentication method supported by both parties.
The following C# code snippet demonstrates how to specify Basic and Anonymous authentication for an HttpWebRequest:
using System;
using System.Net;
using System.Net.Security;
public class Example {
public static void Main() {
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://example.com/secure/data");
// Setting authentication types
request.AuthenticationTypes = AuthenticationTypes.Basic | AuthenticationTypes.Anonymous;
// Optionally set credentials if Basic authentication is chosen and required
// request.Credentials = new NetworkCredential("username", "password");
try {
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) {
Console.WriteLine("Response received. Status code: {0}", response.StatusCode);
// Process the response...
}
} catch (WebException ex) {
Console.WriteLine("Error: {0}", ex.Message);
}
}
}
| | | | |
|---|---|
| Namespace | System.Net.Security |
| Assembly | System (in System.dll) |
| .NET Framework versions | Available in .NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.6, 4.7, 4.8. |