What are the high level steps to authenticate users of an ASP.NET MVC application against Active Directory?
I presume something like:
- Modify web.config to use Windows authentication
- Configure web.config to use the ActiveDirectoryMembershipProvider
- Configure the web.config to use a custom RoleProvider that looks in AD
Does the above look sensible, and if so, where do I put the valid user detection logic?
In my case a valid user is someone on a specific AD domain.
Here's a solution from the tutorial Chris Schiffhauer - Implement Active Directory Authentication in ASP.NET MVC 5:
Forms Authentication
You can use the normal forms authentication to authenticate a user against an Active Directory, for that you just need you AD connection string:
and add the Membership Provider to use this connection:
you will need to use username@domain to successfully authenticate the user.
Here is something to get you started
Windows Authentication
If you start your project new, you can always select Intranet application from the template and all is taken care for you
If you want to do it manually, you need to change:
for detailed info on doing this on IIS7/8 and IISExpress:
In your
web.config
have something likeand that's it!
Now, when you want the user identity, just call
and this will show you the
Domain\Username
like for me :Here is something to get you started