public string[] GetRolesForCurrentUser() { try { ApplicationServiceHelper.EnsureRoleServiceEnabled(); EnsureProviderEnabled(); IPrincipal user = ApplicationServiceHelper.GetCurrentUser(HttpContext.Current); string username = ApplicationServiceHelper.GetUserName(user); RoleProvider provider = GetRoleProvider(user); return(provider.GetRolesForUser(username)); } catch (Exception e) { LogException(e); throw; } }
public bool IsCurrentUserInRole(string role) { if (role == null) { throw new ArgumentNullException("role"); } try { ApplicationServiceHelper.EnsureRoleServiceEnabled(); EnsureProviderEnabled(); IPrincipal user = ApplicationServiceHelper.GetCurrentUser(HttpContext.Current); string username = ApplicationServiceHelper.GetUserName(user); RoleProvider provider = GetRoleProvider(user); return(provider.IsUserInRole(username, role)); } catch (Exception e) { LogException(e); throw; } }