0

Active Directory と C# を使用して認証しようとしています。コードは Visual Studio 15 の IIS Express で動作していますが、プロジェクトを IIS サーバーにデプロイすると、LDAP 接続で次のエラーが返されます。

「提供された資格情報は無効です」

私が使用しているコードは次のとおりです。

public static dynamic AuthenticationUser(string username, string password)
{
    bool validation;
    try
    {
        var credentials = new NetworkCredential(username, password, "somedomain");
        var serverId = new LdapDirectoryIdentifier("someserver");
        LdapConnection conn = new LdapConnection(new LdapDirectoryIdentifier((string)null, false, false));

        conn.Credential = credentials;
        conn.AuthType = AuthType.Negotiate;
        conn.Bind(credentials);
        validation = true;
    }
    catch (LdapException ex)
    {
        validation = false;
        return ex.Message;
    }

Visual Studio でデバッグするとすべて問題ありません。ユーザーが AD サーバーに存在することを確認して検証できますが、IIS サーバーではエラーが発生します。

アップデート

IIS サーバーでドメイン コントローラーを無効にすることで、この問題を修正しました。

4

1 に答える 1