我發現ELMAH源代碼的研究和本文http://dotnetslackers.com/articles/aspnet/Securing-ELMAH-with-Independent-HTTP-Authentication.aspx後的解決方案。用戶可以自定義實現IRequestAuthorizationHandler IHttpModule的 我做下一個:
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()
{
}
}
嗨感謝,但它並不在我身邊工作。你能告訴我,也許我需要爲sitecore設置一些其他設置? –
請注意,用戶角色站點核心使用的是什麼,我剛剛舉了一個例子。 –
我看到了,但我試圖使用aspnet_Roles表中的角色,並且無法正常工作。 –