zlZimon
zlZimon

Reputation: 2489

How to list users of Google Admin Directory but exclude users in any sub OU

I have one main organizational unit which includes most of my users in the Google Admin Directory. However I also have some sub-organizational units under the main one which also contain users.

To retrieve all users I am using the Directory API. When I want only to retrieve users of one sub- organizational unit I add orgUnitPath:/MainOU/subOU1 as a query parameter.

But how can I only retrieve users which are in the main OU but NOT in any sub OU? When I use orgUnitPath:/MainOU it also includes all users in any sub OU.

Upvotes: 1

Views: 1105

Answers (1)

ziganotschka
ziganotschka

Reputation: 26836

Unfortunately the scope of query for Users: list is rather limited

  • It does not implement the functionality of excluding sub OUs.
  • If this functionality is important to you, consider filing a feature request on Google's Public Issue Tracker
  • In the mean time, a workaround would be performing multiple requests:
    • One request to list the users of the sub OU(s)
    • The second request to list all users
    • Subsequently you need to implement programmatically a functionality to compare the two lists a retrieve only the users that are not contained in the subdomain list

Upvotes: 1

Related Questions