Luis Abreu
Luis Abreu

Reputation: 4506

Microsoft graph: get only users from group

Just wondering if there's any way to get only the users placed inside an azure ad group. I've tried something like this:

var membros = await obtemUtilizadores
                .Filter("'odata.type' eq '#microsoft.graph.user'")
                .Select("id,userprincipalname,mail,displayname")
                .Expand("extensions($filter=id eq 'assistenciasExtensions')")
                .GetAsync().ConfigureAwait(false);

It translates into this url:

https://graph.microsoft.com/v1.0/groups/xxxxxx/members?
 $filter='odatatype eq 'microsoft.graph.user'&
 $select=id,userprincipalname,mail,displayname&
 $expand=extensions($filter=id eq 'assistenciasExtensions')

Which returns an error saying that the filter is wrong.

Btw, what I really need is to get all users from within group X with the assistenciasExtensions data.

Thanks.

Luis

Upvotes: 2

Views: 1804

Answers (1)

Dan Kershaw - MSFT
Dan Kershaw - MSFT

Reputation: 5838

Unfortunately a service-side filter for this is not currently possible (filtering on the target of a navigation collection - for type and/or any property including extension properties). You'll need to get all members and then filter on the client side. Appreciate that this is pretty awful - I filed a user voice item for this - please feel free to vote for this feature. https://officespdev.uservoice.com/forums/224641-feature-requests-and-feedback/suggestions/19587061-allow-filter-on-target-of-a-navigation-collection

Hope this helps,

Upvotes: 2

Related Questions