Search code examples
azure-active-directorymicrosoft-graph-apioffice365api

Microsoft Graph API: Getting the users who are assigned to a licence


I am trying to get the users assigned to a licence trough the microsoft graph API. Much like on azure

enter image description here

Now thanks to the chrome devtools i found that the following api is called to get this information https://main.iam.ad.ext.azure.com/api/AccountSkus/UserAssignments

Unfortunately trying to access this api is convulted and definitely not suitable for production

I was wondering if there is a way something similar can be done trough the graph api.


Solution

  • https://graph.microsoft.com/beta/users?$select=id,displayName,assignedLicenses,assignedPlans
    

    enter image description here

    You can use the below query by giving LastSignInDateTime and SKU to get the users for a particular assigned licenses SKU

      https://graph.microsoft.com/beta/users?$filter=signInActivity/lastSignInDateTime le 2020-08-01T00:00:00Z&assignedLicenses/any(x:x/skuId eq xxx7a907fd6c235)&$select=displayname
    

    enter image description here