Nota
L'accesso a questa pagina richiede l'autorizzazione. È possibile provare ad accedere o modificare le directory.
L'accesso a questa pagina richiede l'autorizzazione. È possibile provare a modificare le directory.
L'autenticazione NTLM predefinita e l'autenticazione Kerberos usano le credenziali utente di Microsoft Windows associate all'applicazione chiamante per tentare l'autenticazione con il server. Quando si usa l'autenticazione NTLM non predefinita, l'applicazione imposta il tipo di autenticazione su NTLM e usa un NetworkCredential oggetto per passare il nome utente, la password e il dominio all'host, come illustrato nell'esempio seguente.
Dim myUri As String = "http://www.contoso.com/"
Using handler As New HttpClientHandler()
With handler
.Credentials = New NetworkCredential(UserName, SecurelyStoredPassword, Domain)
End With
Using client As New HttpClient(handler)
Dim result As String = Await client.GetStringAsync(myUri)
' Do Other Stuff...
End Using
End Using
string myUri = "http://www.contoso.com/";
using HttpClientHandler handler = new()
{
Credentials = new NetworkCredential(UserName, SecurelyStoredPassword, Domain),
};
using HttpClient client = new(handler);
string result = await client.GetStringAsync(myUri);
// Do Other Stuff...
Le applicazioni che devono connettersi ai servizi Internet usando le credenziali dell'utente dell'applicazione possono farlo con le credenziali predefinite dell'utente, come illustrato nell'esempio seguente.
Dim myUri As String = "http://www.contoso.com/"
Using handler As New HttpClientHandler()
With handler
.Credentials = CredentialCache.DefaultCredentials
End With
Using client As New HttpClient(handler)
Dim result As String = Await client.GetStringAsync(myUri)
' Do Other Stuff...
End Using
End Using
string myUri = "http://www.contoso.com/";
using HttpClientHandler handler = new()
{
Credentials = CredentialCache.DefaultCredentials,
};
using HttpClient client = new(handler);
string result = await client.GetStringAsync(myUri);
// Do Other Stuff...
Il modulo di autenticazione negoziata determina se il server remoto usa l'autenticazione NTLM o Kerberos e invia la risposta appropriata.
Annotazioni
L'autenticazione NTLM non funziona tramite un server proxy.
Vedere anche
- Autenticazione Basic e Digest
- Autenticazione Internet