UserManager<TUser, TKey> Class

 

Exposes user related APIs which will automatically save changes to the UserStore.

Namespace:   Microsoft.AspNet.Identity
Assembly:  Microsoft.AspNet.Identity.Core (in Microsoft.AspNet.Identity.Core.dll)

Inheritance Hierarchy

System.Object
  Microsoft.AspNet.Identity.UserManager<TUser, TKey>
    Microsoft.AspNet.Identity.UserManager<TUser>

Syntax

public class UserManager<TUser, TKey> : IDisposable
where TUser : class, IUser<TKey>
where TKey : object, IEquatable<TKey>
generic<typename TUser, typename TKey>
where TUser : ref class, IUser<TKey>
where TKey : Object, IEquatable<TKey>
public ref class UserManager : IDisposable
type UserManager<'TUser, 'TKey when 'TUser : not struct and IUser<'TKey> when 'TKey : Object and IEquatable<'TKey>> = 
    class
        interface IDisposable
    end
Public Class UserManager(Of TUser As { Class, IUser(Of TKey) }, TKey As { Object, IEquatable(Of TKey) })
    Implements IDisposable

Type Parameters

  • TUser
    The entity type of the user.
  • TKey
    The entity key of the user.

Constructors

Name Description
System_CAPS_pubmethod UserManager<TUser, TKey>(IUserStore<TUser, TKey>)

Initializes a new instance of the UserManager<TUser, TKey> class.

Properties

Name Description
System_CAPS_pubproperty ClaimsIdentityFactory

Gets or sets the factory used to create claims identities from users.

System_CAPS_pubproperty DefaultAccountLockoutTimeSpan

Gets or sets the default amount of time that a user is locked out for after MaxFailedAccessAttemptsBeforeLockout is reached.

System_CAPS_pubproperty EmailService

Gets or sets the service used to send e-mail.

System_CAPS_pubproperty MaxFailedAccessAttemptsBeforeLockout

Gets or sets the maximum number of access attempts allowed before a user is locked out (if lockout is enabled).

System_CAPS_pubproperty PasswordHasher

Gets or sets the property used to hash/verify passwords.

System_CAPS_pubproperty PasswordValidator

Gets or sets the property used to validate passwords before persisting changes.

System_CAPS_pubproperty SmsService

Gets or sets the property used to send a SMS message.

System_CAPS_protproperty Store

Gets or sets the persistence abstraction that the UserManager operates against.

System_CAPS_pubproperty SupportsQueryableUsers

Gets a value that indicates whether the store is an IQueryableUserStore.

System_CAPS_pubproperty SupportsUserClaim

Gets a value that indicates whether the store is an IUserClaimStore.

System_CAPS_pubproperty SupportsUserEmail

Gets a value that indicates whether the store is an IUserEmailStore.

System_CAPS_pubproperty SupportsUserLockout

Gets a value that indicates whether the store is an IUserLockoutStore.

System_CAPS_pubproperty SupportsUserLogin

Gets a value that indicates whether the store is an IUserLoginStore.

System_CAPS_pubproperty SupportsUserPassword

Gets a value that indicates whether the store is an IUserPasswordStore.

System_CAPS_pubproperty SupportsUserPhoneNumber

Gets a value that indicates whether the store is an IUserPhoneNumberStore.

System_CAPS_pubproperty SupportsUserRole

Gets a value that indicates whether the store is an IUserRoleStore.

System_CAPS_pubproperty SupportsUserSecurityStamp

Gets a value that indicates whether the store is an IUserSecurityStore.

System_CAPS_pubproperty SupportsUserTwoFactor

Gets a value that indicates whether the store is an IUserTwoFactorStore.

System_CAPS_pubproperty TwoFactorProviders

Gets the registered two-factor authentication providers for users by their ID.

System_CAPS_pubproperty UserLockoutEnabledByDefault

Gets or sets a value that indicates whether the user lockout is enabled when users are created.

System_CAPS_pubproperty Users

Gets an IQueryable of users if the store is an IQueryableUserStore.

System_CAPS_pubproperty UserTokenProvider

Gets or sets a property used for generating reset password and confirmation tokens.

System_CAPS_pubproperty UserValidator

Gets or sets a property used to validate users before changes are saved.

