Google 应用中二级域的用户列表
List of user from the Secondary Domain in Google Apps
我创建了一个脚本来获取一个电子表格中的所有用户、姓名和电子邮件,但我无法获取在辅助域下创建的用户。
这是我的代码:
function writeToSpreadsheet(){
var values = [],
users = [],
userListQuery = {},
nextPageToken = '',
listObject = {
domain:'the domain name',
maxResults: 500,
},
i = 0,
activeSpreadsheet;
do {
if (nextPageToken && nextPageToken !== '') {
listObject.pageToken = nextPageToken;
}
userListQuery = AdminDirectory.Users.list(listObject);
// if there are more users than fit in the query a nextPageToken is returned
nextPageToken = userListQuery.nextPageToken;
// Add the query results to the users array
users = users.concat(userListQuery.users);
} while (nextPageToken);
for (i = 0; i < users.length; i += 1) {
values.push([users[i].name.fullName, users[i].primaryEmail]);
}
SpreadsheetApp.getActiveSpreadsheet().getSheets()[0].getRange(2, 1, values.length, values[0].length).setValues(values);
}
使用 Google 管理设置 API,它允许 Google 应用程序域的管理员以 Google 数据 Google 的形式检索和更改其域的设置 API 饲料。
要从辅助域检索,您可以将 HTTP GET 发送到帐户信息管理员辅助电子邮件地址供稿 URL 并包含 Authorization
header,如 Authenticating to the Admin Settings service 中所述
成功响应 returns 和 HTTP 200 OK
,以及管理员的辅助电子邮件地址。
示例 HTTP GET 请求:
https://apps-apis.google.com/a/feeds/domain/2.0/{域名}/accountInformation/adminSecondaryEmai
我创建了一个脚本来获取一个电子表格中的所有用户、姓名和电子邮件,但我无法获取在辅助域下创建的用户。
这是我的代码:
function writeToSpreadsheet(){
var values = [],
users = [],
userListQuery = {},
nextPageToken = '',
listObject = {
domain:'the domain name',
maxResults: 500,
},
i = 0,
activeSpreadsheet;
do {
if (nextPageToken && nextPageToken !== '') {
listObject.pageToken = nextPageToken;
}
userListQuery = AdminDirectory.Users.list(listObject);
// if there are more users than fit in the query a nextPageToken is returned
nextPageToken = userListQuery.nextPageToken;
// Add the query results to the users array
users = users.concat(userListQuery.users);
} while (nextPageToken);
for (i = 0; i < users.length; i += 1) {
values.push([users[i].name.fullName, users[i].primaryEmail]);
}
SpreadsheetApp.getActiveSpreadsheet().getSheets()[0].getRange(2, 1, values.length, values[0].length).setValues(values);
}
使用 Google 管理设置 API,它允许 Google 应用程序域的管理员以 Google 数据 Google 的形式检索和更改其域的设置 API 饲料。
要从辅助域检索,您可以将 HTTP GET 发送到帐户信息管理员辅助电子邮件地址供稿 URL 并包含 Authorization
header,如 Authenticating to the Admin Settings service 中所述
成功响应 returns 和 HTTP 200 OK
,以及管理员的辅助电子邮件地址。
示例 HTTP GET 请求: https://apps-apis.google.com/a/feeds/domain/2.0/{域名}/accountInformation/adminSecondaryEmai