Table of Contents

Class UserStore<TKey, TUser, TRole, TUserClaim, TUserRole, TUserLogin, TUserToken>

Namespace
LinqToDB.Identity
Assembly
LinqToDB.Identity.dll

Represents a new instance of a persistence store for the specified user and role types.

public class UserStore<TKey, TUser, TRole, TUserClaim, TUserRole, TUserLogin, TUserToken> : IUserLoginStore<TUser>, IUserRoleStore<TUser>, IUserClaimStore<TUser>, IUserPasswordStore<TUser>, IUserSecurityStampStore<TUser>, IUserEmailStore<TUser>, IUserLockoutStore<TUser>, IUserPhoneNumberStore<TUser>, IQueryableUserStore<TUser>, IUserTwoFactorStore<TUser>, IUserAuthenticationTokenStore<TUser>, IUserStore<TUser>, IDisposable where TKey : IEquatable<TKey> where TUser : class, IIdentityUser<TKey> where TRole : class, IIdentityRole<TKey> where TUserClaim : class, IIdentityUserClaim<TKey>, new() where TUserRole : class, IIdentityUserRole<TKey>, new() where TUserLogin : class, IIdentityUserLogin<TKey>, new() where TUserToken : class, IIdentityUserToken<TKey>, new()

Type Parameters

TKey

The type of the primary key for a role.

TUser

The type representing a user.

TRole

The type representing a role.

TUserClaim

The type representing a claim.

TUserRole

The type representing a user role.

TUserLogin

The type representing a user external login.

TUserToken

The type representing a user token.

Inheritance
UserStore<TKey, TUser, TRole, TUserClaim, TUserRole, TUserLogin, TUserToken>
Implements
IUserStore<TUser>
Derived

Constructors

UserStore(IConnectionFactory, IdentityErrorDescriber)

public UserStore(IConnectionFactory factory, IdentityErrorDescriber describer = null)

Parameters

factory IConnectionFactory

IConnectionFactory

describer IdentityErrorDescriber

The IdentityErrorDescriber used to describe store errors.

Properties

ErrorDescriber

Gets or sets the IdentityErrorDescriber for any error that occurred with the current operation.

public IdentityErrorDescriber ErrorDescriber { get; set; }

Property Value

IdentityErrorDescriber

Users

A navigation property for the users the store contains.

public virtual IQueryable<TUser> Users { get; }

Property Value

IQueryable<TUser>

Methods

AddClaimsAsync(DataConnection, IEnumerable<TUserClaim>, CancellationToken)

Adds the claims given to the specified user.

protected virtual Task AddClaimsAsync(DataConnection dc, IEnumerable<TUserClaim> data, CancellationToken cancellationToken)

Parameters

dc DataConnection
data IEnumerable<TUserClaim>
cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The Task that represents the asynchronous operation.

AddClaimsAsync(TUser, IEnumerable<Claim>, CancellationToken)

Adds the claims given to the specified user.

public Task AddClaimsAsync(TUser user, IEnumerable<Claim> claims, CancellationToken cancellationToken = default)

Parameters

user TUser

The user to add the claim to.

claims IEnumerable<Claim>

The claim to add to the user.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The Task that represents the asynchronous operation.

AddLoginAsync(DataConnection, TUser, UserLoginInfo, CancellationToken)

Adds the login given to the specified user.

protected virtual Task AddLoginAsync(DataConnection db, TUser user, UserLoginInfo login, CancellationToken cancellationToken)

Parameters

db DataConnection
user TUser

The user to add the login to.

login UserLoginInfo

The login to add to the user.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The Task that represents the asynchronous operation.

AddLoginAsync(TUser, UserLoginInfo, CancellationToken)

Adds the login given to the specified user.

public Task AddLoginAsync(TUser user, UserLoginInfo login, CancellationToken cancellationToken = default)

Parameters

user TUser

The user to add the login to.

login UserLoginInfo

The login to add to the user.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The Task that represents the asynchronous operation.

AddToRoleAsync(DataConnection, TUser, string, CancellationToken)

Adds the given normalizedRoleName to the specified user.

protected virtual Task AddToRoleAsync(DataConnection db, TUser user, string normalizedRoleName, CancellationToken cancellationToken)

Parameters

