UserManager<TUser> Class

Summary

Provides the APIs for managing user in a persistence store.

Syntax

public class UserManager<TUser> : IDisposable where TUser : class

GitHub

View on GitHub

class Microsoft.AspNet.Identity.UserManager<TUser>

Constructors

UserManager(Microsoft.AspNet.Identity.IUserStore<TUser>, IOptions<Microsoft.AspNet.Identity.IdentityOptions>, Microsoft.AspNet.Identity.IPasswordHasher, System.Collections.Generic.IEnumerable<Microsoft.AspNet.Identity.IUserValidator>, System.Collections.Generic.IEnumerable<Microsoft.AspNet.Identity.IPasswordValidator>, Microsoft.AspNet.Identity.ILookupNormalizer, Microsoft.AspNet.Identity.IdentityErrorDescriber, System.Collections.Generic.IEnumerable<Microsoft.AspNet.Identity.IUserTokenProvider>, ILogger<Microsoft.AspNet.Identity.UserManager<TUser>>, IHttpContextAccessor)

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

Arguments:
  • store (Microsoft.AspNet.Identity.IUserStore{{TUser}}) – The persistence store the manager will operate over.
  • optionsAccessor (IOptions{Microsoft.AspNet.Identity.IdentityOptions}) – The accessor used to access the Microsoft.AspNet.Identity.IdentityOptions.
  • passwordHasher (Microsoft.AspNet.Identity.IPasswordHasher) – The password hashing implementation to use when saving passwords.
  • userValidators (System.Collections.Generic.IEnumerable{Microsoft.AspNet.Identity.IUserValidator}) – A collection of IUserValidator&lt;TUser&gt; to validate users against.
  • passwordValidators (System.Collections.Generic.IEnumerable{Microsoft.AspNet.Identity.IPasswordValidator}) – A collection of IPasswordValidator&lt;TUser&gt; to validate passwords against.
  • keyNormalizer (Microsoft.AspNet.Identity.ILookupNormalizer) – The Microsoft.AspNet.Identity.ILookupNormalizer to use when generating index keys for users.
  • errors (Microsoft.AspNet.Identity.IdentityErrorDescriber) – The Microsoft.AspNet.Identity.IdentityErrorDescriber used to provider error messages.
  • logger (ILogger{Microsoft.AspNet.Identity.UserManager`1}) – The logger used to log messages, warnings and errors.
  • contextAccessor (IHttpContextAccessor) – The accessor used to access the HttpContext.
public UserManager(IUserStore<TUser> store, IOptions<IdentityOptions> optionsAccessor, IPasswordHasher passwordHasher, IEnumerable<IUserValidator> userValidators, IEnumerable<IPasswordValidator> passwordValidators, ILookupNormalizer keyNormalizer, IdentityErrorDescriber errors, IEnumerable<IUserTokenProvider> tokenProviders, ILogger<UserManager<TUser>> logger, IHttpContextAccessor contextAccessor)

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.AspNet.Identity.IdentityResult}

Returns:

The <see cref=”T:System.Threading.Tasks.Task” /> that represents the asynchronous operation, containing the <see cref=”T:Microsoft.AspNet.Identity.IdentityResult” /> of the operation.

public virtual Task<IdentityResult> AccessFailedAsync(TUser user)
AddClaimAsync(TUser, System.Security.Claims.Claim)

Adds the specified claim to the user, as an asynchronous operation.

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.AspNet.Identity.IdentityResult}

Returns:

The <see cref=”T:System.Threading.Tasks.Task” /> that represents the asynchronous operation, containing the <see cref=”T:Microsoft.AspNet.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 claims to the user, as an asynchronous operation.

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.AspNet.Identity.IdentityResult}

Returns:

The <see cref=”T:System.Threading.Tasks.Task” /> that represents the asynchronous operation, containing the <see cref=”T:Microsoft.AspNet.Identity.IdentityResult” /> of the operation.

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

Adds an external Microsoft.AspNet.Identity.UserLoginInfo to the specified user, as an asynchronous operation.

Arguments:
  • user ({TUser}) – The user to add the login to.
  • login (Microsoft.AspNet.Identity.UserLoginInfo) – The external Microsoft.AspNet.Identity.UserLoginInfo to add to the specified user.
Return type:

System.Threading.Tasks.Task{Microsoft.AspNet.Identity.IdentityResult}

Returns:

The <see cref=”T:System.Threading.Tasks.Task” /> that represents the asynchronous operation, containing the <see cref=”T:Microsoft.AspNet.Identity.IdentityResult” /> of the operation.

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

Adds the password to the specified user only if the user does not already have a password, as an asynchronous operation.

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

System.Threading.Tasks.Task{Microsoft.AspNet.Identity.IdentityResult}

Returns:

The <see cref=”T:System.Threading.Tasks.Task” /> that represents the asynchronous operation, containing the <see cref=”T:Microsoft.AspNet.Identity.IdentityResult” /> of the operation.

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

Add the specified user to the named role, as an asynchronous operation.

Arguments:
  • user ({TUser}) – The user to add to the named role.
Return type:

System.Threading.Tasks.Task{Microsoft.AspNet.Identity.IdentityResult}

Returns:

The <see cref=”T:System.Threading.Tasks.Task” /> that represents the asynchronous operation, containing the <see cref=”T:Microsoft.AspNet.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 user to the named roles, as an asynchronous operation.

Arguments:
  • user ({TUser}) – The user to add to the named roles.
Return type:

System.Threading.Tasks.Task{Microsoft.AspNet.Identity.IdentityResult}

Returns:

The <see cref=”T:System.Threading.Tasks.Task” /> that represents the asynchronous operation, containing the <see cref=”T:Microsoft.AspNet.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 token 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.AspNet.Identity.IdentityResult}

Returns:

The <see cref=”T:System.Threading.Tasks.Task” /> that represents the asynchronous operation, containing the <see cref=”T:Microsoft.AspNet.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 currentPassword 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 user.
Return type:

System.Threading.Tasks.Task{Microsoft.AspNet.Identity.IdentityResult}

Returns:

The <see cref=”T:System.Threading.Tasks.Task” /> that represents the asynchronous operation, containing the <see cref=”T:Microsoft.AspNet.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 user if the specified change token 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.AspNet.Identity.IdentityResult}

Returns:

The <see cref=”T:System.Threading.Tasks.Task” /> that represents the asynchronous operation, containing the <see cref=”T:Microsoft.AspNet.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 password is valid for the specified user, as an asynchronous operation.

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 <see cref=”T:System.Threading.Tasks.Task” /> that represents the asynchronous operation, containing true if the specified <paramref name=”password” /> matches the one store for the <paramref name=”user” />, otherwise false.

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

Validates that an email confirmation token matches the specified user, as an asynchronous operation.

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.AspNet.Identity.IdentityResult}

Returns:

The <see cref=”T:System.Threading.Tasks.Task” /> that represents the asynchronous operation, containing the <see cref=”T:Microsoft.AspNet.Identity.IdentityResult” /> of the operation.

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

Creates the specified user 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.AspNet.Identity.IdentityResult}

Returns:

The <see cref=”T:System.Threading.Tasks.Task” /> that represents the asynchronous operation, containing the <see cref=”T:Microsoft.AspNet.Identity.IdentityResult” /> of the operation.

public virtual Task<IdentityResult> CreateAsync(TUser user)
CreateAsync(TUser, System.String)

Creates the specified user 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.AspNet.Identity.IdentityResult}

Returns:

The <see cref=”T:System.Threading.Tasks.Task” /> that represents the asynchronous operation, containing the <see cref=”T:Microsoft.AspNet.Identity.IdentityResult” /> of the operation.

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

Deletes the specified user from the backing store, as an asynchronous operation.

Arguments:
  • user ({TUser}) – The user to delete.
Return type:

System.Threading.Tasks.Task{Microsoft.AspNet.Identity.IdentityResult}

Returns:

The <see cref=”T:System.Threading.Tasks.Task” /> that represents the asynchronous operation, containing the <see cref=”T:Microsoft.AspNet.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.

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 userId.

Arguments:
  • userId (System.String) – The user ID to search for.
Return type:

System.Threading.Tasks.Task{{TUser}}

Returns:

The <see cref=”T:System.Threading.Tasks.Task” /> that represents the asynchronous operation, containing the user matching the specified <paramref name=”userID” /> 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, as an asynchronous operation..

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

System.Threading.Tasks.Task{{TUser}}

Returns:

The <see cref=”T: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 normalized user name.

Return type:System.Threading.Tasks.Task{{TUser}}
Returns:The <see cref=”T:System.Threading.Tasks.Task” /> that represents the asynchronous operation, containing the user matching the specified <paramref name=”userID” /> if it exists.
public virtual Task<TUser> FindByNameAsync(string userName)
GenerateChangeEmailTokenAsync(TUser, System.String)

Generates an email change token for the specified user, as an asynchronous operation.

Arguments:
  • user ({TUser}) – The user to generate an email change token for.
Return type:

System.Threading.Tasks.Task{System.String}

Returns:

The <see cref=”T: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, as an asynchronous operation.

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 <see cref=”T: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, as an asynchronous operation.

Arguments:
  • user ({TUser}) – The user to generate the stamp for.
Return type:

System.Threading.Tasks.Task{System.String}

Returns:

The <see cref=”T:System.Threading.Tasks.Task” /> that represents the asynchronous operation, containing the security stamp for the specified <paramref name=”user” />.

public virtual Task<string> GenerateConcurrencyStampAsync(TUser user)
GenerateEmailConfirmationTokenAsync(TUser)

Generates an email confirmation token for the specified user, as an asynchronous operation.

Arguments:
  • user ({TUser}) – The user to generate an email confirmation token for.
Return type:

System.Threading.Tasks.Task{System.String}

Returns:

The <see cref=”T: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 user, using the configured password reset token provider, as an asynchronous operation.

Arguments:
  • user ({TUser}) – The user to generate a password reset token for.
Return type:

System.Threading.Tasks.Task{System.String}

Returns:

The <see cref=”T:System.Threading.Tasks.Task” /> that represents the asynchronous operation, containing a password reset token for the specified <paramref name=”user” />.

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

Gets a two factor authentication token for the specified user, as an asynchronous operation.

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 <see cref=”T: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 user and purpose, as an asynchronous operation.

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 <see cref=”T: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 user, as an asynchronous operation.

Arguments:
  • user ({TUser}) – The user whose access failed count should be retrieved for.
Return type:

System.Threading.Tasks.Task{System.Int32}

Returns:

The <see cref=”T: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)
GetClaimsAsync(TUser)

Gets a list of System.Security.Claims.Claim`s to be belonging to the specified ``user` as an asynchronous operation.

Arguments:
  • user ({TUser}) – The role whose claims to retrieve.
Return type:

System.Threading.Tasks.Task{System.Collections.Generic.IList{System.Security.Claims.Claim}}

Returns:

A <see cref=”T:System.Threading.Tasks.Task`1” /> that represents the result of the asynchronous query, a list of <see cref=”T:System.Security.Claims.Claim” />s.

public virtual Task<IList<Claim>> GetClaimsAsync(TUser user)
GetEmailAsync(TUser)

Gets the email address for the specified user, as an asynchronous operation.

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 <paramref name=”user” />.

public virtual Task<string> GetEmailAsync(TUser user)
GetLockoutEnabledAsync(TUser)

Retrieves a flag indicating whether user lockout can enabled for the specified user, as an asynchronous operation.

Arguments:
  • user ({TUser}) – The user whose ability to be locked out should be returned.
Return type:

System.Threading.Tasks.Task{System.Boolean}

Returns:

The <see cref=”T: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, as an asynchronous operation. 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 <see cref=”T:System.Threading.Tasks.Task`1” /> that represents the lookup, a <see cref=”T: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” />, as an asynchronous operation.

Arguments:
  • user ({TUser}) – The user whose associated logins to retrieve.
Return type:

System.Threading.Tasks.Task{System.Collections.Generic.IList{Microsoft.AspNet.Identity.UserLoginInfo}}

Returns:

The <see cref=”T:System.Threading.Tasks.Task” /> for the asynchronous operation, containing a list of <see cref=”T:Microsoft.AspNet.Identity.UserLoginInfo” /> for the specified <paramref name=”user” />, if any.

public virtual Task<IList<UserLoginInfo>> GetLoginsAsync(TUser user)
GetPhoneNumberAsync(TUser)

Gets the telephone number, if any, for the specified user, as an asynchronous operation.

Arguments:
  • user ({TUser}) – The user whose telephone number should be retrieved.
Return type:

System.Threading.Tasks.Task{System.String}

Returns:

The <see cref=”T: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 user belongs to, as an asynchronous operation.

Arguments:
  • user ({TUser}) – The user whose role names to retrieve.
Return type:

System.Threading.Tasks.Task{System.Collections.Generic.IList{System.String}}

Returns:

The <see cref=”T: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 user, as an asynchronous operation.

Arguments:
  • user ({TUser}) – The user whose security stamp should be set.
Return type:

System.Threading.Tasks.Task{System.String}

Returns:

The <see cref=”T:System.Threading.Tasks.Task” /> that represents the asynchronous operation, containing the security stamp for the specified <paramref name=”user” />.

public virtual Task<string> GetSecurityStampAsync(TUser user)
GetTwoFactorEnabledAsync(TUser)

Returns a flag indicating whether the specified user 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 <see cref=”T:System.Threading.Tasks.Task” /> that represents the asynchronous operation, true if the specified <paramref name=”user ” /> has two factor authentication enabled, otherwise false.

public virtual Task<bool> GetTwoFactorEnabledAsync(TUser user)
GetUserIdAsync(TUser)

Gets the user identifier for the specified user, as an asynchronous operation.

Arguments:
  • user ({TUser}) – The user whose identifier should be retrieved.
Return type:

System.Threading.Tasks.Task{System.String}

Returns:

The <see cref=”T:System.Threading.Tasks.Task” /> that represents the asynchronous operation, containing the identifier for the specified <paramref name=”user” />.

public virtual Task<string> GetUserIdAsync(TUser user)
GetUserNameAsync(TUser)

Gets the user name for the specified user, as an asynchronous operation.

Arguments:
  • user ({TUser}) – The user whose name should be retrieved.
Return type:

System.Threading.Tasks.Task{System.String}

Returns:

The <see cref=”T:System.Threading.Tasks.Task” /> that represents the asynchronous operation, containing the name for the specified <paramref name=”user” />.

public virtual Task<string> GetUserNameAsync(TUser user)
GetUsersForClaimAsync(System.Security.Claims.Claim)
Return type:System.Threading.Tasks.Task{System.Collections.Generic.IList{{TUser}}}
public virtual Task<IList<TUser>> GetUsersForClaimAsync(Claim claim)
GetUsersInRoleAsync(System.String)

Returns a list of users from the user store who have the specified System.Security.Claims.Claim.

Return type:System.Threading.Tasks.Task{System.Collections.Generic.IList{{TUser}}}
Returns:A <see cref=”T:System.Threading.Tasks.Task`1” /> that represents the result of the asynchronous query, a list of <typeparamref name=”TUser” />s who have the specified claim.
public virtual Task<IList<TUser>> GetUsersInRoleAsync(string roleName)
GetValidTwoFactorProvidersAsync(TUser)

Gets a list of valid two factor token providers for the specified user, 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 <see cref=”T: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 user has a password, as an asynchronous operation.

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 <see cref=”T:System.Threading.Tasks.Task” /> that represents the asynchronous operation, returning true if the specified <paramref name=”user” /> 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 user has been verified, true if the email address is verified otherwise false, as an asynchronous operation.

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 <paramref name=”user” /> has been confirmed or not.

public virtual Task<bool> IsEmailConfirmedAsync(TUser user)
IsInRoleAsync(TUser, System.String)

Returns a flag indicating whether the specified user is a member of the give named role, as an asynchronous operation.

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 <see cref=”T:System.Threading.Tasks.Task” /> that represents the asynchronous operation, containing a flag indicating whether the specified <see cref=”!:user” /> 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 user 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 <see cref=”T:System.Threading.Tasks.Task” /> that represents the asynchronous operation, true if the specified <paramref name=”user ” /> is locked out, otherwise false.

public virtual Task<bool> IsLockedOutAsync(TUser user)
IsPhoneNumberConfirmedAsync(TUser)

Gets a flag indicating whether the specified user‘s telephone number has been confirmed, as an asynchronous operation.

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 <see cref=”T:System.Threading.Tasks.Task” /> that represents the asynchronous operation, returning true if the specified <paramref name=”user” /> 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 <paramref name=”key” />.

public virtual string NormalizeKey(string key)
RegisterTokenProvider(Microsoft.AspNet.Identity.IUserTokenProvider)

Registers a token provider.

Arguments:
  • provider (Microsoft.AspNet.Identity.IUserTokenProvider) – The provider to register.
public virtual void RegisterTokenProvider(IUserTokenProvider provider)
RemoveClaimAsync(TUser, System.Security.Claims.Claim)

Removes the specified claim from the given user.

Arguments:
  • user ({TUser}) – The user to remove the specified claims from.
  • claim (System.Security.Claims.Claim) – The System.Security.Claims.Claim to remove.
Return type:

System.Threading.Tasks.Task{Microsoft.AspNet.Identity.IdentityResult}

Returns:

The <see cref=”T:System.Threading.Tasks.Task” /> that represents the asynchronous operation, containing the <see cref=”T:Microsoft.AspNet.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 claims from the given user.

Arguments:
  • user ({TUser}) – The user to remove the specified claims from.
  • claims (System.Collections.Generic.IEnumerable{System.Security.Claims.Claim}) – A collection of :dn:ref:`System.Security.Claims.Claim`s to remove.
Return type:

System.Threading.Tasks.Task{Microsoft.AspNet.Identity.IdentityResult}

Returns:

The <see cref=”T:System.Threading.Tasks.Task” /> that represents the asynchronous operation, containing the <see cref=”T:Microsoft.AspNet.Identity.IdentityResult” /> of the operation.

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

Removes the specified user from the named role, as an asynchronous operation.

Arguments:
  • user ({TUser}) – The user to remove from the named role.
Return type:

System.Threading.Tasks.Task{Microsoft.AspNet.Identity.IdentityResult}

Returns:

The <see cref=”T:System.Threading.Tasks.Task” /> that represents the asynchronous operation, containing the <see cref=”T:Microsoft.AspNet.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 user from the named roles, as an asynchronous operation.

Arguments:
  • user ({TUser}) – The user to remove from the named roles.
Return type:

System.Threading.Tasks.Task{Microsoft.AspNet.Identity.IdentityResult}

Returns:

The <see cref=”T:System.Threading.Tasks.Task” /> that represents the asynchronous operation, containing the <see cref=”T:Microsoft.AspNet.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 user, as an asynchronous operation. 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.AspNet.Identity.IdentityResult}

Returns:

The <see cref=”T:System.Threading.Tasks.Task” /> that represents the asynchronous operation, containing the <see cref=”T:Microsoft.AspNet.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, as an asynchronous operation.

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

System.Threading.Tasks.Task{Microsoft.AspNet.Identity.IdentityResult}

Returns:

The <see cref=”T:System.Threading.Tasks.Task” /> that represents the asynchronous operation, containing the <see cref=”T:Microsoft.AspNet.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 claim on the specified user with the newClaim

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 claim with.
Return type:

System.Threading.Tasks.Task{Microsoft.AspNet.Identity.IdentityResult}

Returns:

The <see cref=”T:System.Threading.Tasks.Task” /> that represents the asynchronous operation, containing the <see cref=”T:Microsoft.AspNet.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 user, as an asynchronous operation.

Arguments:
  • user ({TUser}) – The user whose failed access count should be reset.
Return type:

System.Threading.Tasks.Task{Microsoft.AspNet.Identity.IdentityResult}

Returns:

The <see cref=”T:System.Threading.Tasks.Task” /> that represents the asynchronous operation, containing the <see cref=”T:Microsoft.AspNet.Identity.IdentityResult” /> of the operation.

public virtual Task<IdentityResult> ResetAccessFailedCountAsync(TUser user)
ResetPasswordAsync(TUser, System.String, System.String)

Resets the user‘s password to the specified newPassword after validating the given password reset token, as an asynchronous operation.

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.AspNet.Identity.IdentityResult}