Methods

Name Description
System_CAPS_pubmethod AccessFailedAsync(TKey)

Increments the access failed count for the user and if the failed access account is greater than or equal to the MaxFailedAccessAttempsBeforeLockout, the user will be locked out for the next DefaultAccountLockoutTimeSpan and the AccessFailedCount will be reset to 0. This is used for locking out the user account.

System_CAPS_pubmethod AddClaimAsync(TKey, Claim)

Adds a user claim.

System_CAPS_pubmethod AddLoginAsync(TKey, UserLoginInfo)

Associates a login with a user.

System_CAPS_pubmethod AddPasswordAsync(TKey, String)

Adds a user password only if one does not already exist.

System_CAPS_pubmethod AddToRoleAsync(TKey, String)

Adds a user to a role.

System_CAPS_pubmethod AddToRolesAsync(TKey, String[])

Method to add user to multiple roles

System_CAPS_pubmethod ChangePasswordAsync(TKey, String, String)

Changes a user password.

System_CAPS_pubmethod ChangePhoneNumberAsync(TKey, String, String)

Sets a user phone number with the verification token.

System_CAPS_pubmethod CheckPasswordAsync(TUser, String)

Determines whether the password is valid for the user.

System_CAPS_pubmethod ConfirmEmailAsync(TKey, String)

Confirms the user e-mail with confirmation token.

System_CAPS_pubmethod CreateAsync(TUser)

Creates a user with no password.

System_CAPS_pubmethod CreateAsync(TUser, String)

Creates a user with the given password.

System_CAPS_pubmethod CreateIdentityAsync(TUser, String)

Creates a ClaimsIdentity representing the user.

System_CAPS_pubmethod DeleteAsync(TUser)

Deletes a user.

System_CAPS_pubmethod Dispose()

Releases the resources used by the current instance of the UserManager<TUser, TKey> class.

System_CAPS_protmethod Dispose(Boolean)

Releases the resources used by the current instance of the UserManager<TUser, TKey> class.

System_CAPS_pubmethod Equals(Object)

(Inherited from Object.)

System_CAPS_protmethod Finalize()

(Inherited from Object.)

System_CAPS_pubmethod FindAsync(String, String)

Returns a user with the specified username and password or null if there is no match.

System_CAPS_pubmethod FindAsync(UserLoginInfo)

Returns the user associated with this login.

System_CAPS_pubmethod FindByEmailAsync(String)

Finds a user by his e-mail.

System_CAPS_pubmethod FindByIdAsync(TKey)

Finds a user by ID.

System_CAPS_pubmethod FindByNameAsync(String)

Finds a user by user name.

System_CAPS_pubmethod GenerateChangePhoneNumberTokenAsync(TKey, String)

Generates a code that the user can use to change their phone number to a specific number.

System_CAPS_pubmethod GenerateEmailConfirmationTokenAsync(TKey)

Gets the e-mail confirmation token for the user.

System_CAPS_pubmethod GeneratePasswordResetTokenAsync(TKey)

Generates a password reset token for the user using the UserTokenProvider.

System_CAPS_pubmethod GenerateTwoFactorTokenAsync(TKey, String)

Gets a token for a specific two factor provider.

System_CAPS_pubmethod GenerateUserTokenAsync(String, TKey)

Gets a user token for a specific purpose.

System_CAPS_pubmethod GetAccessFailedCountAsync(TKey)

Returns the number of failed access attempts for the user.

System_CAPS_pubmethod GetClaimsAsync(TKey)

Gets a user claims.

System_CAPS_pubmethod GetEmailAsync(TKey)

Gets a user e-mail.

System_CAPS_pubmethod GetHashCode()

(Inherited from Object.)

System_CAPS_pubmethod GetLockoutEnabledAsync(TKey)

Determines whether the lockout is enabled for the user.

System_CAPS_pubmethod GetLockoutEndDateAsync(TKey)

Returns when the user is no longer locked out, dates in the past are considered as not being locked out.

System_CAPS_pubmethod GetLoginsAsync(TKey)

Gets the logins for a user.

System_CAPS_pubmethod GetPhoneNumberAsync(TKey)

Gets a user phone number.

System_CAPS_pubmethod GetRolesAsync(TKey)