db DataConnection
user TUser

The user to add the role to.

normalizedRoleName string

The role to add.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The Task that represents the asynchronous operation.

AddToRoleAsync(TUser, string, CancellationToken)

Adds the given normalizedRoleName to the specified user.

public Task AddToRoleAsync(TUser user, string normalizedRoleName, CancellationToken cancellationToken = default)

Parameters

user TUser

The user to add the role to.

normalizedRoleName string

The role to add.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The Task that represents the asynchronous operation.

ConvertIdFromString(string)

Converts the provided id to a strongly typed key object.

public virtual TKey ConvertIdFromString(string id)

Parameters

id string

The id to convert.

Returns

TKey

An instance of TKey representing the provided id.

ConvertIdToString(TKey)

Converts the provided id to its string representation.

public virtual string ConvertIdToString(TKey id)

Parameters

id TKey

The id to convert.

Returns

string

An string representation of the provided id.

CreateAsync(DataConnection, TUser, CancellationToken)

Creates the specified user in the user store.

protected virtual Task<IdentityResult> CreateAsync(DataConnection db, TUser user, CancellationToken cancellationToken)

Parameters

db DataConnection
user TUser

The user to create.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<IdentityResult>

The Task that represents the asynchronous operation, containing the IdentityResult of the creation operation.

CreateAsync(TUser, CancellationToken)

Creates the specified user in the user store.

public Task<IdentityResult> CreateAsync(TUser user, CancellationToken cancellationToken = default)

Parameters

user TUser

The user to create.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<IdentityResult>

The Task that represents the asynchronous operation, containing the IdentityResult of the creation operation.

CreateUserClaim(TUser, Claim)

Create a new entity representing a user claim.

protected virtual TUserClaim CreateUserClaim(TUser user, Claim claim)

Parameters

user TUser
claim Claim

Returns

TUserClaim

CreateUserLogin(TUser, UserLoginInfo)

Create a new entity representing a user login.

protected virtual TUserLogin CreateUserLogin(TUser user, UserLoginInfo login)

Parameters

user TUser
login UserLoginInfo

Returns

TUserLogin

CreateUserRole(TUser, TRole)

Creates a new entity to represent a user role.

protected virtual TUserRole CreateUserRole(TUser user, TRole role)

Parameters

user TUser
role TRole

Returns

TUserRole

CreateUserToken(TUser, string, string, string)

Create a new entity representing a user token.

protected virtual TUserToken CreateUserToken(TUser user, string loginProvider, string name, string value)

Parameters

user TUser
loginProvider string
name string
value string

Returns

TUserToken

DeleteAsync(DataConnection, TUser, CancellationToken)

Deletes the specified user from the user store.

protected virtual Task<IdentityResult> DeleteAsync(DataConnection db, TUser user, CancellationToken cancellationToken)

Parameters

db DataConnection
user TUser

The user to delete.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<IdentityResult>

The Task that represents the asynchronous operation, containing the IdentityResult of the update operation.

DeleteAsync(TUser, CancellationToken)

Deletes the specified user from the user store.

public Task<IdentityResult> DeleteAsync(TUser user, CancellationToken cancellationToken = default)

Parameters

user TUser

The user to delete.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<IdentityResult>

The Task that represents the asynchronous operation, containing the IdentityResult of the update operation.

Dispose()

Dispose the store

public void Dispose()

FindByEmailAsync(DataConnection, string, CancellationToken)

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

protected virtual Task<TUser> FindByEmailAsync(DataConnection db, string normalizedEmail, CancellationToken cancellationToken)

Parameters

db DataConnection
normalizedEmail string

The normalized email address to return the user for.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<TUser>

The task object containing the results of the asynchronous lookup operation, the user if any associated with the specified normalized email address.

FindByEmailAsync(string, CancellationToken)

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

public Task<TUser> FindByEmailAsync(string normalizedEmail, CancellationToken cancellationToken = default)

Parameters

normalizedEmail string

The normalized email address to return the user for.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<TUser>

The task object containing the results of the asynchronous lookup operation, the user if any associated with the specified normalized email address.

FindByIdAsync(DataConnection, TKey, CancellationToken)

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

protected virtual Task<TUser> FindByIdAsync(DataConnection db, TKey id, CancellationToken cancellationToken)