Returns:

The <see cref=”T:System.Threading.Tasks.Task” /> that represents the asynchronous operation, containing the <see cref=”T:Microsoft.AspNet.Identity.IdentityResult” /> of the operation.

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

Sets the email address for a user, as an asynchronous operation.

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

System.Threading.Tasks.Task{Microsoft.AspNet.Identity.IdentityResult}

Returns:

The <see cref=”T:System.Threading.Tasks.Task” /> that represents the asynchronous operation, containing the <see cref=”T:Microsoft.AspNet.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 user 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.AspNet.Identity.IdentityResult}

Returns:

The <see cref=”T:System.Threading.Tasks.Task” /> that represents the asynchronous operation, the <see cref=”T:Microsoft.AspNet.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, as an asynchronous operation. 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 user‘s lockout should end.
Return type:

System.Threading.Tasks.Task{Microsoft.AspNet.Identity.IdentityResult}

Returns:

The <see cref=”T:System.Threading.Tasks.Task” /> that represents the asynchronous operation, containing the <see cref=”T:Microsoft.AspNet.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 user.

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.AspNet.Identity.IdentityResult}

Returns:

The <see cref=”T:System.Threading.Tasks.Task” /> that represents the asynchronous operation, containing the <see cref=”T:Microsoft.AspNet.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 user 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.
Return type:

System.Threading.Tasks.Task{Microsoft.AspNet.Identity.IdentityResult}

Returns:

The <see cref=”T:System.Threading.Tasks.Task” /> that represents the asynchronous operation, the <see cref=”T:Microsoft.AspNet.Identity.IdentityResult” /> of the operation

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

Sets the given userName for the specified user, as an asynchronous operation.

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.AspNet.Identity.IdentityResult}

Returns:

The <see cref=”T:System.Threading.Tasks.Task” /> that represents the asynchronous operation.

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

Updates the specified user in the backing store, as an asynchronous operation.

Arguments:
  • user ({TUser}) – The user to update.
Return type:

System.Threading.Tasks.Task{Microsoft.AspNet.Identity.IdentityResult}

Returns:

The <see cref=”T:System.Threading.Tasks.Task” /> that represents the asynchronous operation, containing the <see cref=”T:Microsoft.AspNet.Identity.IdentityResult” /> of the operation.

public virtual Task<IdentityResult> UpdateAsync(TUser user)
UpdateNormalizedEmailAsync(TUser)

Updates the normalized email for the specified user.

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 user, as an asynchronous operation.

Arguments:
  • user ({TUser}) – The user whose user name should be normalized and updated.
Return type:

System.Threading.Tasks.Task

Returns:

