【问题标题】:How to search users in groups and return display names using graph API?如何使用图形 API 在组中搜索用户并返回显示名称?
【发布时间】:2021-01-12 14:19:07
【问题描述】:

网络核心应用程序。我在 Web 应用程序中有搜索框,用户可以在其中搜索用户属于特定组。我正在尝试如下搜索用户

var members = await graphClient.Groups["0001b29c-fd90-4ae9-a5a1-h8afe65777e9"].Request().Expand("members").GetAsync();
var usersInGroup = members.Members.ToList();

在上面的代码中,我还想应用过滤器来列出以开头的用户名。我正在努力应用过滤器。有人可以帮我在这里添加过滤器。任何帮助将不胜感激。谢谢

【问题讨论】:

    标签: asp.net-core azure-active-directory microsoft-graph-api


    【解决方案1】:

    请尝试使用以下 API 来搜索群组中的用户

     https://graph.microsoft.com/beta/groups/groupid/members/microsoft.graph.user?$count=true&$orderby=displayName&$search="displayName:sr"&$select=displayName,id
    
    ConsistencyLevel: eventual
    

    【讨论】:

    • 感谢 Sruthi,但同样的事情,我如何用 c# 编写?
    • 另外如何在上述请求中添加开头?
    • 对于startswith 使用此查询https://graph.microsoft.com/beta/groups/groupid/members/microsoft.graph.user?$count=true&$filter=startsWith(displayName,'sr')&$select=displayName,id
    • 我用过它,但它显示所有行但我想搜索显示名称以特定名称开头
    • 我试过上面的查询,现在得到错误为“code”:“Request_UnsupportedQuery”,“message”:“当前不支持引用属性查询的指定过滤器。”,
    猜你喜欢
    • 2015-11-06
    • 1970-01-01
    • 2018-09-16
    • 1970-01-01
    • 1970-01-01
    • 2016-07-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多