0

I am building a ASP.NET MVC 5 Web Application which should be used by corporate users. When they are inside the corporate Network the should be authenticated automatically by Windows Authentication. When they call the application from outside the corporate Network from lets say a mobile phone, they should be redirected to a logon page where they can authenticate against active Directory. I've tried different things, but haven't been successfully so far. The last thing I tried was to create an authentication filter with the following configuration:

Web Application setting in IIS: Authentication = Windows Authentication Web.Config Setting: authentication mode = Windows

From inside the Network this works fine. But when I try to authenticate from outside I get the authentication request before the AuthenticationFilter was hit.

In the second try I tried the following Settings:

Web Application setting in IIS: Authentication = Windows Authentication + Anonymous Web.Config Setting: authentication mode = Windows

With this Setting when I call the site from inside the Network the AuthenticationFilter gets hit twice. The first time with anonymous authentication, the second time with the real user I am logged in with.

Is there a way to configure the order authentication happens or any other way to get both Scenarios handled?

tereško
  • 58,060
  • 25
  • 98
  • 150
Franz Kiermaier
  • 387
  • 3
  • 19
  • I don't think there is something you can configure to obtain what you're looking for, Take a look at those: http://stackoverflow.com/questions/863080/asp-net-membership-which-roleprovider-to-use-so-user-isinrole-checks-actived http://stackoverflow.com/questions/2250921/mixing-forms-authentication-with-windows-authentication http://stackoverflow.com/questions/6153266/windows-authentication-hybrid http://stackoverflow.com/questions/3232072/mixed-mode-authentication-against-ad-and-fallback-to-the-database-if-it-fail-wit And: http://www.justskins.com/forums/mixed-mode-forms-and-250928.html – Fourat Feb 19 '15 at 08:27
  • Hi, I went the way to have two Websites. One with Windows integrated authentication, the other one with forms authentication. Thanks – Franz Kiermaier Feb 19 '15 at 10:31

1 Answers1

0

I have now used this Approach to implement the forms based authentication: http://www.schiffhauer.com/mvc-5-and-active-directory-authentication/

Franz Kiermaier
  • 387
  • 3
  • 19
  • This guide does not appear to work with MVC 5. It just causes a constant redirect back to the login page after successfully authenticating. – Joe Stellato Apr 06 '17 at 04:04