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 SourceAddRole(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. |
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. |
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. |
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. |
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. |
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 |
Returns
| Type | Description |
|---|---|
| bool |
|
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. |
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. |
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. |
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. |
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. |
GetAllRoles()
Gets all roles as IMemberGroup objects.
Declaration
IEnumerable<IMemberGroup> GetAllRoles()
Returns
| Type | Description |
|---|---|
| IEnumerable<IMemberGroup> | An enumerable collection of all IMemberGroup objects. |
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. |
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. |
GetAllRolesIds()
Gets the integer ids of all roles.
Declaration
IEnumerable<int> GetAllRolesIds()
Returns
| Type | Description |
|---|---|
| IEnumerable<int> | An enumerable collection of all role ids. |
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. |
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. |
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. |
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. |
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. |