Microsoft graph get all users只返回100个用户



Microsoft graph只返回100用户,我如何从Microsoft图中获得所有用户

var users = graphServiceClient
.Users
.Request()
.GetAsync()
.GetAwaiter()
.GetResult();

如何获得所有用户?

MS Graph使用100记录的默认页面大小的分页输出。您刚刚阅读了默认100用户的第一页。

您可能想要这样的东西(查询通常,这就是为什么我将它们设置为async):

var users = await graphServiceClient
.Users
.Request()
.Top(999)  // <- Custom page of 999 records (if you want to set it)
.GetAsync()
.ConfigureAwait(false);
while (true) {
//TODO: relevant code here (process users)
// If the page is the last one
if (users.NextPageRequest is null)
break;
// Read the next page
users = await users
.NextPageRequest
.GetAsync()
.ConfigureAwait(false);
} 

最新更新