문제

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.

도움이 되었습니까?

해결책

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)

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).

다른 팁

After some back and forth with the google dev relations team I was able to get it to work bay adding a query parameter orgUnitPath=/SOMEPATH to the list users call. Here is an example using the google api php client that's using the directory API: $users = $directory->users->listUsers(array("domain"=>"example.com","query"=>"orgUnitPath=/SOMEPATH"));

Hope this helps!

UsersResource.ListRequest request = service.Users.List(); 
request.Customer = "my_customer";
request.Query = "orgUnitPath=" + "'" + "/testOu/under testOu/testOu1" + "'"; 
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top