2013-01-10 54 views
1

我加ELMAH工具,我Sitecore的解決方案,我其實是喜歡這裏 http://newguid.net/sitecore/2011/using-elmah-for-error-logging-within-sitecore/ 剛一滾筒我已經啓用是allowRemoteAccess財產,如何配置ELMAH顯示日誌只是Sitecore的用戶

<elmah> 
<security allowRemoteAccess="1" /> 
</elmah> 

現在可以從任何地方爲每一個人提供日誌,但是我想僅爲登錄(授權)sitecore(sitecore用戶)的用戶展示它

我該如何管理它?

謝謝。

回答

1

我發現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() 
    { 

    } 
} 
1

不知道什麼Elmah已經建成了,但我曾經這樣做:

<location path="elmah.axd"> 
    <system.web> 
     <authorization> 
      <allow roles="SITECORE_USERS"/> <!---put your role here--> 
      <deny users="*"/> 
     </authorization> 
    </system.web> 
</location> 

Securing Elmah RSS Feeds in ASP.NET website

+0

嗨感謝,但它並不在我身邊工作。你能告訴我,也許我需要爲sitecore設置一些其他設置? –

+0

請注意,用戶角色站點核心使用的是什麼,我剛剛舉了一個例子。 –

+0

我看到了,但我試圖使用aspnet_Roles表中的角色,並且無法正常工作。 –