Reputation: 351
Working with Asp.Net Identity allow you to add the claims to a user. And the System.Security.Claims.ClaimTypes allows you to select any ClaimType from various ClaimTypes.
ClaimTypes is a static class and defines constants for well-known claim types that can be assigned to subjects.
I want to store all these claims in a List<> and display them in a ListBox so that the user with the Admin role can assign a ClaimType to a user after registration.
Seems that I can do that as ClaimTypes is a static class and those constants defined in that can't be listed.
Upvotes: 3
Views: 3477
Reputation: 854
You can list out the claim types by reflecting on the fields in the class:
var claimTypes = typeof(System.Security.Claims.ClaimTypes).GetFields().ToList();
For each claimType
in the list, you can use claimType.Name
to get the constant name and claimType.GetValue(null)
to get the constant value.
Upvotes: 5