gpt4 book ai didi

java - 如何获取 Google Apps 用户的管理员状态

转载 作者:行者123 更新时间:2023-11-30 05:08:23 27 4
gpt4 key购买 nike

我有一个 GWT 应用程序,用户可以使用其 Google Apps 帐户登录(OpenID 登录)。现在我想知道登录的用户是否是该域的管理员。

这已经适用于以下代码:

private boolean isAdmin (String username) {
boolean ret= false;

if (username.indexOf ("@") > 0) username= username.substring (0, username
.indexOf ("@"));

AppsForYourDomainClient client= null;
try {
client= new AppsForYourDomainClient ("admin@orgapage.de", "password",
"orgapage.de");

UserEntry user= client.retrieveUser (username);
if (user.getLogin ().getAdmin ().equals (Boolean.TRUE)) ret= true;
else ret= false;
}
catch (Exception ex2) {
log.severe (ex2.getMessage ());
ex2.printStackTrace ();
}

return ret;
}

问题是,我必须输入该域管理员的用户名和密码才能检查当前登录的用户。

有没有办法在不知道管理员密码的情况下执行此操作?也许使用 OAuth?

到目前为止,我发现检索管理员状态的唯一方法是上面的方法。这是它的文档:

http://code.google.com/googleapps/domain/gdata_provisioning_api_v2.0_reference_java.html#Retrieve_Account_Example

最佳答案

如果您使用 Google Apps Marketplace,则可以通过两足 OAuth 请求对 Google Apps 域的只读配置 API 访问权限。这将允许您使用上面的示例代码,而不需要域管理员用户名/密码。请参阅以下文档:

http://code.google.com/googleapps/marketplace/data_access.htmlhttp://code.google.com/googleapps/marketplace/manifest.html

杰伊

关于java - 如何获取 Google Apps 用户的管理员状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4304209/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com