UserManager<TUser> Class

Provides the APIs for managing user in a persistence store.

Namespace
Microsoft.AspNetCore.Identity
Assemblies
  • Microsoft.AspNetCore.Identity

Syntax

public class UserManager<TUser> : IDisposable where TUser : class
class Microsoft.AspNetCore.Identity.UserManager<TUser>

Constructors

UserManager(Microsoft.AspNetCore.Identity.IUserStore<TUser>, Microsoft.Extensions.Options.IOptions<Microsoft.AspNetCore.Builder.IdentityOptions>, Microsoft.AspNetCore.Identity.IPasswordHasher<TUser>, System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Identity.IUserValidator<TUser>>, System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Identity.IPasswordValidator<TUser>>, Microsoft.AspNetCore.Identity.ILookupNormalizer, Microsoft.AspNetCore.Identity.IdentityErrorDescriber, System.IServiceProvider, Microsoft.Extensions.Logging.ILogger<Microsoft.AspNetCore.Identity.UserManager<TUser>>)

Constructs a new instance of Microsoft.AspNetCore.Identity.UserManager`1.

Arguments:
public UserManager(IUserStore<TUser> store, IOptions<IdentityOptions> optionsAccessor, IPasswordHasher<TUser> passwordHasher, IEnumerable<IUserValidator<TUser>> userValidators, IEnumerable<IPasswordValidator<TUser>> passwordValidators, ILookupNormalizer keyNormalizer, IdentityErrorDescriber errors, IServiceProvider services, ILogger<UserManager<TUser>> logger)

Methods

AccessFailedAsync(TUser)

Increments the access failed count for the user as an asynchronous operation. If the failed access account is greater than or equal to the configured maximum number of attempts, the user will be locked out for the configured lockout time span.

Arguments:user (TUser) – The user whose failed access count to increment.
Return type:System.Threading.Tasks.Task<Microsoft.AspNetCore.Identity.IdentityResult>
Returns:The System.Threading.Tasks.Task that represents the asynchronous operation, containing the Microsoft.AspNetCore.Identity.IdentityResult of the operation.
public virtual Task<IdentityResult> AccessFailedAsync(TUser user)
AddClaimAsync(TUser, System.Security.Claims.Claim)

Adds the specified <em>claim</em> to the <em>user</em>.

Arguments:
  • user (TUser) – The user to add the claim to.
  • claim (System.Security.Claims.Claim) – The claim to add.
Return type:

System.Threading.Tasks.Task<Microsoft.AspNetCore.Identity.IdentityResult>

Returns:

The System.Threading.Tasks.Task that represents the asynchronous operation, containing the Microsoft.AspNetCore.Identity.IdentityResult of the operation.

public virtual Task<IdentityResult> AddClaimAsync(TUser user, Claim claim)
AddClaimsAsync(TUser, System.Collections.Generic.IEnumerable<System.Security.Claims.Claim>)

Adds the specified <em>claims</em> to the <em>user</em>.

Arguments:
  • user (TUser) – The user to add the claim to.
  • claims (System.Collections.Generic.IEnumerable<System.Security.Claims.Claim>) – The claims to add.
Return type:

System.Threading.Tasks.Task<Microsoft.AspNetCore.Identity.IdentityResult>

Returns:

The System.Threading.Tasks.Task that represents the asynchronous operation, containing the Microsoft.AspNetCore.Identity.IdentityResult of the operation.

public virtual Task<IdentityResult> AddClaimsAsync(TUser user, IEnumerable<Claim> claims)
AddLoginAsync(TUser, Microsoft.AspNetCore.Identity.UserLoginInfo)

Adds an external Microsoft.AspNetCore.Identity.UserLoginInfo to the specified <em>user</em>.

Arguments:
Return type:

System.Threading.Tasks.Task<Microsoft.AspNetCore.Identity.IdentityResult>

Returns:

The System.Threading.Tasks.Task that represents the asynchronous operation, containing the Microsoft.AspNetCore.Identity.IdentityResult of the operation.

public virtual Task<IdentityResult> AddLoginAsync(TUser user, UserLoginInfo login)
AddPasswordAsync(TUser, System.String)

Adds the <em>password</em> to the specified <em>user</em> only if the user does not already have a password.

Arguments:
  • user (TUser) – The user whose password should be set.
  • password (System.String) – The password to set.
Return type:

System.Threading.Tasks.Task<Microsoft.AspNetCore.Identity.IdentityResult>

Returns:

The System.Threading.Tasks.Task that represents the asynchronous operation, containing the Microsoft.AspNetCore.Identity.IdentityResult of the operation.

public virtual Task<IdentityResult> AddPasswordAsync(TUser user, string password)
AddToRoleAsync(TUser, System.String)

Add the specified <em>user</em> to the named role.

Arguments:
  • user (TUser) – The user to add to the named role.
  • role (System.String) – The name of the role to add the user to.
Return type:

System.Threading.Tasks.Task<Microsoft.AspNetCore.Identity.IdentityResult>

Returns:

The System.Threading.Tasks.Task that represents the asynchronous operation, containing the Microsoft.AspNetCore.Identity.IdentityResult of the operation.

public virtual Task<IdentityResult> AddToRoleAsync(TUser user, string role)
AddToRolesAsync(TUser, System.Collections.Generic.IEnumerable<System.String>)

Add the specified <em>user</em> to the named roles.

Arguments:
  • user (TUser) – The user to add to the named roles.
  • roles (System.Collections.Generic.IEnumerable<System.String>) – The name of the roles to add the user to.
Return type:

System.Threading.Tasks.Task<Microsoft.AspNetCore.Identity.IdentityResult>

Returns:

The System.Threading.Tasks.Task that represents the asynchronous operation, containing the Microsoft.AspNetCore.Identity.IdentityResult of the operation.

public virtual Task<IdentityResult> AddToRolesAsync(TUser user, IEnumerable<string> roles)
ChangeEmailAsync(TUser, System.String, System.String)

Updates a users emails if the specified email change <em>token</em> is valid for the user.

Arguments:
  • user (TUser) – The user whose email should be updated.
  • newEmail (System.String) – The new email address.
  • token (System.String) – The change email token to be verified.
Return type:

System.Threading.Tasks.Task<Microsoft.AspNetCore.Identity.IdentityResult>

Returns:

The System.Threading.Tasks.Task that represents the asynchronous operation, containing the Microsoft.AspNetCore.Identity.IdentityResult of the operation.

public virtual Task<IdentityResult> ChangeEmailAsync(TUser user, string newEmail, string token)
ChangePasswordAsync(TUser, System.String, System.String)

Changes a user’s password after confirming the specified <em>currentPassword</em> is correct, as an asynchronous operation.

Arguments:
  • user (TUser) – The user whose password should be set.
  • currentPassword (System.String) – The current password to validate before changing.
  • newPassword (System.String) – The new password to set for the specified <em>user</em>.
Return type:

System.Threading.Tasks.Task<Microsoft.AspNetCore.Identity.IdentityResult>

Returns:

The System.Threading.Tasks.Task that represents the asynchronous operation, containing the Microsoft.AspNetCore.Identity.IdentityResult of the operation.

public virtual Task<IdentityResult> ChangePasswordAsync(TUser user, string currentPassword, string newPassword)
ChangePhoneNumberAsync(TUser, System.String, System.String)

Sets the phone number for the specified <em>user</em> if the specified change <em>token</em> is valid.

Arguments:
  • user (TUser) – The user whose phone number to set.
  • phoneNumber (System.String) – The phone number to set.
  • token (System.String) – The phone number confirmation token to validate.
Return type:

System.Threading.Tasks.Task<Microsoft.AspNetCore.Identity.IdentityResult>

Returns:

The System.Threading.Tasks.Task that represents the asynchronous operation, containing the Microsoft.AspNetCore.Identity.IdentityResult of the operation.

public virtual Task<IdentityResult> ChangePhoneNumberAsync(TUser user, string phoneNumber, string token)
CheckPasswordAsync(TUser, System.String)

Returns a flag indicating whether the given <em>password</em> is valid for the specified <em>user</em>.

Arguments:
  • user (TUser) – The user whose password should be validated.
  • password (System.String) – The password to validate
Return type:

System.Threading.Tasks.Task<System.Boolean>

Returns:

The System.Threading.Tasks.Task that represents the asynchronous operation, containing true if the specified <em>password</em> matches the one store for the <em>user</em>, otherwise false.

public virtual Task<bool> CheckPasswordAsync(TUser user, string password)
ConfirmEmailAsync(TUser, System.String)

Validates that an email confirmation token matches the specified <em>user</em>.

Arguments:
  • user (TUser) – The user to validate the token against.
  • token (System.String) – The email confirmation token to validate.
Return type:

System.Threading.Tasks.Task<Microsoft.AspNetCore.Identity.IdentityResult>

Returns:

The System.Threading.Tasks.Task that represents the asynchronous operation, containing the Microsoft.AspNetCore.Identity.IdentityResult of the operation.

public virtual Task<IdentityResult> ConfirmEmailAsync(TUser user, string token)
CreateAsync(TUser)

Creates the specified <em>user</em> in the backing store with no password, as an asynchronous operation.

Arguments:user (TUser) – The user to create.
Return type:System.Threading.Tasks.Task<Microsoft.AspNetCore.Identity.IdentityResult>
Returns:The System.Threading.Tasks.Task that represents the asynchronous operation, containing the Microsoft.AspNetCore.Identity.IdentityResult of the operation.
public virtual Task<IdentityResult> CreateAsync(TUser user)
CreateAsync(TUser, System.String)

Creates the specified <em>user</em> in the backing store with given password, as an asynchronous operation.

Arguments:
  • user (TUser) – The user to create.
  • password (System.String) – The password for the user to hash and store.
Return type:

System.Threading.Tasks.Task<Microsoft.AspNetCore.Identity.IdentityResult>

Returns:

The System.Threading.Tasks.Task that represents the asynchronous operation, containing the Microsoft.AspNetCore.Identity.IdentityResult of the operation.

public virtual Task<IdentityResult> CreateAsync(TUser user, string password)
DeleteAsync(TUser)

Deletes the specified <em>user</em> from the backing store.

Arguments:user (TUser) – The user to delete.
Return type:System.Threading.Tasks.Task<Microsoft.AspNetCore.Identity.IdentityResult>
Returns:The System.Threading.Tasks.Task that represents the asynchronous operation, containing the Microsoft.AspNetCore.Identity.IdentityResult of the operation.
public virtual Task<IdentityResult> DeleteAsync(TUser user)
Dispose()

Releases all resources used by the user manager.

public void Dispose()
Dispose(System.Boolean)

Releases the unmanaged resources used by the role manager and optionally releases the managed resources.

Arguments:disposing (System.Boolean) – true to release both managed and unmanaged resources; false to release only unmanaged resources.
protected virtual void Dispose(bool disposing)
FindByEmailAsync(System.String)

Gets the user, if any, associated with the specified, normalized email address.

Arguments:email (System.String) – The normalized email address to return the user for.
Return type:System.Threading.Tasks.Task<TUser>
Returns:The task object containing the results of the asynchronous lookup operation, the user if any associated with the specified normalized email address.
public virtual Task<TUser> FindByEmailAsync(string email)
FindByIdAsync(System.String)

Finds and returns a user, if any, who has the specified <em>userId</em>.

Arguments:userId (System.String) – The user ID to search for.
Return type:System.Threading.Tasks.Task<TUser>
Returns:The System.Threading.Tasks.Task that represents the asynchronous operation, containing the user matching the specified <em>userId</em> if it exists.
public virtual Task<TUser> FindByIdAsync(string userId)
FindByLoginAsync(System.String, System.String)

Retrieves the user associated with the specified external login provider and login provider key..

Arguments:
  • loginProvider (System.String) – The login provider who provided the <em>providerKey</em>.
  • providerKey (System.String) – The key provided by the <em>loginProvider</em> to identify a user.
Return type:

System.Threading.Tasks.Task<TUser>

Returns:

The System.Threading.Tasks.Task for the asynchronous operation, containing the user, if any which matched the specified login provider and key.

public virtual Task<TUser> FindByLoginAsync(string loginProvider, string providerKey)
FindByNameAsync(System.String)

Finds and returns a user, if any, who has the specified user name.

Arguments:userName (System.String) – The user name to search for.
Return type:System.Threading.Tasks.Task<TUser>
Returns:The System.Threading.Tasks.Task that represents the asynchronous operation, containing the user matching the specified <em>userName</em> if it exists.
public virtual Task<TUser> FindByNameAsync(string userName)
GenerateChangeEmailTokenAsync(TUser, System.String)

Generates an email change token for the specified user.

Arguments:
  • user (TUser) – The user to generate an email change token for.
  • newEmail (System.String) – The new email address.
Return type:

System.Threading.Tasks.Task<System.String>

Returns:

The System.Threading.Tasks.Task that represents the asynchronous operation, an email change token.

public virtual Task<string> GenerateChangeEmailTokenAsync(TUser user, string newEmail)
GenerateChangePhoneNumberTokenAsync(TUser, System.String)

Generates a telephone number change token for the specified user.

Arguments:
  • user (TUser) – The user to generate a telephone number token for.
  • phoneNumber (System.String) – The new phone number the validation token should be sent to.
Return type:

System.Threading.Tasks.Task<System.String>

Returns:

The System.Threading.Tasks.Task that represents the asynchronous operation, containing the telephone change number token.

public virtual Task<string> GenerateChangePhoneNumberTokenAsync(TUser user, string phoneNumber)
GenerateConcurrencyStampAsync(TUser)

Generates a value suitable for use in concurrency tracking.

Arguments:user (TUser) – The user to generate the stamp for.
Return type:System.Threading.Tasks.Task<System.String>
Returns:The System.Threading.Tasks.Task that represents the asynchronous operation, containing the security stamp for the specified <em>user</em>.
public virtual Task<string> GenerateConcurrencyStampAsync(TUser user)
GenerateEmailConfirmationTokenAsync(TUser)

Generates an email confirmation token for the specified user.

Arguments:user (TUser) – The user to generate an email confirmation token for.
Return type:System.Threading.Tasks.Task<System.String>
Returns:The System.Threading.Tasks.Task that represents the asynchronous operation, an email confirmation token.
public virtual Task<string> GenerateEmailConfirmationTokenAsync(TUser user)
GeneratePasswordResetTokenAsync(TUser)

Generates a password reset token for the specified <em>user</em>, using the configured password reset token provider.

Arguments:user (TUser) – The user to generate a password reset token for.
Return type:System.Threading.Tasks.Task<System.String>
Returns:The System.Threading.Tasks.Task that represents the asynchronous operation, containing a password reset token for the specified <em>user</em>.
public virtual Task<string> GeneratePasswordResetTokenAsync(TUser user)
GenerateTwoFactorTokenAsync(TUser, System.String)

Gets a two factor authentication token for the specified <em>user</em>.

Arguments:
  • user (TUser) – The user the token is for.
  • tokenProvider (System.String) – The provider which will generate the token.
Return type:

System.Threading.Tasks.Task<System.String>

Returns:

The System.Threading.Tasks.Task that represents result of the asynchronous operation, a two factor authentication token for the user.

public virtual Task<string> GenerateTwoFactorTokenAsync(TUser user, string tokenProvider)
GenerateUserTokenAsync(TUser, System.String, System.String)

Generates a token for the given <em>user</em> and <em>purpose</em>.

Arguments:
  • user (TUser) – The user the token will be for.
  • tokenProvider (System.String) – The provider which will generate the token.
  • purpose (System.String) – The purpose the token will be for.
Return type:

System.Threading.Tasks.Task<System.String>

Returns:

The System.Threading.Tasks.Task that represents result of the asynchronous operation, a token for the given user and purpose.

public virtual Task<string> GenerateUserTokenAsync(TUser user, string tokenProvider, string purpose)
GetAccessFailedCountAsync(TUser)

Retrieves the current number of failed accesses for the given <em>user</em>.

Arguments:user (TUser) – The user whose access failed count should be retrieved for.
Return type:System.Threading.Tasks.Task<System.Int32>
Returns:The System.Threading.Tasks.Task that contains the result the asynchronous operation, the current failed access count for the user.
public virtual Task<int> GetAccessFailedCountAsync(TUser user)
GetAuthenticationTokenAsync(TUser, System.String, System.String)

Returns an authentication token for a user.

Arguments:
  • loginProvider (System.String) – The authentication scheme for the provider the token is associated with.
  • tokenName (System.String) – The name of the token.
Return type:

System.Threading.Tasks.Task<System.String>

public virtual Task<string> GetAuthenticationTokenAsync(TUser user, string loginProvider, string tokenName)
GetChangeEmailTokenPurpose(System.String)

Generates the token purpose used to change email

Return type:System.String
protected static string GetChangeEmailTokenPurpose(string newEmail)
GetClaimsAsync(TUser)

Gets a list of System.Security.Claims.Claims to be belonging to the specified <em>user</em> as an asynchronous operation.

Arguments:user (TUser) – The user whose claims to retrieve.
Return type:System.Threading.Tasks.Task<System.Collections.Generic.IList<System.Security.Claims.Claim>>
Returns:A System.Threading.Tasks.Task`1 that represents the result of the asynchronous query, a list of System.Security.Claims.Claims.
public virtual Task<IList<Claim>> GetClaimsAsync(TUser user)
GetEmailAsync(TUser)

