Skip to content

ASP.NET MVC 5 Mixed Authentication (Web Forms + Windows)

License

Notifications You must be signed in to change notification settings

JCNikolov/MVC5-MixedAuth

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 

Repository files navigation

ASP.NET MVC 5 Mixed Authentication

Mixing Windows and Forms Authentication (Windows + Forms)

Login

How its done ?

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

Running the solution locally

No special requirements! Visual Studio Express 2013 is all you need.

  • Clone the repository: git clone git@github.com:MohammadYounes/MVC5-MixedAuth.git

  • Open the solution using Visual Studio, build and run.

Enabling Windows Authentication on IIS Express.

  • From Solution Explorer, select MixedAuth project then press F4 to view Project Properties and Make sure "Windows Authentication" is enabled.

    ![IIS Express](https://raw2.github.com/MohammadYounes/MVC5-MixedAuth/screens/screens/WinAuth.Enabled.PNG)
    

Importing AD Groups as Role Claims:

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.Groups:

private void MapGroupsToRoleClaims(ApplicationUser user)
{
  foreach (var group in Request.LogonUserIdentity.Groups)  
    user.Claims.Add(new IdentityUserClaim()
    {
      ClaimType = ClaimTypes.Role,
      ClaimValue = new SecurityIdentifier(group.Value)
                         .Translate(typeof(NTAccount)).Value
    });
}

Please share any issues you may have.

About

ASP.NET MVC 5 Mixed Authentication (Web Forms + Windows)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published