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?
Web Applications Stack Exchange is a question and answer site for power users of web applications. It only takes a minute to sign up.
Sign up to join this communityWe 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?
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()));
}
app.add(flexTable);
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:
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
range.clear();
// 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
sheet.getRange(2,1,len,2).setValues(auserInfo);
}
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
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.