Gets the email address for the specified <em>user</em>.

Arguments:user (TUser) – The user whose email should be returned.
Return type:System.Threading.Tasks.Task<System.String>
Returns:The task object containing the results of the asynchronous operation, the email address for the specified <em>user</em>.
public virtual Task<string> GetEmailAsync(TUser user)
GetLockoutEnabledAsync(TUser)

Retrieves a flag indicating whether user lockout can enabled for the specified user.

Arguments:user (TUser) – The user whose ability to be locked out should be returned.
Return type:System.Threading.Tasks.Task<System.Boolean>
Returns:The System.Threading.Tasks.Task that represents the asynchronous operation, true if a user can be locked out, otherwise false.
public virtual Task<bool> GetLockoutEnabledAsync(TUser user)
GetLockoutEndDateAsync(TUser)

Gets the last System.DateTimeOffset a user’s last lockout expired, if any. Any time in the past should be indicates a user is not locked out.

Arguments:user (TUser) – The user whose lockout date should be retrieved.
Return type:System.Threading.Tasks.Task<System.Nullable<System.DateTimeOffset>>
Returns:A System.Threading.Tasks.Task`1 that represents the lookup, a System.DateTimeOffset containing the last time a user’s lockout expired, if any.
public virtual Task<DateTimeOffset? > GetLockoutEndDateAsync(TUser user)
GetLoginsAsync(TUser)

Retrieves the associated logins for the specified <param ref=”user” />.

Arguments:user (TUser) – The user whose associated logins to retrieve.
Return type:System.Threading.Tasks.Task<System.Collections.Generic.IList<Microsoft.AspNetCore.Identity.UserLoginInfo>>
Returns:The System.Threading.Tasks.Task for the asynchronous operation, containing a list of Microsoft.AspNetCore.Identity.UserLoginInfo for the specified <em>user</em>, if any.
public virtual Task<IList<UserLoginInfo>> GetLoginsAsync(TUser user)
GetPhoneNumberAsync(TUser)

Gets the telephone number, if any, for the specified <em>user</em>.

Arguments:user (TUser) – The user whose telephone number should be retrieved.
Return type:System.Threading.Tasks.Task<System.String>
Returns:The System.Threading.Tasks.Task that represents the asynchronous operation, containing the user’s telephone number, if any.
public virtual Task<string> GetPhoneNumberAsync(TUser user)
GetRolesAsync(TUser)

Gets a list of role names the specified <em>user</em> belongs to.

Arguments:user (TUser) – The user whose role names to retrieve.
Return type:System.Threading.Tasks.Task<System.Collections.Generic.IList<System.String>>
Returns:The System.Threading.Tasks.Task that represents the asynchronous operation, containing a list of role names.
public virtual Task<IList<string>> GetRolesAsync(TUser user)
GetSecurityStampAsync(TUser)

Get the security stamp for the specified <em>user</em>.

Arguments:user (TUser) – The user whose security stamp should be set.
Return type:System.Threading.Tasks.Task<System.String>
Returns:The System.Threading.Tasks.Task that represents the asynchronous operation, containing the security stamp for the specified <em>user</em>.
public virtual Task<string> GetSecurityStampAsync(TUser user)
GetTwoFactorEnabledAsync(TUser)

Returns a flag indicating whether the specified <em>user</em> has two factor authentication enabled or not, as an asynchronous operation.

Arguments:user (TUser) – The user whose two factor authentication enabled status should be retrieved.
Return type:System.Threading.Tasks.Task<System.Boolean>
Returns:The System.Threading.Tasks.Task that represents the asynchronous operation, true if the specified <em>user </em> has two factor authentication enabled, otherwise false.
public virtual Task<bool> GetTwoFactorEnabledAsync(TUser user)
GetUserAsync(System.Security.Claims.ClaimsPrincipal)
Return type:System.Threading.Tasks.Task<TUser>
public virtual Task<TUser> GetUserAsync(ClaimsPrincipal principal)
GetUserId(System.Security.Claims.ClaimsPrincipal)

Returns the User ID claim value if present otherwise returns null.

Arguments:principal (System.Security.Claims.ClaimsPrincipal) – The System.Security.Claims.ClaimsPrincipal instance.
Return type:System.String
Returns:The User ID claim value, or null if the claim is not present.
public virtual string GetUserId(ClaimsPrincipal principal)
GetUserIdAsync(TUser)

Gets the user identifier for the specified <em>user</em>.

Arguments:user (TUser) – The user whose identifier should be retrieved.
Return type:System.Threading.Tasks.Task<System.String>
Returns:The System.Threading.Tasks.Task that represents the asynchronous operation, containing the identifier for the specified <em>user</em>.
public virtual Task<string> GetUserIdAsync(TUser user)
GetUserName(System.Security.Claims.ClaimsPrincipal)

Returns the Name claim value if present otherwise returns null.

Arguments:principal (System.Security.Claims.ClaimsPrincipal) – The System.Security.Claims.ClaimsPrincipal instance.
Return type:System.String
Returns:The Name claim value, or null if the claim is not present.
public virtual string GetUserName(ClaimsPrincipal principal)
GetUserNameAsync(TUser)

Gets the user name for the specified <em>user</em>.

Arguments:user (TUser) – The user whose name should be retrieved.
Return type:System.Threading.Tasks.Task<System.String>
Returns:The System.Threading.Tasks.Task that represents the asynchronous operation, containing the name for the specified <em>user</em>.
public virtual Task<string> GetUserNameAsync(TUser user)
GetUsersForClaimAsync(System.Security.Claims.Claim)

Returns a list of users from the user store who have the specified <em>claim</em>.

Arguments:claim (System.Security.Claims.Claim) – The claim to look for.
Return type:System.Threading.Tasks.Task<System.Collections.Generic.IList<TUser>>
Returns:A System.Threading.Tasks.Task`1 that represents the result of the asynchronous query, a list of <em>TUser</em>s who have the specified claim.
public virtual Task<IList<TUser>> GetUsersForClaimAsync(Claim claim)
GetUsersInRoleAsync(System.String)

