本文介绍了获得所有用户的特定索赔?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
对于ASP.NET Identity 2.0:
For ASP.NET Identity 2.0:
有人知道如何获得分配了给定索赔的所有用户"吗?
Does anybody know how to get "all users that have a given claim assigned"?
假设我有一个类型为"ArticleId"且值为"1"的声明.
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!!
推荐答案
选中此选项.
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"));
这篇关于获得所有用户的特定索赔?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!