Reputation: 153
I have the business requirement to pull group membership from an Office 365 organisation and resolve all members for each the groups using the Microsoft Graph API.
I can successfully pull the list of groups and drill down through the members of the group however currently the Microsoft Graph API does not return group members which are 'Contacts' - it only returns Users (Microsoft.Graph.User
) and Groups (Microsoft.Graph.Group
).
Current Approach:
/v1.0/groups
)/v1.0/groups/{id}/members
)Ideally I need to know whether this is possible using Microsoft Graph or whether another API is available to achieve the business requirement. One approach I have considered is to pull all contacts then evaluate that against the list of groups to work out membership but unfortunately there does not seem to be a call to pull all organisation contacts using Microsoft Graph (there is only a user specific call)
Example JSON (v1.0/groups/165d8e8d-6ba0-4782-9dbc-251f6f76826d/members
):
{
"@odata.context":"${hidden}",
"@odata.nextLink":"${hidden}",
"value": [
{
"@odata.type": "#microsoft.graph.user",
"id": "b01eb2fe-1656-4c3e-a1bd-283c057baaac",
"businessPhones": [
"${hidden}"
],
"displayName": "${hidden}",
"givenName": "Richard",
"jobTitle": null,
"mail": "${hidden}@${hidden}",
"mobilePhone": null,
"officeLocation": null,
"preferredLanguage": "en-NZ",
"surname": "${hidden}",
"userPrincipalName": "${hidden}@${hidden}"
},
{
"@odata.type": "#microsoft.graph.user",
"id": "802670e3-02d9-4083-be58-55ab7abef0ab",
"businessPhones": [],
"displayName": "Johnny Minty",
"givenName": "Johnny",
"jobTitle": null,
"mail": "johnny.minty@${hidden}",
"mobilePhone": null,
"officeLocation": null,
"preferredLanguage": "en",
"surname": "Minty",
"userPrincipalName": "johnny.minty@${hidden}"
},
{
"@odata.type": "#microsoft.graph.user",
"id": "6d7a6dba-ddad-4351-b324-d88e575c50e1",
"businessPhones": [],
"displayName": "${hidden}",
"givenName": "Shrey",
"jobTitle": null,
"mail": "${hidden}@${hidden}",
"mobilePhone": null,
"officeLocation": null,
"preferredLanguage": "en",
"surname": "${hidden}",
"userPrincipalName": "${hidden}@${hidden}"
},
{
"@odata.type": "#microsoft.graph.group",
"id": "9ad40d3c-ee89-4dd3-a511-a4c16691d695",
"deletedDateTime": null,
"classification": null,
"createdDateTime": "2017-08-09T07:08:14Z",
"description": null,
"displayName": "Large1",
"groupTypes": [],
"mail": "large1@${hidden}",
"mailEnabled": true,
"mailNickname": "Large1",
"onPremisesLastSyncDateTime": null,
"onPremisesProvisioningErrors": [],
"onPremisesSecurityIdentifier": null,
"onPremisesSyncEnabled": null,
"proxyAddresses": [
"SMTP:large1@${hidden}"
],
"renewedDateTime": "2017-08-09T07:08:14Z",
"securityEnabled": false,
"visibility": null
}
]
}
Upvotes: 1
Views: 487
Reputation: 33094
Microsoft Graph current only supports Office 365, Dynamic, and Security groups. What you're looking at here is a classic Distribution List (see Compare groups for details).
The reason you're not getting a complete list is because Microsoft Graph doesn't have a type support for the Contact
object, it currently only supports microsoft.graph.user
.
This is coming however. The /beta
endpoint includes both microsoft.graph.user
and microsoft.graph.orgContact
object types. If you try your call against the /beta
endpoint, you'll find it returns the full list of members.
I do not have an ETA but as soon as Organization Contacts is released to GA, you should be able to leverage Distribution Lists through the API. Until then, you can do your development against the /beta
endpoint. You may have some minor changes to make when it is released but it is unlikely the final version will be substantially different.
Upvotes: 1