Returns a list of users from the user store who are members of the specified <em>roleName</em>.

Arguments:roleName (System.String) – The name of the role whose users should be returned.
Return type:System.Threading.Tasks.Task<System.Collections.Generic.IList<TUser>>
Returns:A System.Threading.Tasks.Task`1 that represents the result of the asynchronous query, a list of <em>TUser</em>s who are members of the specified role.
public virtual Task<IList<TUser>> GetUsersInRoleAsync(string roleName)
GetValidTwoFactorProvidersAsync(TUser)

Gets a list of valid two factor token providers for the specified <em>user</em>, as an asynchronous operation.

Arguments:user (TUser) – The user the whose two factor authentication providers will be returned.
Return type:System.Threading.Tasks.Task<System.Collections.Generic.IList<System.String>>
Returns:The System.Threading.Tasks.Task that represents result of the asynchronous operation, a list of two factor authentication providers for the specified user.
public virtual Task<IList<string>> GetValidTwoFactorProvidersAsync(TUser user)
HasPasswordAsync(TUser)

Gets a flag indicating whether the specified <em>user</em> has a password.

Arguments:user (TUser) – The user to return a flag for, indicating whether they have a password or not.
Return type:System.Threading.Tasks.Task<System.Boolean>
Returns:The System.Threading.Tasks.Task that represents the asynchronous operation, returning true if the specified <em>user</em> has a password otherwise false.
public virtual Task<bool> HasPasswordAsync(TUser user)
IsEmailConfirmedAsync(TUser)

Gets a flag indicating whether the email address for the specified <em>user</em> has been verified, true if the email address is verified otherwise false.

Arguments:user (TUser) – The user whose email confirmation status should be returned.
Return type:System.Threading.Tasks.Task<System.Boolean>
Returns:The task object containing the results of the asynchronous operation, a flag indicating whether the email address for the specified <em>user</em> has been confirmed or not.
public virtual Task<bool> IsEmailConfirmedAsync(TUser user)
IsInRoleAsync(TUser, System.String)

Returns a flag indicating whether the specified <em>user</em> is a member of the give named role.

Arguments:
  • user (TUser) – The user whose role membership should be checked.
  • role (System.String) – The name of the role to be checked.
Return type:

System.Threading.Tasks.Task<System.Boolean>

Returns:

The System.Threading.Tasks.Task that represents the asynchronous operation, containing a flag indicating whether the specified <em>user</em> is a member of the named role.

public virtual Task<bool> IsInRoleAsync(TUser user, string role)
IsLockedOutAsync(TUser)

Returns a flag indicating whether the specified <em>user</em> his locked out, as an asynchronous operation.

Arguments:user (TUser) – The user whose locked out status should be retrieved.
Return type:System.Threading.Tasks.Task<System.Boolean>
Returns:The System.Threading.Tasks.Task that represents the asynchronous operation, true if the specified <em>user </em> is locked out, otherwise false.
public virtual Task<bool> IsLockedOutAsync(TUser user)
IsPhoneNumberConfirmedAsync(TUser)

Gets a flag indicating whether the specified <em>user</em>’s telephone number has been confirmed.

Arguments:user (TUser) – The user to return a flag for, indicating whether their telephone number is confirmed.
Return type:System.Threading.Tasks.Task<System.Boolean>
Returns:The System.Threading.Tasks.Task that represents the asynchronous operation, returning true if the specified <em>user</em> has a confirmed telephone number otherwise false.
public virtual Task<bool> IsPhoneNumberConfirmedAsync(TUser user)
NormalizeKey(System.String)

Normalize a key (user name, email) for consistent comparisons.

Arguments:key (System.String) – The key to normalize.
Return type:System.String
Returns:A normalized value representing the specified <em>key</em>.
public virtual string NormalizeKey(string key)
RegisterTokenProvider(System.String, Microsoft.AspNetCore.Identity.IUserTwoFactorTokenProvider<TUser>)

Registers a token provider.

Arguments:
public virtual void RegisterTokenProvider(string providerName, IUserTwoFactorTokenProvider<TUser> provider)
RemoveAuthenticationTokenAsync(TUser, System.String, System.String)

Remove an authentication token for a user.

Arguments:
  • loginProvider (System.String) – The authentication scheme for the provider the token is associated with.
  • tokenName (System.String) – The name of the token.
Return type:

System.Threading.Tasks.Task<Microsoft.AspNetCore.Identity.IdentityResult>

Returns:

Whether a token was removed.

public virtual Task<IdentityResult> RemoveAuthenticationTokenAsync(TUser user, string loginProvider, string tokenName)
RemoveClaimAsync(TUser, System.Security.Claims.Claim)

Removes the specified <em>claim</em> from the given <em>user</em>.

Arguments:
  • user (TUser) – The user to remove the specified <em>claim</em> from.
  • claim (System.Security.Claims.Claim) – The System.Security.Claims.Claim to remove.
Return type:

System.Threading.Tasks.Task<Microsoft.AspNetCore.Identity.IdentityResult>

Returns:

The System.Threading.Tasks.Task that represents the asynchronous operation, containing the Microsoft.AspNetCore.Identity.IdentityResult of the operation.

public virtual Task<IdentityResult> RemoveClaimAsync(TUser user, Claim claim)
RemoveClaimsAsync(TUser, System.Collections.Generic.IEnumerable<System.Security.Claims.Claim>)

Removes the specified <em>claims</em> from the given <em>user</em>.

Arguments:
  • user (TUser) – The user to remove the specified <em>claims</em> from.
  • claims (System.Collections.Generic.IEnumerable<System.Security.Claims.Claim>) – A collection of System.Security.Claims.Claims to remove.
Return type:

System.Threading.Tasks.Task<Microsoft.AspNetCore.Identity.IdentityResult>

Returns:

The System.Threading.Tasks.Task that represents the asynchronous operation, containing the Microsoft.AspNetCore.Identity.IdentityResult of the operation.

public virtual Task<IdentityResult> RemoveClaimsAsync(TUser user, IEnumerable<Claim> claims)
RemoveFromRoleAsync(TUser, System.String)

Removes the specified <em>user</em> from the named role.

Arguments:
  • user (TUser) – The user to remove from the named role.
  • role (System.String) – The name of the role to remove the user from.
Return type:

System.Threading.Tasks.Task<Microsoft.AspNetCore.Identity.IdentityResult>

Returns:

The System.Threading.Tasks.Task that represents the asynchronous operation, containing the Microsoft.AspNetCore.Identity.IdentityResult of the operation.

public virtual Task<IdentityResult> RemoveFromRoleAsync(TUser user, string role)
RemoveFromRolesAsync(TUser, System.Collections.Generic.IEnumerable<System.String>)

Removes the specified <em>user</em> from the named roles.

Arguments:
  • user (TUser) – The user to remove from the named roles.
  • roles (System.Collections.Generic.IEnumerable<System.String>) – The name of the roles to remove the user from.
Return type:

System.Threading.Tasks.Task<Microsoft.AspNetCore.Identity.IdentityResult>

Returns:

The System.Threading.Tasks.Task that represents the asynchronous operation, containing the Microsoft.AspNetCore.Identity.IdentityResult of the operation.

public virtual Task<IdentityResult> RemoveFromRolesAsync(TUser user, IEnumerable<string> roles)
RemoveLoginAsync(TUser, System.String, System.String)

Attempts to remove the provided external login information from the specified <em>user</em>. and returns a flag indicating whether the removal succeed or not.

Arguments:
  • user (TUser) – The user to remove the login information from.
  • loginProvider (System.String) – The login provide whose information should be removed.
  • providerKey (System.String) – The key given by the external login provider for the specified user.
Return type:

System.Threading.Tasks.Task<Microsoft.AspNetCore.Identity.IdentityResult>

Returns:

The System.Threading.Tasks.Task that represents the asynchronous operation, containing the Microsoft.AspNetCore.Identity.IdentityResult of the operation.

public virtual Task<IdentityResult> RemoveLoginAsync(TUser user, string loginProvider, string providerKey)
RemovePasswordAsync(TUser, System.Threading.CancellationToken)

Removes a user’s password.

Arguments:
  • user (TUser) – The user whose password should be removed.
  • cancellationToken (System.Threading.CancellationToken) – The Microsoft.AspNetCore.Identity.UserManager`1.CancellationToken used to propagate notifications that the operation should be canceled.
