Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

web.config allow all users from a specific domain, but not another

I have users from two different domains that can access the web site I am currently working on and I would like to only allow users from one of those domain to access the site. I've done some research and the only thing I was able to come up with is allowing users from a specific domain group, but not from an entire domain only.

I've also come across this post that suggest to check the domain manually upon logon:

http://bytes.com/topic/asp-net/answers/343407-using-web-config-allow-access-domain-users-only

I've added this to the web.config, but it does not appear to be working:

<authorization>
  <deny users="?"/>
  <allow users="FirstDomain\Domain Users"/>
  <deny users="SecondDomain\Domain Users" />
</authorization>

Thanks,

like image 707
Paul Avatar asked Jan 15 '23 08:01

Paul


2 Answers

Got it working eventually:

<authorization>
  <allow roles="FirstDomain\Domain Users"/>
  <deny users="*"/>
</authorization>
like image 109
Paul Avatar answered Feb 08 '23 15:02

Paul


"Allow" should preceed the "Deny" tags, as in your case, everything will be denied access.

<system.web>
 <authorization>
  <allow users="FirstDomain\Domain Users"/>
  <deny users="SecondDomain\Domain Users" />
 </authorization>
</system.web>

Hope this helps.

like image 36
Brett Rigby Avatar answered Feb 08 '23 14:02

Brett Rigby