首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Google Apps Domain中从电子邮件中获取用户名?

在Google Apps Domain中从电子邮件中获取用户名?
EN

Stack Overflow用户
提问于 2013-04-15 13:51:52
回答 2查看 2.2K关注 0票数 0

我有一封来自Google Apps域名的电子邮件。我可以通过进入谷歌应用程序的联系人页面,在“域”下看到一个域中所有用户的列表。

如果我想从那封电子邮件中得到他们的全名,我该怎么做呢?我试过使用ContactsApp,但都没有用。我也不能在域工具中使用UserManager,因为我没有访问管理工具的权限。

你知道我该怎么做吗?

EN

回答 2

Stack Overflow用户

发布于 2013-04-17 10:01:10

您的问题类似于Google Script How do I getGivenName() of getActiveUser(),尽管在这种情况下,管理员试图创建一个服务,域成员运行的脚本可以使用该服务来获取自己的全名。

this answer可能会有所帮助。作为域用户,您可以获取自己联系人列表中人员的全名。加入足够多的人(或合适的人),你的成功率将会很高。

以下是该脚本的修改版本。

代码语言:javascript
复制
/**
 * Get a user's name, by accessing contacts.
 *
 * @returns {String} FullName, or UserID
 *                   if record not found in contacts.
 */
function getUserName(email){
  var user = ContactsApp.getContact(email);

  // If user in contacts, return their name
  if (user) {
    // Get full name
    var name = user.getFullName();
  }
  if (!name) {
    // If not in Contacts, return the bald userID.
    name = email.split('@')[0];
  }
  return name;
}
票数 1
EN

Stack Overflow用户

发布于 2013-05-09 21:30:19

要求管理员授予您自己对用户配置API的只读访问权限。这一点和GAL提要在这个问题的答案中都有介绍:How can I get read-only access to the Google Apps Profiles API?

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16008421

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档