I have a new project i created in VS 2013. I am using the identity system and i'm confused how to get a list of all users to the application and all roles int he application. I am trying to create some admin pages so i can add new roles, add roles to users, see who all is logged in or locked.
Anybody know how to do this?
In ASP.NET Identity 1.0, you'll have to get this from the DbContext itself...
var context = new ApplicationDbContext();
var allUsers = context.Users.ToList();
var allRoles = context.Roles.ToList();
In ASP.NET Identity 2.0 (currently in Alpha), this functionality is exposed on the UserManager
and RoleManager
...
userManager.Users.ToList();
roleManager.Roles.ToList();
In both versions, you would be interacting with the RoleManager
and UserManager
to create roles and assign roles to users.