No WebSecurity.GetAllUsers() method. Why?

528 views Asked by At

I want to list all users who are in admin role using WebMatrix.WebData.Security.

I am able see Membership.GetAllUsers() Method is there. But not WebSecurity.GetAllUsers().Why?.

I used Membership.GetAllUsers () method but this throws an exception “Specified method is not supported.”

Can anybody provide alternate ways to achieve this?

2

There are 2 answers

0
sridharnetha On BEST ANSWER

Below code may helpful to someone. I used lambda expression.

List<UserProfile> UserProfileList = db.UserProfileRepository.Where(u => Roles.IsUserInRole(u.UserName, "admin") == true).ToList();
1
Ashish Rajput On

Here you can use like

var userRoles = (SimpleRoleProvider)Roles.Provider;        
var userName = userRoles.GetUsersInRole("admin");

Here userName would be string array.