Parameters

db DataConnection
id TKey
cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<TUser>

The Task that represents the asynchronous operation, containing the user matching the specified userId if it exists.

FindByIdAsync(string, CancellationToken)

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

public Task<TUser> FindByIdAsync(string userId, CancellationToken cancellationToken = default)

Parameters

userId string

The user ID to search for.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<TUser>

The Task that represents the asynchronous operation, containing the user matching the specified userId if it exists.

FindByLoginAsync(DataConnection, string, string, CancellationToken)

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

protected virtual Task<TUser> FindByLoginAsync(DataConnection db, string loginProvider, string providerKey, CancellationToken cancellationToken)

Parameters

db DataConnection
loginProvider string

The login provider who provided the providerKey.

providerKey string

The key provided by the loginProvider to identify a user.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<TUser>

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

FindByLoginAsync(string, string, CancellationToken)

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

public Task<TUser> FindByLoginAsync(string loginProvider, string providerKey, CancellationToken cancellationToken = default)

Parameters

loginProvider string

The login provider who provided the providerKey.

providerKey string

The key provided by the loginProvider to identify a user.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<TUser>

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

FindByNameAsync(DataConnection, string, CancellationToken)

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

protected virtual Task<TUser> FindByNameAsync(DataConnection db, string normalizedUserName, CancellationToken cancellationToken)

Parameters

db DataConnection
normalizedUserName string

The normalized user name to search for.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<TUser>

The Task that represents the asynchronous operation, containing the user matching the specified normalizedUserName if it exists.

FindByNameAsync(string, CancellationToken)

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

public Task<TUser> FindByNameAsync(string normalizedUserName, CancellationToken cancellationToken = default)

Parameters

normalizedUserName string

The normalized user name to search for.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<TUser>

The Task that represents the asynchronous operation, containing the user matching the specified normalizedUserName if it exists.

GetAccessFailedCountAsync(TUser, CancellationToken)

Retrieves the current failed access count for the specified user..

public virtual Task<int> GetAccessFailedCountAsync(TUser user, CancellationToken cancellationToken = default)

Parameters

user TUser

The user whose failed access count should be retrieved.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<int>

The Task that represents the asynchronous operation, containing the failed access count.

GetAuthenticatorKeyAsync(TUser, CancellationToken)

Get the authenticator key for the specified user.

public virtual Task<string> GetAuthenticatorKeyAsync(TUser user, CancellationToken cancellationToken)

Parameters

user TUser

The user whose security stamp should be set.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<string>

The Task that represents the asynchronous operation, containing the security stamp for the specified user.

GetClaimsAsync(DataConnection, TUser, CancellationToken)

Get the claims associated with the specified user as an asynchronous operation.

protected virtual Task<IList<Claim>> GetClaimsAsync(DataConnection db, TUser user, CancellationToken cancellationToken)

Parameters

db DataConnection
user TUser

The user whose claims should be retrieved.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<IList<Claim>>

A Task<TResult> that contains the claims granted to a user.

GetClaimsAsync(TUser, CancellationToken)

Get the claims associated with the specified user as an asynchronous operation.

public Task<IList<Claim>> GetClaimsAsync(TUser user, CancellationToken cancellationToken = default)

Parameters

user TUser

The user whose claims should be retrieved.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<IList<Claim>>

A Task<TResult> that contains the claims granted to a user.

GetConnection()

protected DataConnection GetConnection()

Returns

DataConnection

DataConnection

GetContext()

Gets IDataContext from supplied IConnectionFactory

protected IDataContext GetContext()

Returns

IDataContext

IDataContext

GetEmailAsync(TUser, CancellationToken)

Gets the email address for the specified user.

public virtual Task<string> GetEmailAsync(TUser user, CancellationToken cancellationToken = default)

Parameters

user TUser

The user whose email should be returned.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<string>

The task object containing the results of the asynchronous operation, the email address for the specified user.

GetEmailConfirmedAsync(TUser, CancellationToken)

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

public virtual Task<bool> GetEmailConfirmedAsync(TUser user, CancellationToken cancellationToken = default)

Parameters

user TUser

The user whose email confirmation status should be returned.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<bool>

