Is there an API in Microsoft Azure where I can identify if a user is inactive or logged out of Tenant

Tiwari, Vaibhav 1 Reputation point
2024-03-14T07:24:31.9766667+00:00

Hi

I could find a MS graph sign API which gives me last signin datetime but could not find API which can give me last signout time or how long a user is inactive.

Sign in API - https://graph.microsoft.com/v1.0/auditLogs/signIns

PLease can someone suggest how can I identify if a user is inactive or logged out of MS azure tenant

Thanks

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,448 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Danstan Onyango 3,736 Reputation points Microsoft Employee
    2024-03-26T12:37:47.1233333+00:00

    Microsoft Entra does not provide a direct API to determine if a user is inactive or has logged out of the tenant. The reason for this is the nature of token-based authentication used by Entra. When a user signs out, it does not necessarily invalidate their token - the token will continue to be valid until it expires.

    The SignIn logs from Microsoft Graph API can be used to find when a user last signed in, but it doesn't track when a user signs out or if a user is inactive.

    Some suggestions to try can be using User Presence Information If you're using Teams - https://graph.microsoft.com/beta/users/{id}/presence or using Entra audit logs to check for recent activities - https://docs.microsoft.com/en-us/graph/api/resources/azure-ad-auditlog-overview?view=graph-rest-1.0

    That said, I would suggest a review of the action that requires you to check if a user is active. Often times if a user should not be active, an admin can invalidate all logins. See https://learn.microsoft.com/en-us/entra/identity/users/users-revoke-access.

    0 comments No comments