12

In MVC4 I enabled <authentication mode="Windows"/> in the web.config and created a custom role provider which then would automatically wrap the WindowsIdentity with a RolePrincipal for you. Worked like a charm.

How would you do this in MVC5 using OWIN and/or Microsoft.ASPNET.Identity?

batkuip
  • 1,480
  • 3
  • 15
  • 25

1 Answers1

10

Its the similar way to configure in web.config or configure at IIS Website.

<authentication mode="Windows" />
<authorization>
  <deny users="?" />
</authorization>

Above is sufficient for intranet application. For additional scenarios like providing additional claims transformation as well as mixed authentication, for ASP.NET application, you can use custom OWIN middleware handler.

Have a look at example of such WindowsPrincipalHandler. You need to register it in startup.cs like app.Use(typeof(WindowsPrincipalHandler))

jd4u
  • 5,789
  • 2
  • 28
  • 28
  • Interesting way of doing it. WindowsPrincipal is already claims aware so they are simply rewriting it without the roles. Would this also be the right place to add the database calls to populate the roles? – batkuip Oct 21 '13 at 21:20