0

When I execute the below code

CN = AdminDirectory.Users.get(user).organizations;

I got the output as below-

[{customType=, name=OPOP, description=Software engineer, title=SWE, type=work, primary=true}]

But i would like to print each item separately like below

customType=

name=OPOP

description=Software engineer

title=SWE

How can I do this?

Thanks in advance

Kanchan
  • 65
  • 2
  • 11

1 Answers1

0

As mentioned in Admin SDK Directory Service, developers are allowed to use the Admin SDK's Directory API in Apps Script. This API gives administrators of Google Apps domains (including resellers) the ability to manage devices, groups, users, and other entities in their domains.

With the Directory API, you can retrieve an organization unit using the GET request and include the authorization described in Authorize requests. The orgUnitPath query string is the full path for this organization unit.

Also discussed in the documentation:

If you are an administrator retrieving an organization unit, use my_customer.

GET https://www.googleapis.com/admin/directory/v1/customer/my_customer/orgunits/orgUnitPath

If you are a reseller retrieving an organization unit for a resold customer, use the customerId. To get the customerId use the Retrieve a user operation.

GET https://www.googleapis.com/admin/directory/v1/customer/customerId/orgunits/orgUnitPath

If you want to print seperately, here is an example request wherein the 'frontline sales' organization unit is retrieved. Note the 'frontline+sales' HTTP encoding in the request's URI:

GET https://www.googleapis.com/admin/directory/v1/customer/my_customer/orgunits/corp/sales/frontline+sales

A successful response returns an HTTP 200 status code. Along with the status code, the response returns the organization unit's settings:

{
    "kind": "directory#orgUnit",
    "name": "frontline sales",
    "description": "The frontline sales team",
    "orgUnitPath": "/corp/sales/frontline sales",
    "parentOrgUnitPath": "/corp/sales",
    "blockInheritance": false
}

Hope that helps!

adjuremods
  • 2,938
  • 2
  • 12
  • 17
  • I did get the output as above. But i'm not able to access individual values from the above output. For example, assume that above output is stored in variable 'CN', If I print **CN.name** it's showing undefined as the output. Could you please help me. Thanks in advance. – Kanchan Oct 05 '16 at 03:17