The task object containing the results of the asynchronous operation, a flag indicating whether the email address for the specified user has been confirmed or not.

GetLockoutEnabledAsync(TUser, CancellationToken)

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

public virtual Task<bool> GetLockoutEnabledAsync(TUser user, CancellationToken cancellationToken = default)

Parameters

user TUser

The user whose ability to be locked out should be returned.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<bool>

The Task that represents the asynchronous operation, true if a user can be locked out, otherwise false.

GetLockoutEndDateAsync(TUser, CancellationToken)

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

public virtual Task<DateTimeOffset?> GetLockoutEndDateAsync(TUser user, CancellationToken cancellationToken = default)

Parameters

user TUser

The user whose lockout date should be retrieved.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<DateTimeOffset?>

A Task<TResult> that represents the result of the asynchronous query, a DateTimeOffset containing the last time a user's lockout expired, if any.

GetLoginsAsync(DataConnection, TUser, CancellationToken)

Retrieves the associated logins for the specified

.
protected virtual Task<IList<UserLoginInfo>> GetLoginsAsync(DataConnection db, TUser user, CancellationToken cancellationToken)

Parameters

db DataConnection
user TUser

The user whose associated logins to retrieve.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<IList<UserLoginInfo>>

The Task for the asynchronous operation, containing a list of UserLoginInfo for the specified user, if any.

GetLoginsAsync(TUser, CancellationToken)

Retrieves the associated logins for the specified

.
public Task<IList<UserLoginInfo>> GetLoginsAsync(TUser user, CancellationToken cancellationToken = default)

Parameters

user TUser

The user whose associated logins to retrieve.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<IList<UserLoginInfo>>

The Task for the asynchronous operation, containing a list of UserLoginInfo for the specified user, if any.

GetNormalizedEmailAsync(TUser, CancellationToken)

Returns the normalized email for the specified user.

public virtual Task<string> GetNormalizedEmailAsync(TUser user, CancellationToken cancellationToken = default)

Parameters

user TUser

The user whose email address to retrieve.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<string>

The task object containing the results of the asynchronous lookup operation, the normalized email address if any associated with the specified user.

GetNormalizedUserNameAsync(TUser, CancellationToken)

Gets the normalized user name for the specified user.

public virtual Task<string> GetNormalizedUserNameAsync(TUser user, CancellationToken cancellationToken = default)

Parameters

user TUser

The user whose normalized name should be retrieved.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<string>

The Task that represents the asynchronous operation, containing the normalized user name for the specified user.

GetPasswordHashAsync(TUser, CancellationToken)

Gets the password hash for a user.

public virtual Task<string> GetPasswordHashAsync(TUser user, CancellationToken cancellationToken = default)

Parameters

user TUser

The user to retrieve the password hash for.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<string>

A Task<TResult> that contains the password hash for the user.

GetPhoneNumberAsync(TUser, CancellationToken)

Gets the telephone number, if any, for the specified user.

public virtual Task<string> GetPhoneNumberAsync(TUser user, CancellationToken cancellationToken = default)

Parameters

user TUser

The user whose telephone number should be retrieved.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<string>

The Task that represents the asynchronous operation, containing the user's telephone number, if any.

GetPhoneNumberConfirmedAsync(TUser, CancellationToken)

Gets a flag indicating whether the specified user's telephone number has been confirmed.

public virtual Task<bool> GetPhoneNumberConfirmedAsync(TUser user, CancellationToken cancellationToken = default)

Parameters

user TUser

The user to return a flag for, indicating whether their telephone number is confirmed.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<bool>

The Task that represents the asynchronous operation, returning true if the specified user has a confirmed telephone number otherwise false.

GetRolesAsync(DataConnection, TUser, CancellationToken)

Retrieves the roles the specified user is a member of.

protected virtual Task<IList<string>> GetRolesAsync(DataConnection db, TUser user, CancellationToken cancellationToken)

Parameters

db DataConnection
user TUser

The user whose roles should be retrieved.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<IList<string>>

A Task<TResult> that contains the roles the user is a member of.

GetRolesAsync(TUser, CancellationToken)

Retrieves the roles the specified user is a member of.

public Task<IList<string>> GetRolesAsync(TUser user, CancellationToken cancellationToken = default)

Parameters

user TUser

