UserClaimsPrincipalFactory<TUser, TRole> Class¶
Provides methods to create a claims principal for a given user.
- Namespace
Microsoft.AspNetCore.Identity
- Assemblies
- Microsoft.AspNetCore.Identity
Syntax¶
public class UserClaimsPrincipalFactory<TUser, TRole> : IUserClaimsPrincipalFactory<TUser> where TUser : class where TRole : class
-
class
Microsoft.AspNetCore.Identity.
UserClaimsPrincipalFactory<TUser, TRole>
¶
Constructors¶
-
UserClaimsPrincipalFactory
(Microsoft.AspNetCore.Identity.UserManager<TUser>, Microsoft.AspNetCore.Identity.RoleManager<TRole>, Microsoft.Extensions.Options.IOptions<Microsoft.AspNetCore.Builder.IdentityOptions>)¶ Initializes a new instance of the
Microsoft.AspNetCore.Identity.UserClaimsPrincipalFactory`2
class.Arguments: - userManager (Microsoft.AspNetCore.Identity.UserManager<TUser>) – The
Microsoft.AspNetCore.Identity.UserManager`1
to retrieve user information from. - roleManager (Microsoft.AspNetCore.Identity.RoleManager<TRole>) – The
Microsoft.AspNetCore.Identity.RoleManager`1
to retrieve a user’s roles from. - optionsAccessor (Microsoft.Extensions.Options.IOptions<Microsoft.AspNetCore.Builder.IdentityOptions>) – The configured
Microsoft.AspNetCore.Builder.IdentityOptions
.
public UserClaimsPrincipalFactory(UserManager<TUser> userManager, RoleManager<TRole> roleManager, IOptions<IdentityOptions> optionsAccessor)
- userManager (Microsoft.AspNetCore.Identity.UserManager<TUser>) – The
-
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 System.Threading.Tasks.Task
that represents the asynchronous creation operation, containing the createdSystem.Security.Claims.ClaimsPrincipal
.public virtual Task<ClaimsPrincipal> CreateAsync(TUser user)
-
Properties¶
-
Microsoft.AspNetCore.Identity.UserClaimsPrincipalFactory<TUser, TRole>.
Options
¶ Gets the
Microsoft.AspNetCore.Builder.IdentityOptions
for this factory.Return type: Microsoft.AspNetCore.Builder.IdentityOptions Returns: The current Microsoft.AspNetCore.Builder.IdentityOptions
for this factory instance.public IdentityOptions Options { get; }
-
Microsoft.AspNetCore.Identity.UserClaimsPrincipalFactory<TUser, TRole>.
RoleManager
¶ Gets the
Microsoft.AspNetCore.Identity.RoleManager`1
for this factory.Return type: Microsoft.AspNetCore.Identity.RoleManager<TRole> Returns: The current Microsoft.AspNetCore.Identity.RoleManager`1
for this factory instance.public RoleManager<TRole> RoleManager { get; }
-
Microsoft.AspNetCore.Identity.UserClaimsPrincipalFactory<TUser, TRole>.
UserManager
¶ Gets the
Microsoft.AspNetCore.Identity.UserManager`1
for this factory.Return type: Microsoft.AspNetCore.Identity.UserManager<TUser> Returns: The current Microsoft.AspNetCore.Identity.UserManager`1
for this factory instance.public UserManager<TUser> UserManager { get; }
-