user3302723
user3302723

Reputation: 15

Query OUPath with AdminSDK "Invalid Input: INVALID_OU_ID"

Trying to query all users in the OU "LegacyMail" with the new Admin SDK for Apps Script, but it fails:

The example at developers.google.com shows that it should look like this:

"orgUnitPath": "corp/engineering",

function admsdk() {

  var x = AdminDirectory.Users.list({
    domain: "acamedomain.com",
    query: "orgUnitPath:/acamedomain.com/LegacyMail"

  });

  Logger.log(x);

}

Upvotes: 1

Views: 2937

Answers (1)

Jay Lee
Jay Lee

Reputation: 13528

Try:

function admsdk() {

  var x = AdminDirectory.Users.list({
    customer: "my_customer",
    query: "orgUnitPath='/LegacyMail'"

  });

  Logger.log(x);

}

to explain:

  1. customer / my_customer isn't strictly necessary but it ensures you get ALL users, not just users who have a primary domain in acamedomain.com.
  2. / is the root OU of your domain. /acamedomain.com is not right unless you've explicitly created an OU called that. OUs are independent of SMTP domains.

Upvotes: 3

Related Questions