Hi I am testing WebApi calls and I Wanted to proble users and their roles.
I can get all roles, and user data but how can I check what roles a user has?
This is a plugin so I can not know what type of role providers a consuming project could have. COuld be Default ones, could be OWIN. Could be something different.
public IHttpActionResult GetCurrentUserData(string userName)
var virtualRoleRepository = (RolesRepository ?? ServiceLocator.Current.GetInstance<IVirtualRoleRepository>()).GetAllRoles();
var user = EPiServerProfile.Get(userName);
//var userRoles = ?????
if (user == null)
You can use UIRoleProvider.GetRolesForUser(userName)
the drawback is UIRoleProvider is in EPiServer.Shell.Security, i.e. EPiServer UI package
Thank you! I dont know if the namespace will be a problem, i would assume not and hope it will not :)