Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get all users for a certain claim?

For ASP.NET Identity 2.0:

Does anybody know how to get "all users that have a given claim assigned"?

Let's say I have a claim with type="ArticleId" and value="1".

How can I get all users that have this claim? I really couldn't figure it out .. so, thanks for any help!!

like image 380
Ingmar Avatar asked Oct 15 '14 17:10

Ingmar


1 Answers

Check this one.

var userContext = new ApplicationDbContext();

var users = userContext.Users.ToList(); Or 

var users = UserManager.Users.ToList();

var userfilter = users.Where(u => u.Claims.Any(t => t.ClaimType == "ArticleId" && t.ClaimValue == "1"));
like image 180
DSR Avatar answered Oct 21 '22 23:10

DSR