How to detect and investigate inactive user accounts

In large environments, user accounts aren't always deleted when employees leave an organization. As an IT administrator, you want to detect and resolve these obsolete user accounts because they represent a security risk.

This article explains a method to handle obsolete user accounts in Microsoft Entra ID.

Note

This article applies only to finding inactive user accounts in Microsoft Entra ID. It does not apply to finding inactive accounts in Azure AD B2C.

Prerequisites

To access the lastSignInDateTime property using Microsoft Graph:

  • You need a Microsoft Entra ID P1 or P2 license.

  • You need to grant the app the following Microsoft Graph permissions:

    • AuditLog.Read.All
    • User.Read.All
  • Reports Reader is the least privileged role required to access the activity logs.

What are inactive user accounts?

Inactive accounts are user accounts that aren't required anymore by members of your organization to gain access to your resources. One key identifier for inactive accounts is that they haven't been used for a while to sign in to your environment. Because inactive accounts are tied to the sign-in activity, you can use the timestamp of the last time an account attempted to sign in to detect inactive accounts.

The challenge of this method is to define what for a while means for your environment. For example, users might not sign in to an environment for a while, because they are on vacation. You need to consider all legitimate reasons for not signing in to your environment. In many organizations, a reasonable window for inactive user accounts is between 90 and 180 days.

The last sign-in date provides potential insights into a user's continued need for access to resources. It can help with determining if group membership or app access is still needed or could be removed. For external user management, you can determine if an external user is still active within the tenant or should be removed.

How to find inactive user accounts

You can use the Microsoft Entra admin center or the Microsoft Graph API to find inactive user accounts. While there isn't a built-in report for inactive user accounts, you can use the last sign-in date and time to determine if a user account is inactive.

To find the last sign-in time for a user, you can look at your user list in the Microsoft Entra admin center. While all users can see the list of users, some columns and details are only available to users with the appropriate permissions.

  1. Sign in to the Microsoft Entra admin center as at least a Reports Reader.

  2. Browse to Identity > Users > All users.

  3. Select Manage view and then Edit columns.

    Screenshot of the Users view with the manage view option highlighted.

  4. From the list, select + Add column, select Last interactive sign-in time from the list, then select Save.

    Screenshot of the Edit columns pane with the Last interactive sign-in time option highlighted.

  5. With the column now visible in the all users list, select Add filter and set a time frame for your search using the filter options.

    • Select < = as the Operator, then select the date to find the last sign-in before that selected date.

Screenshot of the last sign-in filter results.

How to investigate a single user in the Microsoft Entra admin center

If you need to view the latest sign-in activity for a user, you can view the user's sign-in details in Microsoft Entra ID. You can also use the Microsoft Graph users by name scenario described in the previous section.

  1. Sign in to the Microsoft Entra admin center as at least a Reports Reader.

  2. Browse to Identity > Users > All users.

  3. Select a user from the list.

  4. In the My Feed area of the user's Overview, locate the Sign-ins tile.

    Screenshot of the user overview page with the sign-in activity tile highlighted.

The last sign-in date and time shown on this tile might take up to 24 hours to update, which means the date and time might not be current. If you need to see the activity in near real time, select the See all sign-ins link on the Sign-ins tile to view all sign-in activity for that user.