Return type:

System.Threading.Tasks.Task<Microsoft.AspNetCore.Identity.IdentityResult>

Returns:

The System.Threading.Tasks.Task that represents the asynchronous operation, containing the Microsoft.AspNetCore.Identity.IdentityResult of the operation.

public virtual Task<IdentityResult> RemovePasswordAsync(TUser user, CancellationToken cancellationToken = null)
ReplaceClaimAsync(TUser, System.Security.Claims.Claim, System.Security.Claims.Claim)

Replaces the given <em>claim</em> on the specified <em>user</em> with the <em>newClaim</em>

Arguments:
  • user (TUser) – The user to replace the claim on.
  • claim (System.Security.Claims.Claim) – The claim to replace.
  • newClaim (System.Security.Claims.Claim) – The new claim to replace the existing <em>claim</em> with.
Return type:

System.Threading.Tasks.Task<Microsoft.AspNetCore.Identity.IdentityResult>

Returns:

The System.Threading.Tasks.Task that represents the asynchronous operation, containing the Microsoft.AspNetCore.Identity.IdentityResult of the operation.

public virtual Task<IdentityResult> ReplaceClaimAsync(TUser user, Claim claim, Claim newClaim)
ResetAccessFailedCountAsync(TUser)

Resets the access failed count for the specified <em>user</em>.

