Graph API and Azure AD - efficiently getting latest signIn per user?

BenediktSnow 21 Reputation points
2022-12-19T10:56:29.13+00:00

I am developing an integration with Graph API for getting data on users from Azure AD.

As I want to get the last login - and last login activity is not included in the User resource - I am making additional requests to the auditLogs/signIns endpoint and matching the signIns with users. (https://learn.microsoft.com/en-us/graph/api/signin-list?view=graph-rest-1.0&tabs=http)

For a large group of users, there is a huge amount of signIns data from the last 30 days, and the process is taking a long time.

The signIns endpoint does not support the $Select query params, so I am unable to limit the data received to the two fields I need (userPrincipalName and createdDateTime). I also cannot see any way of using the $filter param to only receive the latest signIn per user.

Is there any way of achieving this that I'm not seeing?

Microsoft Security | Microsoft Entra | Microsoft Entra ID
0 comments No comments
{count} votes

Answer accepted by question author
  1. Harpreet Singh Matharoo 8,416 Reputation points Microsoft Employee Moderator
    2022-12-19T12:41:01.43+00:00

    Hello @BenediktSnow

    Thank you for reaching out. I would like to confirm we can query last sign-in activity on user using Graph API select parameter, however you would need to use beta version and following query:

    GET https://graph.microsoft.com/beta/users?$select=displayName,userPrincipalName,signInActivity

    Following is the output screen on Graph explorer which confirms that it returns last login activity of the user:
    272065-image.png

    I hope this helps.

    ----------

    Please "Accept the answer" if the information helped you. This will help us and others in the community as well.


1 additional answer

Sort by: Most helpful
  1. BenediktSnow 21 Reputation points
    2022-12-21T13:17:54.417+00:00

    Thank you for clarifying the limitations of Graph API V1 as of now.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.