Reputation: 7213
I have a GWT application, where users can sign on with their Google Apps account (OpenID Login). Now I want to be able to know, if the user signed on is an admin for this domain.
This already works with the following code:
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 ("[email protected]", "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;
}
The problem is, that I have to enter the username and password of an admin of this domain to check for the current logged in user.
Is there a way to do this without having to know the password of an admin? Maybe with OAuth?
The only way to retrieve the admin status, I found so far, is the one above. Here is the documentation of it:
Upvotes: 1
Views: 929
Reputation: 156
If you use the Google Apps Marketplace, you can request read-only Provisioning API access to the Google Apps domain via Two-Legged OAuth. This would allow you to use your sample code above instead of needing a domain admin username/pass. See the docs at:
http://code.google.com/googleapps/marketplace/data_access.html http://code.google.com/googleapps/marketplace/manifest.html
Jay
Upvotes: 3
Reputation: 2214
The UserService
has a method called isUserAdmin
for determining if the current user is an admin for the application.
Not sure if this is what you are looking for!
Upvotes: -1