The user whose roles should be retrieved.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<IList<string>>

A Task<TResult> that contains the roles the user is a member of.

GetSecurityStampAsync(TUser, CancellationToken)

Get the security stamp for the specified user.

public virtual Task<string> GetSecurityStampAsync(TUser user, CancellationToken cancellationToken = default)

Parameters

user TUser

The user whose security stamp should be set.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<string>

The Task that represents the asynchronous operation, containing the security stamp for the specified user.

GetTokenAsync(DataConnection, TUser, string, string, CancellationToken)

Returns the token value.

protected virtual Task<string> GetTokenAsync(DataConnection db, TUser user, string loginProvider, string name, CancellationToken cancellationToken)

Parameters

db DataConnection
user TUser

The user.

loginProvider string

The authentication provider for the token.

name string

The name of the token.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<string>

The Task that represents the asynchronous operation.

GetTokenAsync(TUser, string, string, CancellationToken)

Returns the token value.

public Task<string> GetTokenAsync(TUser user, string loginProvider, string name, CancellationToken cancellationToken)

Parameters

user TUser

The user.

loginProvider string

The authentication provider for the token.

name string

The name of the token.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<string>

The Task that represents the asynchronous operation.

GetTwoFactorEnabledAsync(TUser, CancellationToken)

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

public virtual Task<bool> GetTwoFactorEnabledAsync(TUser user, CancellationToken cancellationToken = default)

Parameters

user TUser

The user whose two factor authentication enabled status should be set.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<bool>

The Task that represents the asynchronous operation, containing a flag indicating whether the specified user has two factor authentication enabled or not.

GetUserIdAsync(TUser, CancellationToken)

Gets the user identifier for the specified user.

public virtual Task<string> GetUserIdAsync(TUser user, CancellationToken cancellationToken = default)

Parameters

user TUser

The user whose identifier should be retrieved.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<string>

The Task that represents the asynchronous operation, containing the identifier for the specified user.

GetUserNameAsync(TUser, CancellationToken)

Gets the user name for the specified user.

public virtual Task<string> GetUserNameAsync(TUser user, CancellationToken cancellationToken = default)

Parameters

user TUser

The user whose name should be retrieved.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<string>

The Task that represents the asynchronous operation, containing the name for the specified user.

GetUsersForClaimAsync(Claim, CancellationToken)

Retrieves all users with the specified claim.

public Task<IList<TUser>> GetUsersForClaimAsync(Claim claim, CancellationToken cancellationToken = default)

Parameters

claim Claim

The claim whose users should be retrieved.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<IList<TUser>>

The Task contains a list of users, if any, that contain the specified claim.

GetUsersInRoleAsync(DataConnection, string, CancellationToken)

Retrieves all users in the specified role.

protected virtual Task<IList<TUser>> GetUsersInRoleAsync(DataConnection db, string normalizedRoleName, CancellationToken cancellationToken)

Parameters

db DataConnection
normalizedRoleName string

The role whose users should be retrieved.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<IList<TUser>>

The Task contains a list of users, if any, that are in the specified role.

GetUsersInRoleAsync(string, CancellationToken)

Retrieves all users in the specified role.

public Task<IList<TUser>> GetUsersInRoleAsync(string normalizedRoleName, CancellationToken cancellationToken = default)

Parameters

normalizedRoleName string

The role whose users should be retrieved.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<IList<TUser>>

The Task contains a list of users, if any, that are in the specified role.

HasPasswordAsync(TUser, CancellationToken)

Returns a flag indicating if the specified user has a password.

public virtual Task<bool> HasPasswordAsync(TUser user, CancellationToken cancellationToken = default)

Parameters

user TUser

The user to retrieve the password hash for.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<bool>

A Task<TResult> containing a flag indicating if the specified user has a password. If the user has a password the returned value with be true, otherwise it will be false.

IncrementAccessFailedCountAsync(TUser, CancellationToken)

Records that a failed access has occurred, incrementing the failed access count.

public virtual Task<int> IncrementAccessFailedCountAsync(TUser user, CancellationToken cancellationToken = default)

Parameters

user TUser

The user whose cancellation count should be incremented.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<int>

The Task that represents the asynchronous operation, containing the incremented failed access count.