Arguments:user (TUser) – The user whose failed access count should be reset.
Return type:System.Threading.Tasks.Task<Microsoft.AspNetCore.Identity.IdentityResult>
Returns:The System.Threading.Tasks.Task that represents the asynchronous operation, containing the Microsoft.AspNetCore.Identity.IdentityResult of the operation.
public virtual Task<IdentityResult> ResetAccessFailedCountAsync(TUser user)
ResetPasswordAsync(TUser, System.String, System.String)

Resets the <em>user</em>’s password to the specified <em>newPassword</em> after validating the given password reset <em>token</em>.

Arguments:
  • user (TUser) – The user whose password should be reset.
  • token (System.String) – The password reset token to verify.
  • newPassword (System.String) – The new password to set if reset token verification fails.
Return type:

System.Threading.Tasks.Task<Microsoft.AspNetCore.Identity.IdentityResult>

Returns:

The System.Threading.Tasks.Task that represents the asynchronous operation, containing the Microsoft.AspNetCore.Identity.IdentityResult of the operation.

public virtual Task<IdentityResult> ResetPasswordAsync(TUser user, string token, string newPassword)
SetAuthenticationTokenAsync(TUser, System.String, System.String, System.String)

Sets an authentication token for a user.

Arguments:
  • loginProvider (System.String) – The authentication scheme for the provider the token is associated with.
  • tokenName (System.String) – The name of the token.
  • tokenValue (System.String) – The value of the token.
