title: ASP.NET Core Authorize AD Groups through web.config
body: <p>In my old .NET MVC app, I could enable Windows Authentication in IIS and disable anonymous. Then in my <code>web.config</code> file I just had to put in this:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;authorization&gt; 
    &lt;allow roles="Domain\MyADGroupToHaveAccess" /&gt;
    &lt;deny users="*" /&gt; 
  &lt;/authorization&gt; 
  </code></pre>
  
  <p>In .NET Core 2.0 this will not work – it denies anonymous correctly, but it authorizes all users no matter what.</p>
  
  <p>If I do this:</p>
  
  <pre><code>[Authorize(Roles = "Domain\\MyADGroupToHaveAccess")]
  </code></pre>
  
  <p>on my <code>HomeController</code>, it works, but I don't want to hardcode this setting in my project as it's something that needs to be changed for other environments.</p>
  
  <p>How can I make <code>web.config</code> to work with AD Authorization? Or is there another way to not hardcode this setting in ASP.NET Core?</p>