Web Applications Stack Exchange is a question and answer site for power users of web applications. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We use Google apps for enterprise, and I want to build an intranet, based on the Google sites intranet template

In the Directory area, I want that the list will be updated from my contact/company list directory.

Is it possible?

share|improve this question
up vote 5 down vote accepted

The following code retrieves the users, present within the Google Apps Domain:

function doGet() {
  var app = UiApp.createApplication(); 

  var users = UserManager.getAllUsers();  
  var flexTable = app.createFlexTable().setBorderWidth(1);

  for (var i=0, len=users.length; i<len; i++) {
    var user = users[i];
    flexTable.setWidget(parseInt(i), 0, app.createLabel(user.getGivenName()
      + ' ' + user.getFamilyName()));
    flexTable.setWidget(parseInt(i), 1, app.createLabel(user.getEmail()));


  return app;

Add this script, via the Google Apps Script gadget, to your page and the people will appear. See working example: domain users by script

There are however some prerequisites:

  1. Be an administrator
  2. Enable the provisioning API: dashboard/domain settings/user settings

You can also use a script within a spreadsheet and display the users in a spreadsheet:

function getdomainUsers() {
  // set spreadsheet
  var ss = SpreadsheetApp.getActiveSpreadsheet();

  // set sheet
  var sheet = ss.getSheets()[0];

  // set range
  var range = sheet.getRange(2, 1, sheet.getLastRow(), 2);

  // clear range

  // retrieve all users and create array
  var users = UserManager.getAllUsers(), auserInfo = new Array();  

  // itterate through users  
  for (var i=0, len=users.length; i<len; i++) {
    // instantiate user
    var user = users[i];

    // add info to array
    auserInfo.push([user.getGivenName() + ' ' + user.getFamilyName(),user.getEmail()]);

  // set values to sheet

Set a trigger on the script, to refresh the users for lets say every 12 hours. An administrator needs to prepare the sheet once. See working example: domain users by spreadsheet

share|improve this answer
First script doesn't return results. can you confirm its working please? – Saariko Nov 26 '12 at 19:08
See modified answer. I've added working examples. One based on a stand alone script and the other one via a spreadsheet. – Jacob Jan Tuinstra Nov 26 '12 at 21:13

Note: Apparently the Domain Service "...was deprecated on May 15, 2014, and will be turned off on November 20, 2014. To manage your domain, use the Admin SDK Directory and Admin SDK Reports advanced services instead. See the guide to migrating from Domain service." per the documentation page for the UserManager Class.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.