IsInRoleAsync(DataConnection, TUser, string, CancellationToken)

Returns a flag indicating if the specified user is a member of the give normalizedRoleName.

protected virtual Task<bool> IsInRoleAsync(DataConnection db, TUser user, string normalizedRoleName, CancellationToken cancellationToken)

Parameters

db DataConnection
user TUser

The user whose role membership should be checked.

normalizedRoleName string

The role to check membership of

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<bool>

A Task<TResult> containing a flag indicating if the specified user is a member of the given group. If the user is a member of the group the returned value with be true, otherwise it will be false.

IsInRoleAsync(TUser, string, CancellationToken)

Returns a flag indicating if the specified user is a member of the give normalizedRoleName.

public Task<bool> IsInRoleAsync(TUser user, string normalizedRoleName, CancellationToken cancellationToken = default)

Parameters

user TUser

The user whose role membership should be checked.

normalizedRoleName string

The role to check membership of

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<bool>

A Task<TResult> containing a flag indicating if the specified user is a member of the given group. If the user is a member of the group the returned value with be true, otherwise it will be false.

RemoveClaimsAsync(DataConnection, TUser, IEnumerable<Claim>, CancellationToken)

Removes the claims given from the specified user.

protected virtual Task RemoveClaimsAsync(DataConnection db, TUser user, IEnumerable<Claim> claims, CancellationToken cancellationToken)

Parameters

db DataConnection
user TUser

The user to remove the claims from.

claims IEnumerable<Claim>

The claim to remove.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The Task that represents the asynchronous operation.

RemoveClaimsAsync(TUser, IEnumerable<Claim>, CancellationToken)

Removes the claims given from the specified user.

public Task RemoveClaimsAsync(TUser user, IEnumerable<Claim> claims, CancellationToken cancellationToken = default)

Parameters

user TUser

The user to remove the claims from.

claims IEnumerable<Claim>

The claim to remove.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The Task that represents the asynchronous operation.

RemoveFromRoleAsync(DataConnection, TUser, string, CancellationToken)

Removes the given normalizedRoleName from the specified user.

protected virtual Task RemoveFromRoleAsync(DataConnection db, TUser user, string normalizedRoleName, CancellationToken cancellationToken)

Parameters

db DataConnection
user TUser

The user to remove the role from.

normalizedRoleName string

The role to remove.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The Task that represents the asynchronous operation.

RemoveFromRoleAsync(TUser, string, CancellationToken)

Removes the given normalizedRoleName from the specified user.

public Task RemoveFromRoleAsync(TUser user, string normalizedRoleName, CancellationToken cancellationToken = default)

Parameters

user TUser

The user to remove the role from.

normalizedRoleName string

The role to remove.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The Task that represents the asynchronous operation.

RemoveLoginAsync(DataConnection, TUser, string, string, CancellationToken)

Removes the loginProvider given from the specified user.

protected virtual Task RemoveLoginAsync(DataConnection db, TUser user, string loginProvider, string providerKey, CancellationToken cancellationToken)

Parameters

db DataConnection
user TUser

The user to remove the login from.

loginProvider string

The login to remove from the user.

providerKey string

The key provided by the loginProvider to identify a user.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The Task that represents the asynchronous operation.

RemoveLoginAsync(TUser, string, string, CancellationToken)

Removes the loginProvider given from the specified user.

public Task RemoveLoginAsync(TUser user, string loginProvider, string providerKey, CancellationToken cancellationToken = default)

Parameters

user TUser

The user to remove the login from.

loginProvider string

The login to remove from the user.

providerKey string

The key provided by the loginProvider to identify a user.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The Task that represents the asynchronous operation.

RemoveTokenAsync(DataConnection, TUser, string, string, CancellationToken)

Deletes a token for a user.

protected virtual Task RemoveTokenAsync(DataConnection db, TUser user, string loginProvider, string name, CancellationToken cancellationToken)

Parameters

db DataConnection
user TUser

The user.

loginProvider string

The authentication provider for the token.

name string

The name of the token.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The Task that represents the asynchronous operation.

RemoveTokenAsync(TUser, string, string, CancellationToken)

Deletes a token for a user.

public Task RemoveTokenAsync(TUser user, string loginProvider, string name, CancellationToken cancellationToken)

