Reputation: 12415
I try to get the group-memberships of a user via MS Graph API for Java.
My user is member in 7 groups. But I only get the group ID (sort of UUID) but displayName is always null.
Any idea how to get the name of the group??
User usr = gsc.users (MYUSERID).buildRequest ().get ();
System.out.println ("User: " + usr.displayName);
DirectoryObjectCollectionWithReferencesPage doc = gsc.users (MYUSERID).memberOf ().buildRequest ().get ();
java.util.List <DirectoryObject> lst = doc.getCurrentPage();
for (int i = 0; i < lst.size (); i ++)
{
if (lst.get (i) instanceof Group)
{
Group gp = (Group) lst.get (i);
System.out.println ("Member: " + gp + " / " + gp.id + " / " + gp.displayName);
}
}
Output is
User: MyTestUser
Member: com.microsoft.graph.models.Group@c514b123 / 83091123-c2ea-4883-8a2b-faab7de7433 / null
...
EDIT
This also only delivers null.
for (int i = 0; i < lst.size (); i ++)
{
System.out.println (((Group)doc.getCurrentPage().get(i)).displayName);
}
EDIT
Changed to memberOfAsGroup - still null for displayName.
GroupCollectionPage doc = gsc.users (this.azureuserid).memberOfAsGroup ().buildRequest ().get ();
java.util.List <Group> lst = doc.getCurrentPage ();
for (int i = 0; i < lst.size (); i ++)
{
Group gp = lst.get (i);
System.out.println(i + " Member: " + gp + " / " + gp.id + " / " + gp.displayName + " " + gp.description);
}
Upvotes: 0
Views: 729
Reputation: 12415
Is working now. Registered app in Azure needs permission for Groups.ReadAll (Application, not Delegate!).
Surprisingly not the assigned permission is needed but only the admin-consent to it - even if the persmission is removed.
Do not know if this is a bug or feature.
Upvotes: 0