如何使用 Google Directory API 获取一个组织单位中的所有用户

如何使用 Google Directory API 获取一个组织单位中的所有用户

问题描述:

在新发布的 Google Directory API 中,我找不到获取 Google Apps 特定组织单位中所有用户的方法.是否可以?如何?根据Google Directory API 文档,程序员可以获取所有组织单元,或者整个域的所有用户,但没有描述如何获取一个组织单元的用户.此功能对于构建组织/用户分层树至关重要.请帮忙,谢谢.

In the new released Google Directory API, I cannot find a method to get all users in a specific organization unit of Google Apps. Is it possible? And how? Based on the Google Directory API document, programmers can get all the organization units, or all the users for the whole domain, but there is no description on how to get users of one organization unit. This feature is crucial important to construct the organizations/users hierarchical tree. Please help, thanks.

无法获取单个 OU 下的用户列表(并且只有那些用户).但是,您只需调用以下网址即可获取 Google Apps 实例中用户的完整列表及其 OU:

There is no way to get the list of users under a single OU (and only those users). However, you can just grab the full list of users in the Google Apps instance along with their OU using a call to:

https://www.googleapis.com/admin/directory/v1/users?customer=my_customer&fields=nextPageToken%2Cusers(orgUnitPath%2CprimaryEmail)

根据 Vic Fryzel 在 I/O 上的演讲,我相信 Google 的计划继续改进查询参数的能力,最终允许基于 OU(以及其他查询参数)的查询.

based on Vic Fryzel's presentation at I/O, I believe Google plans to continue to improve the capabilities of the query parameter, eventually allowing a query based on OU (as well as other query parameters).