Search code examples
google-apigoogle-admin-sdkgoogle-apps-marketplace

How to list all users (under all domains) in an organisation?


Organisations can have multiple domains under their Google Apps account, and each domain can have users under it. For example, the organisation domain is company.com, but it also has parkeddomain.com associated with it (admin console -> domains).

I want to get the list of all users, both listed under company.com - [email protected] and parkeddomain.com - [email protected].

I'm currently using this api call:

https://www.googleapis.com/admin/directory/v1/users?domain=company.com

But it only returns users who are in the company.com.

Question: Is there a way to return all users from all domains? If not, is there a way to get all the domains for this organisation so that I can manually iterate over them?


Solution

  • You can retrieve all users of a company using the customer filter (customer=my_customer).

    The unique ID for the customer's Google account. In case of a multi-domain account, to fetch all groups for a customer, fill this field instead of domain. As an account administrator, you can also use the my_customer alias to represent your account's customerId. The customerId is also returned as part of the Users resource. Either the customer or the domain parameter must be provided.

    Source.