A System.Net.ICredentials instance that represents the system credentials in use for the current process.
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.
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.
Type | Reason |
---|---|
System.Security.Permissions.EnvironmentPermission | Requires read access to the environment variable that contains the user name. See System.Security.Permissions.EnvironmentPermissionAccess.Read. |