microsoftgraph / msgraph-sdk-serviceissues

Tracks service issues for follow up.
5 stars 0 forks source link

Cannot rely on expanding memberOf of a user #117

Open barclayadam opened 2 years ago

barclayadam commented 2 years ago

We import users, groups and group memberships to replicate the structure of customer's AAD tenants. We load users using the /users api endpoint, and in addition to providing the properties to $select, we also $expand memberOf.

The problem we are observing is for some users in some tenants (we have been completely unable to determine the pattern for what users) the expanded list is less than the maximum specified (20) BUT they do in fact have many more memberships (for example a user I'm currently investigating returns 14 groups from the expansion, but 22 if I directly hit the /users/{Id}/memberOf endpoint.

Given that no paging (i.e. no next link), or total count information is given in the response it means it is impossible to rely on the expansion, it is completely useless.

Given the above, that means to successfully load all memberships I must, for every user, hit the /memberOf endpoint, which means I go from needing 50 requests (assuming 5k users and default page of 100) to 5050 (users paging + 1 per user/memberOf). Presumably, I could use the batch endpoint, but even still that maxes at 20 requests per hit and therefore I'd still need 300 requests instead of 50, a six-fold increase).

Is this intentional? Are there known reasons for the expansion to be inaccurate? Is there any better way of importing this information in an efficient manner?

petrhollayms commented 2 months ago

Thank you for reporting this issue. This appears to be an issue or limitation with the service APIs. Unfortunately, as the Microsoft Graph SDK team, we do not have ownership of the APIs that are causing you issues. We invite you to create a question about the service API to Microsoft Q&A and tagged with one of the [microsoft-graph-*] tags, that way it will get routed to the appropriate team for them to triage.

Microsoft Graph | Support or https://aka.ms/askgraph

For now, we will close the issue on our side but feel free to open it in the relevant repository if you think the issue is specific to SDK.

Please let us know if this helps!

Note: We will close this repository on April 19, 2024.