Return type:

System.Threading.Tasks.Task<Microsoft.AspNetCore.Identity.IdentityResult>

public virtual Task<IdentityResult> SetAuthenticationTokenAsync(TUser user, string loginProvider, string tokenName, string tokenValue)
SetEmailAsync(TUser, System.String)

Sets the <em>email</em> address for a <em>user</em>.

Arguments:
  • user (TUser) – The user whose email should be set.
  • email (System.String) – The email to set.
Return type:

System.Threading.Tasks.Task<Microsoft.AspNetCore.Identity.IdentityResult>

Returns:

The System.Threading.Tasks.Task that represents the asynchronous operation, containing the Microsoft.AspNetCore.Identity.IdentityResult of the operation.

public virtual Task<IdentityResult> SetEmailAsync(TUser user, string email)
SetLockoutEnabledAsync(TUser, System.Boolean)

Sets a flag indicating whether the specified <em>user</em> is locked out, as an asynchronous operation.

Arguments:
  • user (TUser) – The user whose locked out status should be set.
  • enabled (System.Boolean) – Flag indicating whether the user is locked out or not.
Return type:

System.Threading.Tasks.Task<Microsoft.AspNetCore.Identity.IdentityResult>

Returns:

The System.Threading.Tasks.Task that represents the asynchronous operation, the Microsoft.AspNetCore.Identity.IdentityResult of the operation

