我的生产环境排除了
使用SQL Server身份验证,
将模拟更改为假,或
授予自己对数据库的权限
直接。
然后你别无选择,只能修改elmah源代码。对不起的。
这与双跳问题的关系不大,而与ASP.NET中记录不良的模拟机制有关。根据
this article
,显然
<identity impersonate="true" />
使ASP.NET模拟默认的IIS匿名帐户(IUSR_
机器名
)SharePoint需要这样做,但是试图访问远程数据库对您没有好处,因此显然您需要做一些事情。
是的,根据
this article
必须编辑Elmah源代码并创建从抽象类派生的新类
ErrorLog
.然后,这个新类充当原始sqlErrorLog类的包装器,并在RWEP块中运行其方法。这里是:
public class SqlErrorLogWEP : ErrorLog
{
private SqlErrorLog sqlErrorLog;
public SqlErrorLogWEP(IDictionary config)
{
sqlErrorLog = new SqlErrorLog(config);
}
public SqlErrorLogWEP(string connectionString)
{
sqlErrorLog = new SqlErrorLog(connectionString);
}
public override string Log(Error error)
{
string retVal = String.Empty;
SPSecurity.RunWithElevatedPrivileges(delegate()
{
retVal = sqlErrorLog.Log(error);
});
return retVal;
}
public override ErrorLogEntry GetError(string id)
{
ErrorLogEntry retVal = default(ErrorLogEntry);
SPSecurity.RunWithElevatedPrivileges(delegate()
{
retVal = sqlErrorLog.GetError(id);
});
return retVal;
}
public override int GetErrors(int pageIndex, int pageSize, System.Collections.IList errorEntryList)
{
int retVal = -1;
SPSecurity.RunWithElevatedPrivileges(delegate()
{
retVal = sqlErrorLog.GetErrors(pageIndex, pageSize, errorEntryList);
});
return retVal;
}
}
毫无疑问,您现在需要在elmah项目中引用SharePoint,您的elmah.dll将需要gaced。我已经亲自测试过了,而且效果很好。祝你好运。