Search code examples
google-apps-scriptgoogle-admin-sdkgoogle-directory-api

Query Google Admin User directory for multiple parameters


I'm trying to query Google Admin User directory on two parameters: name and orgName. I have tried several variations of the below, which does not work:

  var userList = AdminDirectory.Users.list({
    customer: 'my_customer',
    maxResults: 100,
    query: 'name:david AND orgName=hotel',
    viewType: 'domain_public',
    projection: 'full'
  }).users;

... but I think it illustrates what I'm trying to do. My questions are:

1) Is this possible?

2) If I might push my luck, is it possible to query organization location? (I didn't see anything like this in the documentation...)

Have already consulted https://developers.google.com/admin-sdk/directory/v1/guides/search-users, did not find anything there.


Solution

  • The query does not support AND or OR operators, only one search term is allowed.

    I'd suggest querying on the more specific (probably name) field and then filtering locally on the additional fields. So in other words, query=name:david and then look for hotel in the orgName field locally.