The <see cref=”T:System.Threading.Tasks.Task” /> that represents the asynchronous operation.

public virtual Task UpdateNormalizedUserNameAsync(TUser user)
UpdateSecurityStampAsync(TUser)

Regenerates the security stamp for the specified user, as an asynchronous operation.

Arguments:
  • user ({TUser}) – The user whose security stamp should be regenerated.
Return type:

System.Threading.Tasks.Task{Microsoft.AspNet.Identity.IdentityResult}

Returns:

The <see cref=”T:System.Threading.Tasks.Task” /> that represents the asynchronous operation, containing the <see cref=”T:Microsoft.AspNet.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 user‘s phone number change verification token is valid for the given phoneNumber, as an asynchronous operation.

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 <see cref=”T:System.Threading.Tasks.Task” /> that represents the asynchronous operation, returning true if the <paramref name=”token” /> is valid, otherwise false.

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

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

Arguments:
  • store (Microsoft.AspNet.Identity.IUserPasswordStore{{TUser}}) – The store containing a user’s password.
  • user ({TUser}) – The user whose password should be verified.
  • password (System.String) – The password to verify.
Return type:

System.Threading.Tasks.Task{Microsoft.AspNet.Identity.PasswordVerificationResult}

Returns:

The <see cref=”T:System.Threading.Tasks.Task” /> that represents the asynchronous operation, containing the <see cref=”T:Microsoft.AspNet.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 token against the user, as an asynchronous operation.

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 <see cref=”T: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 token is valid for the given user and purpose, as an asynchronous operation.

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 <see cref=”T:System.Threading.Tasks.Task” /> that represents the asynchronous operation, returning true if the <paramref name=”token” /> is valid, otherwise false.

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

