I'm using the Google Directory API, here is the code that I'm using and I get the user info. But I need to get also the groups that the user is member.
My question is how can I do that when I have the user. I have another code to get the members, from a group but this impractical, because if I do that. I'll will need to get all the members for all the groups.
public static void get_user(String correo) {
Users us;
try {
service = getDirectoryService("admin@domain.mx");
try {
us = service.users().list().setCustomer("my_customer").setQuery("email:"+correo).execute();
System.out.println("us:"+us);
List<User> lu = us.getUsers();
System.out.println("lu:"+lu);
if (lu!=null) {
System.out.println("reses:"+lu.size());
for (int i=0;i<lu.size();i++) {
User u = lu.get(i);
String id = u.getId();
String pemail = u.getPrimaryEmail();
UserName username = u.getName();
System.out.println("xxxx.................");
System.out.println(i+":"+id);
System.out.println("username:"+username.getFullName());
System.out.println("full:"+username.getGivenName());
System.out.println("email:"+pemail);
System.out.println("organization unit:"+u.getOrgUnitPath());
}
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (GeneralSecurityException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (URISyntaxException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}