1

(別のマシン上の) データベースに接続する ASP.NET アプリケーションを開発しています。自分のマシンから接続しようとしても問題はありませんが、宛先環境にデプロイすると、EF は例外を返します。

The underlying provider failed on Open.System.Data.SqlClient.SqlException (0x80131904): Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'. at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, SqlConnection owningObject) at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, TimeoutTimer timeout) at 

私の構成は次のとおりです。

    <authentication mode="Windows" />
    <customErrors mode="Off"></customErrors>
    <identity impersonate="true" />
    <security>
        <authentication>
            <windowsAuthentication useKernelMode="false">
                <extendedProtection tokenChecking="None" />
            </windowsAuthentication>
        </authentication>
    </security>

そして、私の接続文字列は次のとおりです。

 <add name="pmgbicopEntities" connectionString="metadata=res://*/copDB.csdl|res://*/copDB.ssdl|res://*/copDB.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=[NAME]\devde;Initial Catalog=[NAME];Integrated Security=True;Trusted_Connection=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />

データベース命令を削除すると、 this.Page.User が現在のアカウントになります (これは正しいです!) が、EF 経由で新しい接続を開くと、「匿名」になります。

私は次のような偽装で試しました:

WindowsIdentity winId = (WindowsIdentity)HttpContext.Current.User.Identity;
WindowsImpersonationContext ctx = null;
try
{
  ctx = winId.Impersonate();
  //EF SOMETHING
}
catch (Exception exx)
{
}
finally
{
  if (ctx != null)
  ctx.Undo();
}

しかし、「ユーザー 'NT AUTHORITY\ANONYMOUS LOGON' のログインに失敗しました」という同じ例外が発生します。

アプリケーション プール ユーザーを変更しようとしましたが、手動で偽装しようとしましたが、成功しませんでした。

IIS 構成には、有効化と無効化を試みた kerberos がいくつかありますが、何も変わりません。

何か提案はありますか?マシン間の「信頼」などを有効にする必要がありますか? 「偽のIIS」の開発マシンでは問題はありませんが、DBでユーザーが有効になっています。

前もって感謝します。

4

1 に答える 1

0

ここでの最終目標は何ですか? ユーザーの資格情報を SQL に渡すか、あらかじめ決められたアカウントを使用して SQL に接続しますか?

Kerberos が機能するように構成するために必要な設定は次のとおりです (これにより、ユーザーのアカウントのアクセス許可を使用できるようになります)。

IIS 設定:

-Physical Path Credentials:  Application User (pass-through authentication)
-Physical Path Credential Logon Type:  Clear Text
-Application Pool ID:  Domain\ServiceAccount
-Integrated Windows Authentication:  Enabled
-Windows Authentication Providers:  Negotiate
-useAppPoolCredentials (found in Configuration Editor):  True

ServiceAccount 用に作成された SPN: SETSPN -L Domain\ServiceAccount

HTTP/Our.WebSiteURL.com

ドメイン サービス アカウントを使用したくない場合は、SPN とアプリケーション プールの両方で Domain\MachineAccount に置き換えます。

于 2013-11-08T16:53:16.550 に答える