我在我的Sitecore解决方案中添加了Elmah工具,实际上我就像这里一样 http://newguid.net/sitecore/2011/using-elmah-for-error-logging-within-sitecore/ 我启用的只有一个卷是 allowRemoteAccess 属性,
<elmah>
<security allowRemoteAccess="1" />
</elmah>
现在可以从任何地方为每个人提供日志,但我想仅为登录(授权)到sitecore(sitecore用户)的用户显示
我怎么能管它?
感谢。
答案 0 :(得分:1)
不确定Elmah
现在内置了什么,但我曾经这样做过:
<location path="elmah.axd">
<system.web>
<authorization>
<allow roles="SITECORE_USERS"/> <!---put your role here-->
<deny users="*"/>
</authorization>
</system.web>
</location>
答案 1 :(得分:1)
我在研究elmah源代码和本文http://dotnetslackers.com/articles/aspnet/Securing-ELMAH-with-Independent-HTTP-Authentication.aspx之后找到了解决方案。用户可以为自定义IHttpModule实现IRequestAuthorizationHandler 我接下来做了:
public class SitecoreAuthModule :IHttpModule, IRequestAuthorizationHandler
{
public bool Authorize(HttpContext context)
{
return SC.Context.User.IsAdministrator;
}
public void Init(HttpApplication context)
{
context.AuthenticateRequest += new EventHandler(ContextAuthenticateRequest); ;
}
void ContextAuthenticateRequest(object sender, EventArgs e)
{
var context = sender as HttpApplication;
if (context.Request.Path.IndexOf("elmah.axd",
StringComparison.InvariantCultureIgnoreCase) < 0)
return;
}
public void Dispose()
{
}
}