This is regarding an application where we are using Azure B2C tenant for authentication. There is a requirement to get lists of users which would support filtering, pagination and users have to be from a particular TenantId. We are using Graph API SDK that i.e., microsoft.graph and microsoft.graph.Auth packages.
Steps I have done
- Created graph client with ClientCredentialProvider with TenantId.
- Getting users using the below code
var users = await graphClient.Users
.Request()
.Top(100)
.Filter("identities/any(c:c/issuer eq 'contoso.onmicrosoft.com')")
.Select("displayName,id,identities")
.GetAsync();
This gets all users for a given issuer or tenant. Now, there is an issue I cannot filter users using this option .Filter("identities/any(c:c/issuer eq 'contoso.onmicrosoft.com') and startswith(displayName,'a')
i.e., get all users whose display name starts with 'a' and belong to this issuer 'contoso.onmicrosoft.com'. As per Microsoft, Graph API does not currently support complex queries on Identities. They show this message Message: Complex query on property identities is not supported.
Now, right now my thoughts are limited to this option of loading entire user table for this tenant onto memory. I think this would be not the best approach, because we will have more tenants and I don't know how much users we can store in memory.
Anyone who has more understanding on these type of scenarios, please share your inputs. I wanted to know various other alternatives we could take.