Gets the system credentials of the application.
Assembly: System (in System.dll)
The property applies only to NTLM, negotiate, and Kerberos-based authentication.
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.
The supported values for authType are "NTLM", "Digest", "Kerberos", and "Negotiate". This method does not work for HTTP or FTP protocols.
The ICredentials instance returned by cannot be used to view the user name, password, or domain of the current security context.
The following code example uses the property to get the system credentials of the application.
// Ensure Directory Security settings for default web site in IIS is "Windows Authentication". String* url = S"http://localhost"; // Create a 'HttpWebRequest' object with the specified url. HttpWebRequest* myHttpWebRequest = dynamic_cast<HttpWebRequest*>(WebRequest::Create(url)); // Assign the credentials of the logged in user or the user being impersonated. myHttpWebRequest->Credentials = CredentialCache::DefaultCredentials; // Send the 'HttpWebRequest' and wait for response. HttpWebResponse* myHttpWebResponse = dynamic_cast<HttpWebResponse*>(myHttpWebRequest->GetResponse()); Console::WriteLine(S"Authentication successful"); Console::WriteLine(S"Response received successfully");
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.