Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mixing Forms and Windows authentication in .Net 4.5

This has been possible up to .Net4.0 and IIS 7.5.

The general idea is that you enable anonymous and forms authentication for your intranet site and in a subdirectory you enable windows authentication together with forms authentication and turn off anonymous. By disabling the forms 401 => 302 redirection with some custom code you will be able to get a hold of the users username and domain.

If you google for a solution all roads seem to lead to this blog/solution: http://mvolo.com/iis-70-twolevel-authentication-with-forms-authentication-and-windows-authentication/

However when upgrading to .net 4.5 and IIS8 it breaks, Always forcing a 302 redirect to the login page and no means of getting a hold of the usernamen.

Has anyone solved this yet?

like image 815
Fiffe Avatar asked Dec 04 '13 14:12

Fiffe


People also ask

Can we use Windows Authentication in Web API?

a) To create a web api project in windows authentication mode, follow below steps: After choosing ASP.Net Web Application, select Web API template and from the right side click Change Authentication button and select Windows Authentication.

How many types of authentication ASP.NET supports Windows Authentication?

ASP.NET supports Forms Authentication, Passport Authentication, and Windows authentication providers. The mode is set to one of the authentication modes: Windows, Forms, Passport, or None. The default is Windows.

How do I change Windows Authentication in Visual Studio?

Start Visual Studio and select Create a new project. In the Create a new project dialog, select ASP.NET Core Web App (or Web API) > Next. In the Configure your new project dialog, enter Project name > Next. In the Additional Information dialog, select Authentication Type as Windows.


1 Answers

I made a MVC 5 solution that makes it look like an external provider, the full source code here:

https://github.com/MohammadYounes/MVC5-MixedAuth

I didn't have the chance to test it on IIS 8, try it and let me know.

like image 71
MK. Avatar answered Nov 11 '22 19:11

MK.