title: How to add Custom Authentication in SSRS 2016 - Using ADFS & OWIN
body: <p>I am working on adding custom authentication on top of SSRS 2016. There is a very good article available to do the same</p>
  
  <p>Custom SecuritySample 2016 - <a href="https://github.com/Microsoft/Reporting-Services/tree/master/CustomSecuritySample2016" rel="nofollow noreferrer">https://github.com/Microsoft/Reporting-Services/tree/master/CustomSecuritySample2016</a></p>
  
  <p>The steps Microsoft have provided to add custom authentication is basically adding forms authentication in which user name/password is taken as input on logon.aspx. I did this and it worked as expected. But my requirement is to authenticate user using ADFS (Active Directory Federation Services). And luckily there is another good article available to dotnetcurry.com/windows-azure/1166/aspnet-mvc-multiple-adfs-owin-katana</p>
  
  <p>Thanks to above article I was able to authenticate using ADFS and OWIN in sample MVC web Forms application.</p>
  
  <p>But here is the problem, when I am trying to add the above sample login into Custom Security Sample provided by Microsoft(link above provided). I am getting an exception </p>
  
  <blockquote>
    <p>Exception of type 'System.Web.HttpUnhandledException' was thrown.<br>
    No owin.Environment item was found in the context.</p>
  </blockquote>
  
  <p>So here is what I am doing.</p>
  
  <p>I added Startup.cs file in CustomSecuritySample2016 solution provided <a href="https://github.com/Microsoft/Reporting-Services/tree/master/CustomSecuritySample2016" rel="nofollow noreferrer">https://github.com/Microsoft/Reporting-Services/tree/master/CustomSecuritySample2016</a> on GitHub.
  Then also added Startup.Auth.cs file under App_Start folder.
  Modified the web.config file to add following settings.</p>
  
  <pre><code>&lt;add key="owin:AppStartup" value="Microsoft.Samples.ReportingServices.CustomSecurity.Startup, Microsoft.Samples.ReportingServices.CustomSecurity" /&gt;
  &lt;add key="owin:AutomaticAppStartup" value="true" /&gt;
  </code></pre>
  
  <ol start="4">
  <li>Then on Page_Load event of Logon.aspx I am just trying to access the GetOwinContext method by extending HttpContext.</li>
  </ol>
  
  <blockquote>
    <p>private void Page_Load(object sender, System.EventArgs e)<br>
        {            </p>
    
    <p>var ct = HttpContext.Current.GetOwinContext();</p>
    
    <p>}</p>
  </blockquote>
  
  <ol start="5">
  <li>Rest of the changes are exactly the same as mentioned in custom security sample 2016 code on GitHub(Link above).</li>
  </ol>
  
  <p>I already googled for this exception and I have already added this setting as per the right answers out there but mine is still giving this exception.</p>
  
  <pre><code>&lt;add key="owin:AppStartup" value="Microsoft.Samples.ReportingServices.CustomSecurity.Startup, Microsoft.Samples.ReportingServices.CustomSecurity" /&gt;
  &lt;add key="owin:AutomaticAppStartup" value="true" /&gt;
  </code></pre>
  
  <p>Is is because SSRS don't allow to load any DLL that is not added in RSReportServer.config?</p>