Language

NTLM と Kerberos 認証

Important

NTLM は従来の認証プロトコルであり、現在の推奨事項を満たしていない暗号化アルゴリズムを使用します。 NTLM は、既存のシステムとの互換性のために必要な場合にのみ使用します。 ネゴシエートは、使用可能な場合は Kerberos を優先しますが、NTLM にフォールバックできます。 NTLM を防止するには、サポートされている場合に Kerberos を明示的に要求するか、最新の認証プロトコルを使用する。

既定の NTLM 認証と Kerberos 認証では、呼び出し元アプリケーションに関連付けられている Microsoft Windows ユーザー資格情報を使用して、サーバーでの認証を試みます。 既定以外の NTLM 認証を使用する場合、アプリケーションは認証の種類を NTLM に設定し、次の例に示すように、 NetworkCredential オブジェクトを使用してユーザー名、パスワード、ドメインをホストに渡します。

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...

次の例に示すように、アプリケーション ユーザーの資格情報を使用してインターネット サービスに接続する必要があるアプリケーションは、ユーザーの既定の資格情報で接続できます。

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...

ネゴシエート認証モジュールは、リモート サーバーが NTLM 認証と Kerberos 認証のどちらを使用しているかを判断し、適切な応答を送信します。

注

NTLM 認証はプロキシ サーバー経由では機能しません。

こちらも参照ください