System.Net.CredentialCache.DefaultCredentials Property

Gets the system credentials of the application.

Syntax

[System.MonoTODO("Need EnvironmentPermission implementation first")]
public static ICredentials DefaultCredentials { get; }

Value

A System.Net.ICredentials instance that represents the system credentials in use for the current process.

Remarks

The CredentialCache.DefaultCredentials property applies only to NTLM, negotiate, and Kerberos-based authentication.

CredentialCache.DefaultCredentials represents the system credentials for the current security context in which the application is running. For a client-side application, these are usually the Windows credentials (user name, password, and domain) of the user running the application. For ASP.NET applications, the default credentials are the user credentials of the logged-in user, or the user being impersonated.

To get the credentials as a System.Net.NetworkCredential instance, use the CredentialCache.DefaultNetworkCredentials property.

The supported values for authType are "NTLM", "Digest", "Kerberos", and "Negotiate". This method does not work for HTTP or FTP protocols.

Note:

The System.Net.ICredentials instance returned by CredentialCache.DefaultCredentials cannot be used to view the user name, password, or domain of the current security context.

Permissions

TypeReason
System.Security.Permissions.EnvironmentPermissionRequires read access to the environment variable that contains the user name. See System.Security.Permissions.EnvironmentPermissionAccess.Read.

Requirements

Namespace: System.Net
Assembly: System (in System.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0