(別のマシン上の) データベースに接続する 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="Data Source=[NAME]\devde;Initial Catalog=[NAME];Integrated Security=True;Trusted_Connection=True;MultipleActiveResultSets=True"" 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でユーザーが有効になっています。
前もって感謝します。