CredentialCache.DefaultCredentials Özellik
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Uygulamanın sistem kimlik bilgilerini alır.
public:
static property System::Net::ICredentials ^ DefaultCredentials { System::Net::ICredentials ^ get(); };
public static System.Net.ICredentials DefaultCredentials { get; }
static member DefaultCredentials : System.Net.ICredentials
Public Shared ReadOnly Property DefaultCredentials As ICredentials
Özellik Değeri
ICredentials Uygulamanın sistem kimlik bilgilerini temsil eden.
Örnekler
Aşağıdaki kod örneği, DefaultCredentials uygulamanın sistem kimlik bilgilerini almak için özelliğini kullanır.
// Ensure Directory Security settings for default web site in IIS is "Windows Authentication".
string url = "http://localhost";
// Create a 'HttpWebRequest' object with the specified url.
HttpWebRequest myHttpWebRequest = (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 = (HttpWebResponse)myHttpWebRequest.GetResponse();
Console.WriteLine("Authentication successful");
Console.WriteLine("Response received successfully");
' Assuming "Windows Authentication" has been set as;
' Directory Security settings for default web site in IIS.
Dim url As String = "http://localhost"
' Create a 'HttpWebRequest' object with the specified url.
Dim myHttpWebRequest As HttpWebRequest = CType(WebRequest.Create(url), HttpWebRequest)
' Assign the credentials of the logged in user or the user being impersonated.
myHttpWebRequest.Credentials = CredentialCache.DefaultCredentials
' Send the 'HttpWebRequest' and wait for response.
Dim myHttpWebResponse As HttpWebResponse = CType(myHttpWebRequest.GetResponse(), HttpWebResponse)
Console.WriteLine("Authentication successful")
Console.WriteLine("Response received successfully")
Açıklamalar
DefaultCredentials özelliği yalnızca NTLM, negotiate ve Kerberos tabanlı kimlik doğrulaması için geçerlidir.
DefaultCredentials , uygulamanın çalıştığı geçerli güvenlik bağlamı için sistem kimlik bilgilerini temsil eder. İstemci tarafı uygulama için bunlar genellikle uygulamayı çalıştıran kullanıcının Windows kimlik bilgileridir (kullanıcı adı, parola ve etki alanı). ASP.NET uygulamalar için varsayılan kimlik bilgileri, oturum açmış kullanıcının veya kimliğine bürünülen kullanıcının kullanıcı kimlik bilgileridir.
Kimlik bilgilerini örnek NetworkCredential olarak almak için özelliğini kullanın DefaultNetworkCredentials .
Uyarı
tarafından ICredentialsDefaultCredentials döndürülen örnek, geçerli güvenlik bağlamının kullanıcı adını, parolasını veya etki alanını görüntülemek için kullanılamaz.