Search code examples
apigoogle-appsgoogle-api-clientgoogle-api-dotnet-client

How to get all users in one organization unit using 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.


Solution

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