Properties

Logger()

Gets the ILogger used to log messages from the manager.

Return type:ILogger
protected virtual ILogger Logger { get; set; }
Store()

Gets or sets the persistence store the manager operates over.

Return type:Microsoft.AspNet.Identity.IUserStore{{TUser}}
protected IUserStore<TUser> Store { get; set; }
SupportsQueryableUsers()

Gets a flag indicating whether the backing user store supports returning

System.Linq.IQueryable collections of information.

Return type:System.Boolean
public virtual bool SupportsQueryableUsers { get; }
SupportsUserClaim()

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

Return type:System.Boolean
public virtual bool SupportsUserClaim { get; }
SupportsUserEmail()

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

Return type:System.Boolean
public virtual bool SupportsUserEmail { get; }
SupportsUserLockout()

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

Return type:System.Boolean
public virtual bool SupportsUserLockout { get; }
SupportsUserLogin()

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

Return type:System.Boolean
public virtual bool SupportsUserLogin { get; }
SupportsUserPassword()

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

Return type:System.Boolean
public virtual bool SupportsUserPassword { get; }
SupportsUserPhoneNumber()

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

Return type:System.Boolean
public virtual bool SupportsUserPhoneNumber { get; }
SupportsUserRole()

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

Return type:System.Boolean
public virtual bool SupportsUserRole { get; }
SupportsUserSecurityStamp()

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

Return type:System.Boolean
public virtual bool SupportsUserSecurityStamp { get; }
SupportsUserTwoFactor()

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

Return type:System.Boolean
public virtual bool SupportsUserTwoFactor { get; }
Users()

Returns an IQueryable of users if the store is an IQueryableUserStore

Return type:System.Linq.IQueryable{{TUser}}
public virtual IQueryable<TUser> Users { get; }