public virtual Task<IdentityResult> SetLockoutEnabledAsync(TUser user, bool enabled)
SetLockoutEndDateAsync(TUser, System.Nullable<System.DateTimeOffset>)

Locks out a user until the specified end date has passed. Setting a end date in the past immediately unlocks a user.

Arguments:
  • user (TUser) – The user whose lockout date should be set.
  • lockoutEnd (System.Nullable<System.DateTimeOffset>) – The System.DateTimeOffset after which the <em>user</em>’s lockout should end.
Return type:

System.Threading.Tasks.Task<Microsoft.AspNetCore.Identity.IdentityResult>

Returns:

The System.Threading.Tasks.Task that represents the asynchronous operation, containing the Microsoft.AspNetCore.Identity.IdentityResult of the operation.

public virtual Task<IdentityResult> SetLockoutEndDateAsync(TUser user, DateTimeOffset? lockoutEnd)
SetPhoneNumberAsync(TUser, System.String)

Sets the phone number for the specified <em>user</em>.

Arguments:
  • user (TUser) – The user whose phone number to set.
  • phoneNumber (System.String) – The phone number to set.
Return type:

System.Threading.Tasks.Task<Microsoft.AspNetCore.Identity.IdentityResult>

Returns:

The System.Threading.Tasks.Task that represents the asynchronous operation, containing the Microsoft.AspNetCore.Identity.IdentityResult of the operation.

public virtual Task<IdentityResult> SetPhoneNumberAsync(TUser user, string phoneNumber)
SetTwoFactorEnabledAsync(TUser, System.Boolean)

Sets a flag indicating whether the specified <em>user</em> has two factor authentication enabled or not, as an asynchronous operation.

Arguments:
  • user (TUser) – The user whose two factor authentication enabled status should be set.
  • enabled (System.Boolean) – A flag indicating whether the specified <em>user</em> has two factor authentication enabled.
Return type:

System.Threading.Tasks.Task<Microsoft.AspNetCore.Identity.IdentityResult>

Returns:

The System.Threading.Tasks.Task that represents the asynchronous operation, the Microsoft.AspNetCore.Identity.IdentityResult of the operation

public virtual Task<IdentityResult> SetTwoFactorEnabledAsync(TUser user, bool enabled)
SetUserNameAsync(TUser, System.String)

Sets the given <em>userName</em> for the specified <em>user</em>.

Arguments:
  • user (TUser) – The user whose name should be set.
  • userName (System.String) – The user name to set.
Return type:

System.Threading.Tasks.Task<Microsoft.AspNetCore.Identity.IdentityResult>

Returns:

The System.Threading.Tasks.Task that represents the asynchronous operation.

public virtual Task<IdentityResult> SetUserNameAsync(TUser user, string userName)
ThrowIfDisposed()
protected void ThrowIfDisposed()
UpdateAsync(TUser)

Updates the specified <em>user</em> in the backing store.

Arguments:user (TUser) – The user to update.
Return type:System.Threading.Tasks.Task<Microsoft.AspNetCore.Identity.IdentityResult>
Returns:The System.Threading.Tasks.Task that represents the asynchronous operation, containing the Microsoft.AspNetCore.Identity.IdentityResult of the operation.
public virtual Task<IdentityResult> UpdateAsync(TUser user)
UpdateNormalizedEmailAsync(TUser)

Updates the normalized email for the specified <em>user</em>.

Arguments:user (TUser) – The user whose email address should be normalized and updated.
Return type:System.Threading.Tasks.Task
Returns:The task object representing the asynchronous operation.
public virtual Task UpdateNormalizedEmailAsync(TUser user)
UpdateNormalizedUserNameAsync(TUser)

Updates the normalized user name for the specified <em>user</em>.

Arguments:user (TUser) – The user whose user name should be normalized and updated.
Return type:System.Threading.Tasks.Task
Returns:The System.Threading.Tasks.Task that represents the asynchronous operation.
public virtual Task UpdateNormalizedUserNameAsync(TUser user)
UpdateSecurityStampAsync(TUser)

Regenerates the security stamp for the specified <em>user</em>.

Arguments:user (TUser) – The user whose security stamp should be regenerated.
Return type:System.Threading.Tasks.Task<Microsoft.AspNetCore.Identity.IdentityResult>
Returns:The System.Threading.Tasks.Task that represents the asynchronous operation, containing the Microsoft.AspNetCore.Identity.IdentityResult of the operation.
public virtual Task<IdentityResult> UpdateSecurityStampAsync(TUser user)
VerifyChangePhoneNumberTokenAsync(TUser, System.String, System.String)

Returns a flag indicating whether the specified <em>user</em>’s phone number change verification token is valid for the given <em>phoneNumber</em>.

Arguments:
  • user (TUser) – The user to validate the token against.
  • token (System.String) – The telephone number change token to validate.
  • phoneNumber (System.String) – The telephone number the token was generated for.
Return type:

System.Threading.Tasks.Task<System.Boolean>

Returns:

The System.Threading.Tasks.Task that represents the asynchronous operation, returning true if the <em>token</em> is valid, otherwise false.

public virtual Task<bool> VerifyChangePhoneNumberTokenAsync(TUser user, string token, string phoneNumber)
VerifyPasswordAsync(Microsoft.AspNetCore.Identity.IUserPasswordStore<TUser>, TUser, System.String)

Returns a Microsoft.AspNetCore.Identity.PasswordVerificationResult indicating the result of a password hash comparison.

Arguments:
Return type:

System.Threading.Tasks.Task<Microsoft.AspNetCore.Identity.PasswordVerificationResult>

Returns:

The System.Threading.Tasks.Task that represents the asynchronous operation, containing the Microsoft.AspNetCore.Identity.PasswordVerificationResult of the operation.

