Search Results for

    Show / Hide Table of Contents
    View Source

    Interface IMembershipRoleService<T>

    Defines the MembershipRoleService, which provides role management operations for membership users.

    Namespace: Umbraco.Cms.Core.Services
    Assembly: Umbraco.Core.dll
    Syntax
    public interface IMembershipRoleService<out T> where T : class, IMembershipUser
    Type Parameters
    Name Description
    T

    The type of membership user, must implement IMembershipUser.

    Methods

    View Source

    AddRole(string)

    Adds a new role with the specified name.

    Declaration
    void AddRole(string roleName)
    Parameters
    Type Name Description
    string roleName

    The name of the role to add.

    View Source

    AssignRole(int, string)

    Assigns a single role to a member by their integer id.

    Declaration
    void AssignRole(int memberId, string roleName)
    Parameters
    Type Name Description
    int memberId

    The integer id of the member.

    string roleName

    The name of the role to assign.

    View Source

    AssignRole(string, string)

    Assigns a single role to a member by username.

    Declaration
    void AssignRole(string username, string roleName)
    Parameters
    Type Name Description
    string username

    The username of the member.

    string roleName

    The name of the role to assign.

    View Source

    AssignRoles(int[], string[])

    Assigns multiple roles to multiple members by their integer ids.

    Declaration
    void AssignRoles(int[] memberIds, string[] roleNames)
    Parameters
    Type Name Description
    int[] memberIds

    An array of member ids to assign roles to.

    string[] roleNames

    An array of role names to assign.

    View Source

    AssignRoles(string[], string[])

    Assigns multiple roles to multiple members by their usernames.

    Declaration
    void AssignRoles(string[] usernames, string[] roleNames)
    Parameters
    Type Name Description
    string[] usernames

    An array of usernames to assign roles to.

    string[] roleNames

    An array of role names to assign.

    View Source

    DeleteRole(string, bool)

    Deletes a role by its name.

    Declaration
    bool DeleteRole(string roleName, bool throwIfBeingUsed)
    Parameters
    Type Name Description
    string roleName

    The name of the role to delete.

    bool throwIfBeingUsed

    If true, throws an exception if the role is currently assigned to any members.

    Returns
    Type Description
    bool

    true if the role was successfully deleted; otherwise, false.

    View Source

    DissociateRole(int, string)

    Removes a single role from a member by their integer id.

    Declaration
    void DissociateRole(int memberId, string roleName)
    Parameters
    Type Name Description
    int memberId

    The integer id of the member.

    string roleName

    The name of the role to remove.

    View Source

    DissociateRole(string, string)

    Removes a single role from a member by username.

    Declaration
    void DissociateRole(string username, string roleName)
    Parameters
    Type Name Description
    string username

    The username of the member.

    string roleName

    The name of the role to remove.

    View Source

    DissociateRoles(int[], string[])

    Removes multiple roles from multiple members by their integer ids.

    Declaration
    void DissociateRoles(int[] memberIds, string[] roleNames)
    Parameters
    Type Name Description
    int[] memberIds

    An array of member ids to remove roles from.

    string[] roleNames

    An array of role names to remove.

    View Source

    DissociateRoles(string[], string[])

    Removes multiple roles from multiple members by their usernames.

    Declaration
    void DissociateRoles(string[] usernames, string[] roleNames)
    Parameters
    Type Name Description
    string[] usernames

    An array of usernames to remove roles from.

    string[] roleNames

    An array of role names to remove.

    View Source

    FindMembersInRole(string, string, StringPropertyMatchType)

    Finds members in a role whose username matches the specified pattern.

    Declaration
    IEnumerable<out T> FindMembersInRole(string roleName, string usernameToMatch, StringPropertyMatchType matchType = StringPropertyMatchType.StartsWith)
    Parameters
    Type Name Description
    string roleName

    The name of the role to search within.

    string usernameToMatch

    The username pattern to match.

    StringPropertyMatchType matchType

    The type of string matching to use. Default is StartsWith.

    Returns
    Type Description
    IEnumerable<T>

    An enumerable collection of members matching the criteria.

    View Source

    GetAllRoles()

    Gets all roles as IMemberGroup objects.

    Declaration
    IEnumerable<IMemberGroup> GetAllRoles()
    Returns
    Type Description
    IEnumerable<IMemberGroup>

    An enumerable collection of all IMemberGroup objects.

    View Source

    GetAllRoles(int)

    Gets all role names for a member by their integer id.

    Declaration
    IEnumerable<string> GetAllRoles(int memberId)
    Parameters
    Type Name Description
    int memberId

    The integer id of the member.

    Returns
    Type Description
    IEnumerable<string>

    An enumerable collection of role names assigned to the member.

    View Source

    GetAllRoles(string)

    Gets all role names for a member by their username.

    Declaration
    IEnumerable<string> GetAllRoles(string username)
    Parameters
    Type Name Description
    string username

    The username of the member.

    Returns
    Type Description
    IEnumerable<string>

    An enumerable collection of role names assigned to the member.

    View Source

    GetAllRolesIds()

    Gets the integer ids of all roles.

    Declaration
    IEnumerable<int> GetAllRolesIds()
    Returns
    Type Description
    IEnumerable<int>

    An enumerable collection of all role ids.

    View Source

    GetAllRolesIds(int)

    Gets the integer ids of all roles for a member by their integer id.

    Declaration
    IEnumerable<int> GetAllRolesIds(int memberId)
    Parameters
    Type Name Description
    int memberId

    The integer id of the member.

    Returns
    Type Description
    IEnumerable<int>

    An enumerable collection of role ids assigned to the member.

    View Source

    GetAllRolesIds(string)

    Gets the integer ids of all roles for a member by their username.

    Declaration
    IEnumerable<int> GetAllRolesIds(string username)
    Parameters
    Type Name Description
    string username

    The username of the member.

    Returns
    Type Description
    IEnumerable<int>

    An enumerable collection of role ids assigned to the member.

    View Source

    GetMembersInRole(string)

    Gets all members that belong to a specific role.

    Declaration
    IEnumerable<out T> GetMembersInRole(string roleName)
    Parameters
    Type Name Description
    string roleName

    The name of the role.

    Returns
    Type Description
    IEnumerable<T>

    An enumerable collection of members in the specified role.

    View Source

    ReplaceRoles(int[], string[])

    Replaces all existing roles for the specified members with the given roles, identified by member ids.

    Declaration
    void ReplaceRoles(int[] memberIds, string[] roleNames)
    Parameters
    Type Name Description
    int[] memberIds

    An array of member ids whose roles will be replaced.

    string[] roleNames

    An array of role names to assign as the new roles.

    View Source

    ReplaceRoles(string[], string[])

    Replaces all existing roles for the specified members with the given roles, identified by usernames.

    Declaration
    void ReplaceRoles(string[] usernames, string[] roleNames)
    Parameters
    Type Name Description
    string[] usernames

    An array of usernames whose roles will be replaced.

    string[] roleNames

    An array of role names to assign as the new roles.

    • View Source
    In this article
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX