Class VirtualRoleHelper
Unsupported INTERNAL API! Not covered by semantic versioning; might change without notice. Helps manage roles, virtual roles and the repository
Inheritance
Inherited Members
Namespace: EPiServer.Security.Internal
Assembly: EPiServer.Cms.AspNet.dll
Version: 11.20.7Syntax
public class VirtualRoleHelper
Constructors
VirtualRoleHelper(IVirtualRoleRepository, RoleProvider)
Unsupported INTERNAL API! Not covered by semantic versioning; might change without notice. Initializes a new instance of the VirtualRoleHelper class.
Declaration
public VirtualRoleHelper(IVirtualRoleRepository virtualRoleRepository, RoleProvider roleProvider)
Parameters
Type | Name | Description |
---|---|---|
IVirtualRoleRepository | virtualRoleRepository | |
System.Web.Security.RoleProvider | roleProvider |
Methods
GetAllRoles()
Unsupported INTERNAL API! Not covered by semantic versioning; might change without notice. Gets all virtual roles and all roles defined by the Role provider.
Declaration
public IEnumerable<string> GetAllRoles()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.String> | A string array with all role names. |
Remarks
If you want to get a list of all roles, both from the Roles provider and virtual roles, use this method since it will filter out any duplicates caused by overloading role names from virtual roles. I e if you have a virtual role named "Administrators" and Roles.GetAllRoles() contains an entry named "Administrators" the final array returned by this method will only contain a single reference to the "Administrators" name.
GetAllRolesForUser(String)
Unsupported INTERNAL API! Not covered by semantic versioning; might change without notice. Gets all available roles for a user.
Declaration
public IEnumerable<string> GetAllRolesForUser(string username)
Parameters
Type | Name | Description |
---|---|---|
System.String | username | The username. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.String> | An enumberable of strings with the names of all available roles for the user, regardless if she is a member of the role or not. |
GetAllVirtualRoles()
Unsupported INTERNAL API! Not covered by semantic versioning; might change without notice. Get a list of all virtual roles.
Declaration
public IEnumerable<string> GetAllVirtualRoles()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.String> | A string array with the virtual role names. |
GetRoleNameForClass(Type)
Unsupported INTERNAL API! Not covered by semantic versioning; might change without notice. Gets the virtual role name for the specified class (if many exists you may receive any of them)
Declaration
public string GetRoleNameForClass(Type classType)
Parameters
Type | Name | Description |
---|---|---|
System.Type | classType | Type of the class. |
Returns
Type | Description |
---|---|
System.String | The role name. |
IsPrincipalInVirtualRole(IPrincipal, String, Object)
Unsupported INTERNAL API! Not covered by semantic versioning; might change without notice. Determines whether the specified principal is in the virtual role
Declaration
public bool IsPrincipalInVirtualRole(IPrincipal principal, string virtualRole, object context)
Parameters
Type | Name | Description |
---|---|---|
System.Security.Principal.IPrincipal | principal | The principal. |
System.String | virtualRole | The role. |
System.Object | context | The context of the request |
Returns
Type | Description |
---|---|
System.Boolean |
|
SearchRoles(String)
Unsupported INTERNAL API! Not covered by semantic versioning; might change without notice. Find virtual roles and roles defined by the Role provider.
Declaration
public IEnumerable<string> SearchRoles(string query)
Parameters
Type | Name | Description |
---|---|---|
System.String | query | Query to find roles in. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.String> | A list of roles that match the roleName |
Remarks
Matching of role names is simply a substring check - if the role contains the string passed in roleName anywhere in the string, it is considered a match. A Null or empty roleName will return all roles.
If you want to get a list of roles from the Roles provider and virtual roles, use this method since it will filter out any duplicates caused by overloading role names from virtual roles. I e if you have a virtual role named "Administrators" and Roles.GetAllRoles() contains an entry named "Administrators" the final enumerator returned by this method will only contain a single reference to the "Administrators" name.