protected virtual Task<PasswordVerificationResult> VerifyPasswordAsync(IUserPasswordStore<TUser> store, TUser user, string password)
VerifyTwoFactorTokenAsync(TUser, System.String, System.String)

Verifies the specified two factor authentication <em>token</em> against the <em>user</em>.

Arguments:
  • user (TUser) – The user the token is supposed to be for.
  • tokenProvider (System.String) – The provider which will verify the token.
  • token (System.String) – The token to verify.
Return type:

System.Threading.Tasks.Task<System.Boolean>

Returns:

The System.Threading.Tasks.Task that represents result of the asynchronous operation, true if the token is valid, otherwise false.

public virtual Task<bool> VerifyTwoFactorTokenAsync(TUser user, string tokenProvider, string token)
VerifyUserTokenAsync(TUser, System.String, System.String, System.String)

Returns a flag indicating whether the specified <em>token</em> is valid for the given <em>user</em> and <em>purpose</em>.

Arguments:
  • user (TUser) – The user to validate the token against.
  • tokenProvider (System.String) – The token provider used to generate the token.
  • purpose (System.String) – The purpose the token should be generated for.
  • token (System.String) – The token to validate
Return type:

System.Threading.Tasks.Task<System.Boolean>

Returns:

The System.Threading.Tasks.Task that represents the asynchronous operation, returning true if the <em>token</em> is valid, otherwise false.

public virtual Task<bool> VerifyUserTokenAsync(TUser user, string tokenProvider, string purpose, string token)

Fields

ConfirmEmailTokenPurpose()
Return type:System.String
protected const string ConfirmEmailTokenPurpose = "EmailConfirmation"
ResetPasswordTokenPurpose()
Return type:System.String
protected const string ResetPasswordTokenPurpose = "ResetPassword"

Properties

Microsoft.AspNetCore.Identity.UserManager<TUser>.Logger

Gets the Microsoft.Extensions.Logging.ILogger used to log messages from the manager.

Return type:Microsoft.Extensions.Logging.ILogger
Returns:The Microsoft.Extensions.Logging.ILogger used to log messages from the manager.
protected virtual ILogger Logger { get; set; }
Microsoft.AspNetCore.Identity.UserManager<TUser>.Store

Gets or sets the persistence store the manager operates over.

Return type:Microsoft.AspNetCore.Identity.IUserStore<TUser>
Returns:The persistence store the manager operates over.
protected IUserStore<TUser> Store { get; set; }
Microsoft.AspNetCore.Identity.UserManager<TUser>.SupportsQueryableUsers

Gets a flag indicating whether the backing user store supports returning System.Linq.IQueryable collections of information.

Return type:System.Boolean
Returns:true if the backing user store supports returning System.Linq.IQueryable collections of information, otherwise false.
public virtual bool SupportsQueryableUsers { get; }
Microsoft.AspNetCore.Identity.UserManager<TUser>.SupportsUserAuthenticationTokens

Gets a flag indicating whether the backing user store supports authentication tokens.

Return type:System.Boolean
Returns:true if the backing user store supports authentication tokens, otherwise false.
public virtual bool SupportsUserAuthenticationTokens { get; }
Microsoft.AspNetCore.Identity.UserManager<TUser>.SupportsUserClaim

Gets a flag indicating whether the backing user store supports user claims.

Return type:System.Boolean
Returns:true if the backing user store supports user claims, otherwise false.
public virtual bool SupportsUserClaim { get; }
Microsoft.AspNetCore.Identity.UserManager<TUser>.SupportsUserEmail

Gets a flag indicating whether the backing user store supports user emails.

Return type:System.Boolean
Returns:true if the backing user store supports user emails, otherwise false.
public virtual bool SupportsUserEmail { get; }
Microsoft.AspNetCore.Identity.UserManager<TUser>.SupportsUserLockout

Gets a flag indicating whether the backing user store supports user lock-outs.

Return type:System.Boolean
Returns:true if the backing user store supports user lock-outs, otherwise false.
public virtual bool SupportsUserLockout { get; }
Microsoft.AspNetCore.Identity.UserManager<TUser>.SupportsUserLogin

Gets a flag indicating whether the backing user store supports external logins.

Return type:System.Boolean
Returns:true if the backing user store supports external logins, otherwise false.
public virtual bool SupportsUserLogin { get; }
Microsoft.AspNetCore.Identity.UserManager<TUser>.SupportsUserPassword

Gets a flag indicating whether the backing user store supports user passwords.

Return type:System.Boolean
Returns:true if the backing user store supports user passwords, otherwise false.
public virtual bool SupportsUserPassword { get; }
Microsoft.AspNetCore.Identity.UserManager<TUser>.SupportsUserPhoneNumber

Gets a flag indicating whether the backing user store supports user telephone numbers.

Return type:System.Boolean
Returns:true if the backing user store supports user telephone numbers, otherwise false.
public virtual bool SupportsUserPhoneNumber { get; }
Microsoft.AspNetCore.Identity.UserManager<TUser>.SupportsUserRole

Gets a flag indicating whether the backing user store supports user roles.

Return type:System.Boolean
Returns:true if the backing user store supports user roles, otherwise false.
public virtual bool SupportsUserRole { get; }
Microsoft.AspNetCore.Identity.UserManager<TUser>.SupportsUserSecurityStamp

Gets a flag indicating whether the backing user store supports security stamps.

Return type:System.Boolean
Returns:true if the backing user store supports user security stamps, otherwise false.
public virtual bool SupportsUserSecurityStamp { get; }
Microsoft.AspNetCore.Identity.UserManager<TUser>.SupportsUserTwoFactor

Gets a flag indicating whether the backing user store supports two factor authentication.

Return type:System.Boolean
Returns:true if the backing user store supports user two factor authentication, otherwise false.
public virtual bool SupportsUserTwoFactor { get; }
Microsoft.AspNetCore.Identity.UserManager<TUser>.Users
Returns an IQueryable of users if the store is an IQueryableUserStore
Return type:System.Linq.IQueryable<TUser>
public virtual IQueryable<TUser> Users { get; }