Returns the roles for the user.

System_CAPS_pubmethod GetSecurityStampAsync(TKey)

Returns the current security stamp for a user.

System_CAPS_pubmethod GetTwoFactorEnabledAsync(TKey)

Determines whether two factor authentication is enabled for a user.

System_CAPS_pubmethod GetType()

(Inherited from Object.)

System_CAPS_pubmethod GetValidTwoFactorProvidersAsync(TKey)

Returns a list of valid two factor providers for a user.

System_CAPS_pubmethod HasPasswordAsync(TKey)

Determines whether the user has a password.

System_CAPS_pubmethod IsEmailConfirmedAsync(TKey)

Determines whether the user e-mail has been confirmed.

System_CAPS_pubmethod IsInRoleAsync(TKey, String)

Determines whether the user is in the specified role.

System_CAPS_pubmethod IsLockedOutAsync(TKey)

Determines whether the user is locked out.

System_CAPS_pubmethod IsPhoneNumberConfirmedAsync(TKey)

Determines whether the user phone number has been confirmed.

System_CAPS_protmethod MemberwiseClone()

(Inherited from Object.)

System_CAPS_pubmethod NotifyTwoFactorTokenAsync(TKey, String, String)

Notifies a user with a token using a specific method of two-factor authentication provider.

System_CAPS_pubmethod RegisterTwoFactorProvider(String, IUserTokenProvider<TUser, TKey>)

Registers a two factor authentication provider with the TwoFactorProviders mapping.

System_CAPS_pubmethod RemoveClaimAsync(TKey, Claim)

Removes a user claim.

System_CAPS_pubmethod RemoveFromRoleAsync(TKey, String)

Removes a user from a role.

System_CAPS_pubmethod RemoveFromRolesAsync(TKey, String[])

Remove user from multiple roles

System_CAPS_pubmethod RemoveLoginAsync(TKey, UserLoginInfo)

Removes a user login.

System_CAPS_pubmethod RemovePasswordAsync(TKey)

Removes a user password.

System_CAPS_pubmethod ResetAccessFailedCountAsync(TKey)

Resets the access failed count for the user to 0.

System_CAPS_pubmethod ResetPasswordAsync(TKey, String, String)

Resets a user password using a reset password token.

System_CAPS_pubmethod SendEmailAsync(TKey, String, String)

Sends an e-mail to the user.

System_CAPS_pubmethod SendSmsAsync(TKey, String)

Sends the user a SMS message.

System_CAPS_pubmethod SetEmailAsync(TKey, String)

Sets a user e-mail.

System_CAPS_pubmethod SetLockoutEnabledAsync(TKey, Boolean)

Sets whether lockout is enabled for this user.

System_CAPS_pubmethod SetLockoutEndDateAsync(TKey, DateTimeOffset)

Sets the time when a user lockout ends.

System_CAPS_pubmethod SetPhoneNumberAsync(TKey, String)

Sets a user phone number.

System_CAPS_pubmethod SetTwoFactorEnabledAsync(TKey, Boolean)

Sets the two factor authentication enabled property for the user.

System_CAPS_pubmethod ToString()

(Inherited from Object.)

System_CAPS_pubmethod UpdateAsync(TUser)

Updates a user.

System_CAPS_protmethod UpdatePassword(IUserPasswordStore<TUser, TKey>, TUser, String)

System_CAPS_pubmethod UpdateSecurityStampAsync(TKey)

Generates a new security stamp for a user, used for SignOutEverywhere functionality.

System_CAPS_pubmethod VerifyChangePhoneNumberTokenAsync(TKey, String, String)

Verifies whether the code is valid for a specific user and for a specific phone number.

System_CAPS_protmethod VerifyPasswordAsync(IUserPasswordStore<TUser, TKey>, TUser, String)

Retrieves the hashed password from the user store and calls PasswordHasher.VerifyHashPassword.

System_CAPS_pubmethod VerifyTwoFactorTokenAsync(TKey, String, String)

Verifies a two factor token with the specified provider.

System_CAPS_pubmethod VerifyUserTokenAsync(TKey, String, String)

Verifies a user token with the specified purpose.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Microsoft.AspNet.Identity Namespace
ASP.NET Identity

Return to top