Im using the Directory API in the Google admin SDK to manage users in Google domains. I'm looking for a way to list users in a specific orgunit in the domain but I don't find any examples on how to achieve this. According to the documentation https://developers.google.com/admin-sdk/directory/v1/reference/users/list the only valid query attributes are email, familyName and givenName. The workaround im using today is to get all users in the domain and then filter the response.
1
votes
3 Answers
0
votes
9
votes
This is possible using the query
parameter.
Example:
/admin/directory/v1/users?domain=domain.com&query=orgUnitPath=/Sales
or, url encoded:
/admin/directory/v1/users?domain=example.com&query=orgUnitPath%3D%2FSales
Will return all users in the /Sales
orgunit.
Full docs here.
0
votes
I used the 'query' parameter as explained in https://developers.google.com/admin-sdk/directory/reference/rest/v1/users/list and it works.
var optionalArgs = {
customer: 'my_customer',
orderBy: 'email',
query: "orgUnitPath='/A1 - Current Members'"
};
var response = AdminDirectory.Users.list(optionalArgs);