directory api - get users using orgName

756 views Asked by At

I have four sub-organizations defined. (/AdminOrg, /subOrgA, /SubOrgB, /subOrgA/SubOrgAA)

my directory.orgunits.list query return below data. I store the return array in a variable called orgUnits[]:

http://pastebin.com/Kzud6SAq

I have 4 users in my organization. one in each sub-organization. the users.list return below data:

http://pastebin.com/6ttSgDSe

I am trying to get no. of users within an organization (without including sub organizations in them)

Option 1: The query directory.users.list.query("orgUnitPath=/subOrgA") includes users from sub organization (/subOrgA/SubOrgAA) too and does not meet my needs.

Option 2: I tried the query directory.users.list.query("orgName=orgUnits[]->name"). It queries for users[]->organizations[]->name. And this field is null by default. It does not get populated with orgUnits[]->name.

My questions are

  1. How to populate users.organizations[].name?

  2. Is there any way I can get users within an organization without including sub-organizations in them

1

There are 1 answers

0
Eric Koleda On

Unfortunately it isn't possible to search for users within an orgUnit not including sub-orgs. The orginations field in the Users resource, as well as the orgName, orgTitle, orgDepartment, orgDescription, orgCostCenter query parameters, refer to a completely separate set of data that appears to be used by the API only. Only the orgUnitPath field and query parameter operate on the organizations visible within the Google Apps Admin Console.