Microsoft Graph:在一个请求中列出所有用户及其组 [英] Microsoft Graph: List all users and their groups in one request

查看:106
本文介绍了Microsoft Graph:在一个请求中列出所有用户及其组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想列出所有用户.对于每个用户,我需要显示特定于该用户的角色和组.

I would like to list all users. For each user, I need to display the roles and groups specific to that user.

我尝试过:

https://graph.microsoft.com/v1.0/users?$expand=memberOf

但是它给出的结果与以下内容完全相同:

But it gives exactly the same result as:

https://graph.microsoft.com/v1.0/users

根据用户对象的文档( http://graph.microsoft.io/en-us/docs/api-reference/v1.0/resources/user ),我应该能够通过使用memberOf关系.

According to the doc for the user object (http://graph.microsoft.io/en-us/docs/api-reference/v1.0/resources/user), I should be able to list the roles and groups for the user by using the memberOf relationship.

我可以通过为每个用户执行一个请求(使用https://graph.microsoft.com/v1.0/users/{user_id}/getMemberObjects)来获得每个用户所需的角色和组,但这有点慢且过分.

I can get the roles and groups I need for every user by doing one request per user (using https://graph.microsoft.com/v1.0/users/{user_id}/getMemberObjects) but it's a bit slow and overkill.

我想念什么?

推荐答案

Microsoft Graph端点的生产(v1.0)版本上当前无法使用用户实体上的扩展导航属性.该功能在Beta端点上有效.

Expanding navigation properties on user entities is currently not working on the production (v1.0) version of the Microsoft Graph endpoint. The functionality is live on the beta endpoint.

此查询可按您希望的方式工作:

This query works as you desire:

https://graph.microsoft.com/beta/users?$expand=memberOf

何时将功能从Beta迁移到v1.0或它们是否将以当前形式使用,都没有时间表.

There is no timeline on when features move from beta to v1.0 or whether they even will in the current form.

当前,使用Microsoft Graph API有3种选择.

Currently, you have 3 choices using the Microsoft Graph APIs.

Beta端点

使用beta端点,但了解其功能可能会发生变化.

Use the beta endpoint but understand that it may change in functionality.

多个图形调用

获取用户集合,然后根据需要为每个用户获取memberOf.

Fetch the users collection then fetch the memberOf for each user as you need it.

https://graph.microsoft.com/v1.0/users/{id}/memberOf

https://graph.microsoft.com/v1.0/users/{user_id}/getMemberObjects

扩展网上论坛的成员

如果您要坚持使用v1.0端点并根据您的总体目标,则可以尝试以另一种方式查找所需的信息.获取组的集合,然后展开成员导航属性.

If you want to stick with the v1.0 endpoint and depending on your overall goal, you can attempt to go about finding the information you want the other way. Get the collection of groups and expand the members navigation property instead.

https://graph.microsoft.com/v1.0/groups/?$expand=members

这篇关于Microsoft Graph:在一个请求中列出所有用户及其组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