Parameters

user TUser

The user.

loginProvider string

The authentication provider for the token.

name string

The name of the token.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The Task that represents the asynchronous operation.

ReplaceClaimAsync(TUser, Claim, Claim, CancellationToken)

Replaces the claim on the specified user, with the newClaim.

public Task ReplaceClaimAsync(TUser user, Claim claim, Claim newClaim, CancellationToken cancellationToken = default)

Parameters

user TUser

The role to replace the claim on.

claim Claim

The claim replace.

newClaim Claim

The new claim replacing the claim.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The Task that represents the asynchronous operation.

ReplaceClaimAsync(TUser, Claim, Claim, CancellationToken, DataConnection)

Replaces the claim on the specified user, with the newClaim.

protected virtual Task ReplaceClaimAsync(TUser user, Claim claim, Claim newClaim, CancellationToken cancellationToken, DataConnection db)

Parameters

user TUser

The role to replace the claim on.

claim Claim

The claim replace.

newClaim Claim

The new claim replacing the claim.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

db DataConnection

Returns

Task

The Task that represents the asynchronous operation.

ResetAccessFailedCountAsync(TUser, CancellationToken)

Resets a user's failed access count.

public virtual Task ResetAccessFailedCountAsync(TUser user, CancellationToken cancellationToken = default)

Parameters

user TUser

The user whose failed access count should be reset.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The Task that represents the asynchronous operation.

Remarks

This is typically called after the account is successfully accessed.

SetAuthenticatorKeyAsync(TUser, string, CancellationToken)

Sets the authenticator key for the specified user.

public virtual Task SetAuthenticatorKeyAsync(TUser user, string key, CancellationToken cancellationToken)

Parameters

user TUser

The user whose authenticator key should be set.

key string

The authenticator key to set.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The Task that represents the asynchronous operation.

SetEmailAsync(TUser, string, CancellationToken)

Sets the email address for a user.

public virtual Task SetEmailAsync(TUser user, string email, CancellationToken cancellationToken = default)

Parameters

user TUser

The user whose email should be set.

email string

The email to set.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The task object representing the asynchronous operation.

SetEmailConfirmedAsync(TUser, bool, CancellationToken)

Sets the flag indicating whether the specified user's email address has been confirmed or not.

public virtual Task SetEmailConfirmedAsync(TUser user, bool confirmed, CancellationToken cancellationToken = default)

Parameters

user TUser

The user whose email confirmation status should be set.

confirmed bool

A flag indicating if the email address has been confirmed, true if the address is confirmed otherwise false.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The task object representing the asynchronous operation.

SetLockoutEnabledAsync(TUser, bool, CancellationToken)

Set the flag indicating if the specified user can be locked out..

public virtual Task SetLockoutEnabledAsync(TUser user, bool enabled, CancellationToken cancellationToken = default)

Parameters

user TUser

The user whose ability to be locked out should be set.

enabled bool

A flag indicating if lock out can be enabled for the specified user.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The Task that represents the asynchronous operation.

SetLockoutEndDateAsync(TUser, DateTimeOffset?, CancellationToken)

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

public virtual Task SetLockoutEndDateAsync(TUser user, DateTimeOffset? lockoutEnd, CancellationToken cancellationToken = default)

Parameters

user TUser

The user whose lockout date should be set.

lockoutEnd DateTimeOffset?

The DateTimeOffset after which the user's lockout should end.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The Task that represents the asynchronous operation.

SetNormalizedEmailAsync(TUser, string, CancellationToken)

Sets the normalized email for the specified user.

public virtual Task SetNormalizedEmailAsync(TUser user, string normalizedEmail, CancellationToken cancellationToken = default)

Parameters

user TUser

The user whose email address to set.

normalizedEmail string

The normalized email to set for the specified user.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The task object representing the asynchronous operation.

SetNormalizedUserNameAsync(TUser, string, CancellationToken)

Sets the given normalized name for the specified user.

public virtual Task SetNormalizedUserNameAsync(TUser user, string normalizedName, CancellationToken cancellationToken = default)

Parameters

user TUser

The user whose name should be set.

normalizedName string

The normalized name to set.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The Task that represents the asynchronous operation.

SetPasswordHashAsync(TUser, string, CancellationToken)

