-
Notifications
You must be signed in to change notification settings - Fork 67
ASP.NET MVC 5 Mixed Authentication
Mixing Windows and Forms Authentication (Windows + Forms)
The basic idea is to have a managed handler to perform windows authentication, then hand control over to the cookies authentication middleware.
It will appear as if its an external provider. Sample Screens
No special requirements! Visual Studio Express 2013 is all you need.
-
Clone the repository:
git clone [email protected]:MohammadYounes/MixedAuth.git
-
Open the solution using Visual Studio, build and run.
-
From Solution Explorer, select MixedAuth project then press F4 to view Project Properties and Make sure "Windows Authentication" is enabled.

All AD groups asscociated with the user windows account are available when you hit the WindowsLogin Action, you can fetch all of them by iterating over Request.LogonUserIdentity.Claims
:
private void MapGroupSidToRoleClaims(ApplicationUser user)
{
foreach (var claim in Request.LogonUserIdentity.Claims)
{
if (claim.Type == ClaimTypes.GroupSid)
user.Claims.Add(
new IdentityUserClaim()
{
ClaimType = ClaimTypes.Role,
ClaimValue = new SecurityIdentifier(claim.Value)
.Translate(typeof(NTAccount)).ToString()
});
}
}