I am currently trying to create a website that authenticates users against AD but I cannot seem to find a good resource for examples. To start with I would just like to give all AD users access to the site. I have a Windows 2008 r2 server running IIS and Active Directory roles for testing purposes.
I know that you must add a connection string as shown in ASP.NET MVC – Authenticate users against Active Directory, but require username and password to be inputted. But some sort of example showing models, views and controllers as well as the web.config file would help greatly.
Thanks in advance
I’m going to go ahead and answer since I’m doing precisely this on our company’s internal web app and if I’m doing it wrong, this is how I’m going to find out.
When the user comes to your web site, you’ll have UserPrincipal.Current.SamAccountName. So all you need to do is something like this:
So if you don’t get a SearchResult returned, they wouldn’t be authenticated against your AD domain… Hope I’m doing it right 😉