Created
November 6, 2017 04:30
-
-
Save b-tiwari/892e8641ff84b19adfc257335317b63a to your computer and use it in GitHub Desktop.
AppUserPrincipalClaims.cs - Claims based identity in ASP.Net MVC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Security.Claims; | |
| using System.Web; | |
| namespace csWinAuthWClaims.Views | |
| { | |
| public class AppUserPrincipalClaims : ClaimsPrincipal | |
| { | |
| public AppUserPrincipalClaims(ClaimsPrincipal principal) | |
| : base(principal) | |
| { | |
| } | |
| public string GivenName | |
| { | |
| get { return this.FindFirst(ClaimTypes.GivenName).Value; } | |
| } | |
| public string Surname | |
| { | |
| get { return this.FindFirst(ClaimTypes.Surname).Value; } | |
| } | |
| public string Email | |
| { | |
| get { return this.FindFirst(ClaimTypes.Email).Value; } | |
| } | |
| public string WindowsAccountName | |
| { | |
| get { return this.FindFirst(ClaimTypes.WindowsAccountName).Value; } | |
| } | |
| public string myAppUserRole | |
| { | |
| get { return this.FindFirst("myAppUserRole").Value; } | |
| } | |
| public string MyCustomClaim | |
| { | |
| get { return this.FindFirst("MyCustomClaim").Value; } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment