ELMAH无法登录生产中的数据库,但无法测试服务器 [英] ELMAH fails to login to DB on production but not test server

查看:75
本文介绍了ELMAH无法登录生产中的数据库,但无法测试服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,这里有一些可能的重复操作没有帮助:

无法使用Elmah MVC访问生产服务器上的/ elmah吗?

ELMAH不会在生产时将错误日志插入SQL DB

ELMAH在本地计算机上工作,但不在生产上工作

Elmah,转换为.Net4 vs2010,在Server 2008上运行,不起作用

无法打开数据库测试登录要求。登录失败。用户'xyz\ASPNET'登录失败

错误用户'NT AUTHORITY\IUSR'的登录失败。在ASP.NET和SQL Server 2008中

First off, here's a few of the potential duplicates that didn't help:
Can't access /elmah on production server with Elmah MVC?
ELMAH doesn't insert error logs to SQL DB on production
ELMAH works on local machine, but not on production
Elmah, convert to .Net4 vs2010, run on server 2008, does not work
Cannot open database "test" requested by the login. The login failed. Login failed for user 'xyz\ASPNET'
The error "Login failed for user 'NT AUTHORITY\IUSR'" in ASP.NET and SQL Server 2008

我的ASP.NET MVC应用程序使用一个SQL Server数据库, ELMAH使用了另一个。在测试服务器上,IIS应用程序池帐户用于按预期连接到SQL Server,并且一切正常。但是,使用相同的设置进入生产后,Entity Framework继续使用 IIS APPPOOL\Product Windows帐户连接到SQL Server,但是ELMAH开始尝试使用 DOMAIN\MACHINENAME $ 帐户(我没有创建/设置-我对Windows域知之甚少,所以不知道它来自何处)。

My ASP.NET MVC application uses one SQL Server database and ELMAH uses another. On the test server, the IIS app pool account is used to connect to SQL Server, as intended, and everything works fine. However, moving to production with the same settings has Entity Framework continuing to use the IIS APPPOOL\Product Windows account to connect to SQL Server, but ELMAH starts attempting to use the DOMAIN\MACHINENAME$ account (which I didn't create/set up -- I don't know enough about Windows domains to know where that comes from).

尝试转到列出错误的ELMAH页面(即 http:// localhost / elmah )将返回HTTP 500,事件日志显示以下经典错误消息:

Attempting to go to the ELMAH page that lists errors (i.e. http://localhost/elmah) returns HTTP 500 and the event log shows this classic error message:


无法打开登录请求的数据库错误。登录失败。用户'DOMAIN\MACHINENAME $'的登录失败

Cannot open database "Errors" requested by the login. The login failed. Login failed for user 'DOMAIN\MACHINENAME$'

出于绝望,我尝试只给 DOMAIN\MACHINENAME $ 数据库权限(用于SSMS将登录名映射到 Errors 数据库并选择 db_datawriter db_datareader ),包括建议在此处的存储过程,但即使那样也不行。该过程就是我在测试服务器上进行设置的过程。

Out of desperation, I've tried just giving DOMAIN\MACHINENAME$ database permissions (used SSMS to map the login to the Errors database and selected db_datawriter and db_datareader), including the stored procedures suggested here, but even that doesn't work. That process is what I did to set it up on the test server.

产品是运行IIS 8.5的Windows Server 2012 R2。测试是在运行IIS 10的Windows 10上进行,目前都在运行SQL Server 2016 Express v13。

Production is Windows Server 2012 R2 running IIS 8.5. Test is Windows 10 running IIS 10. Both are running SQL Server 2016 Express v13, for now.

Web.config包含的所有内容都与此相关:

Web.config with everything included that's even slightly related to this:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    <sectionGroup name="elmah">
      <section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah" />
      <section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" />
      <section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah" />
      <section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah" />
    </sectionGroup>
  </configSections>
  <connectionStrings>
    <clear />
    <!-- Entity Framework connection, works fine on both servers -->
    <add name="DbContext" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Data.mdf;Initial Catalog=Data;Integrated Security=True" providerName="System.Data.SqlClient" />
    <!-- ELMAH connection, only works on test server -->
    <add name="ElmahLog" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Errors.mdf;Initial Catalog=Errors;Integrated Security=True" providerName="System.Data.SqlClient" />
  </connectionStrings>
  <appSettings>
    <add key="elmah.mvc.disableHandler" value="false" />
    <add key="elmah.mvc.disableHandleErrorFilter" value="false" />
    <add key="elmah.mvc.requiresAuthentication" value="true" />
    <add key="elmah.mvc.IgnoreDefaultRoute" value="true" />
    <add key="elmah.mvc.allowedRoles" value="Developer" />
    <add key="elmah.mvc.route" value="dev/elmah" />
    <add key="elmah.mvc.UserAuthCaseSensitive" value="true" />
  </appSettings>
  <system.web>
    <globalization culture="en-US" />
    <authentication mode="Windows" />
    <compilation debug="false" targetFramework="4.5.2">
      <assemblies>
        <add assembly="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      </assemblies>
    </compilation>
    <httpRuntime targetFramework="4.5.2" />
    <httpModules>
      <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
      <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
      <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />
    </httpModules>
    <customErrors mode="Off" />
  </system.web>
  <system.webServer>
    <modules>
      <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" />
      <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" preCondition="managedHandler" />
      <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" preCondition="managedHandler" />
    </modules>
    <validation validateIntegratedModeConfiguration="false" />
  </system.webServer>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
  <elmah>
    <security allowRemoteAccess="true" />
    <errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="ElmahLog" />
  </elmah>
  <system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.8.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" />
      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.8.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
    </compilers>
  </system.codedom>
</configuration>  






为什么ELMAH使用其他帐户以及我为什么不能授予该帐户权限?

推荐答案

听起来您的计算机SID在开发和更改之间就变了部署。您是否将计算机加入了域?

It sounds like your machines SID changed between development and deployment. Did you join the machine to a domain?

还是您将客户端从非域计算机移到了加入域的计算机?

Or, you moved the Client from a non-domain computer to a domain joined computer?

重新安装以纠正此问题意味着本地或域的SID不正确。

A reinstall to correct the problem implies the SIDs either local or domain were not correct.

这篇关于ELMAH无法登录生产中的数据库,但无法测试服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