Sets the password hash for a user.

public virtual Task SetPasswordHashAsync(TUser user, string passwordHash, CancellationToken cancellationToken = default)

Parameters

user TUser

The user to set the password hash for.

passwordHash string

The password hash to set.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The Task that represents the asynchronous operation.

SetPhoneNumberAsync(TUser, string, CancellationToken)

Sets the telephone number for the specified user.

public virtual Task SetPhoneNumberAsync(TUser user, string phoneNumber, CancellationToken cancellationToken = default)

Parameters

user TUser

The user whose telephone number should be set.

phoneNumber string

The telephone number to set.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The Task that represents the asynchronous operation.

SetPhoneNumberConfirmedAsync(TUser, bool, CancellationToken)

Sets a flag indicating if the specified user's phone number has been confirmed..

public virtual Task SetPhoneNumberConfirmedAsync(TUser user, bool confirmed, CancellationToken cancellationToken = default)

Parameters

user TUser

The user whose telephone number confirmation status should be set.

confirmed bool

A flag indicating whether the user's telephone number has been confirmed.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The Task that represents the asynchronous operation.

SetSecurityStampAsync(TUser, string, CancellationToken)

Sets the provided security stamp for the specified user.

public virtual Task SetSecurityStampAsync(TUser user, string stamp, CancellationToken cancellationToken = default)

Parameters

user TUser

The user whose security stamp should be set.

stamp string

The security stamp to set.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The Task that represents the asynchronous operation.

SetTokenAsync(DataConnection, TUser, string, string, string, CancellationToken)

Sets the token value for a particular user.

protected virtual Task SetTokenAsync(DataConnection db, TUser user, string loginProvider, string name, string value, CancellationToken cancellationToken)

Parameters

db DataConnection
user TUser

The user.

loginProvider string

The authentication provider for the token.

name string

The name of the token.

value string

The value of the token.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The Task that represents the asynchronous operation.

SetTokenAsync(TUser, string, string, string, CancellationToken)

Sets the token value for a particular user.

public Task SetTokenAsync(TUser user, string loginProvider, string name, string value, CancellationToken cancellationToken)

Parameters

user TUser

The user.

loginProvider string

The authentication provider for the token.

name string

The name of the token.

value string

The value of the token.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The Task that represents the asynchronous operation.

SetTwoFactorEnabledAsync(TUser, bool, CancellationToken)

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

public virtual Task SetTwoFactorEnabledAsync(TUser user, bool enabled, CancellationToken cancellationToken = default)

Parameters

user TUser

The user whose two factor authentication enabled status should be set.

enabled bool

A flag indicating whether the specified user has two factor authentication enabled.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The Task that represents the asynchronous operation.

SetUserNameAsync(TUser, string, CancellationToken)

Sets the given userName for the specified user.

public virtual Task SetUserNameAsync(TUser user, string userName, CancellationToken cancellationToken = default)

Parameters

user TUser

The user whose name should be set.

userName string

The user name to set.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The Task that represents the asynchronous operation.

ThrowIfDisposed()

Throws if this class has been disposed.

protected void ThrowIfDisposed()

UpdateAsync(DataConnection, TUser, CancellationToken)

Updates the specified user in the user store.

protected virtual Task<IdentityResult> UpdateAsync(DataConnection db, TUser user, CancellationToken cancellationToken)

Parameters

db DataConnection
user TUser

The user to update.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<IdentityResult>

The Task that represents the asynchronous operation, containing the IdentityResult of the update operation.

UpdateAsync(TUser, CancellationToken)

Updates the specified user in the user store.

public Task<IdentityResult> UpdateAsync(TUser user, CancellationToken cancellationToken = default)

Parameters

user TUser

The user to update.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<IdentityResult>

The Task that represents the asynchronous operation, containing the IdentityResult of the update operation.

UsersForClaimAsync(DataConnection, Claim, CancellationToken)

Retrieves all users with the specified claim.

protected virtual Task<IList<TUser>> UsersForClaimAsync(DataConnection db, Claim claim, CancellationToken cancellationToken)

Parameters

db DataConnection
claim Claim

The claim whose users should be retrieved.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<IList<TUser>>

The Task contains a list of users, if any, that contain the specified claim.