UserClaimsPrincipalFactory<TUser, TRole> Class

Summary

Provides methods to create a claims principal for a given user.

Syntax

public class UserClaimsPrincipalFactory<TUser, TRole> : IUserClaimsPrincipalFactory<TUser> where TUser : class where TRole : class

GitHub

View on GitHub

class Microsoft.AspNet.Identity.UserClaimsPrincipalFactory<TUser, TRole>

Constructors

UserClaimsPrincipalFactory(Microsoft.AspNet.Identity.UserManager<TUser>, Microsoft.AspNet.Identity.RoleManager<TRole>, IOptions<Microsoft.AspNet.Identity.IdentityOptions>)

Initializes a new instance of the ClaimsIdentityFactory class.

Arguments:
  • userManager (Microsoft.AspNet.Identity.UserManager{{TUser}}) – The Microsoft.AspNet.Identity.UserManager`1 to retrieve user information from.
  • roleManager (Microsoft.AspNet.Identity.RoleManager{{TRole}}) – The Microsoft.AspNet.Identity.RoleManager`1 to retrieve a user’s roles from.
  • optionsAccessor (IOptions{Microsoft.AspNet.Identity.IdentityOptions}) – The configured Microsoft.AspNet.Identity.IdentityOptions.
public UserClaimsPrincipalFactory(UserManager<TUser> userManager, RoleManager<TRole> roleManager, IOptions<IdentityOptions> optionsAccessor)

Methods

CreateAsync(TUser)

Creates a System.Security.Claims.ClaimsPrincipal from an user asynchronously.

Arguments:
  • user ({TUser}) – The user to create a System.Security.Claims.ClaimsPrincipal from.
Return type:

System.Threading.Tasks.Task{System.Security.Claims.ClaimsPrincipal}

Returns:

The <see cref=”T:System.Threading.Tasks.Task” /> that represents the asynchronous creation operation, containing the created <see cref=”T:System.Security.Claims.ClaimsPrincipal” />.

public virtual Task<ClaimsPrincipal> CreateAsync(TUser user)

Properties

Options()

Gets the Microsoft.AspNet.Identity.IdentityOptions for this factory.

Return type:Microsoft.AspNet.Identity.IdentityOptions
public IdentityOptions Options { get; }
RoleManager()

Gets the Microsoft.AspNet.Identity.RoleManager`1 for this factory.

Return type:Microsoft.AspNet.Identity.RoleManager{{TRole}}
public RoleManager<TRole> RoleManager { get; }
UserManager()

Gets the Microsoft.AspNet.Identity.UserManager`1 for this factory.

Return type:Microsoft.AspNet.Identity.UserManager{{TUser}}
public UserManager<TUser> UserManager { get; }