跳到正文
DEV Community· Cloudek Hosting·· 2 小時前AI 評分54

如何透過 Entra ID 管理中心與 Graph Explorer 唯讀找出閒置帳戶及訪客

Find stale accounts and guests in Entra ID with the portal and Graph Explorer (read-only)

AI 導讀

文章提供一套唯讀流程,教用戶透過 Entra ID 管理中心及 Graph Explorer 找出閒置帳戶、訪客和未接受的邀請。

正文

Some AI (AI-assisted): this article was drafted with AI assistance and reviewed and edited by a person. Microsoft statements were checked against Microsoft Learn on 22 November 2026.

Accounts outlive the people they were made for. A leaver whose account was never closed, a contractor's guest invite from two years ago: each is an extra way in that nobody is watching. Microsoft says there is no built-in report for inactive user accounts, so you build one from the last sign-in date.

This is a half-hour, read-only way to do it. You need a licence note, one portal view, four GET queries in Graph Explorer, and a few traps to avoid.

Before you start

  • Licence. Microsoft says reading lastSuccessfulSignInDateTime through Microsoft Graph needs Microsoft Entra ID P1 or P2.
  • Role. For the portal steps, Reports Reader is the least privileged role Microsoft names for the activity logs.
  • Graph permissions. Listing users with signInActivity needs AuditLog.Read.All and a user-read permission such as User.Read.All. Both are read permissions.
  • Cut-off. Microsoft says a reasonable window for many organisations is 90 to 180 days. Pick it before you look at the list, because people go on leave.

Step 1: the portal view

  1. In the Microsoft Entra admin centre go to Entra ID > Users.
  2. Select Manage view, then Edit columns, then + Add column, choose Last interactive sign-in time, and Save.
  3. Select Add filter on that column, choose the <= operator and a date.

Two cautions from Microsoft: the value can take up to 24 hours to update, and it can be blank if the account never attempted a sign-in or its last attempt was before April 2020. Blank means look closer, not delete.

Step 2: Graph Explorer, GET only

Graph Explorer is Microsoft's browser tool for trying Graph requests. Microsoft warns that if you sign in with an organisational account, a write request can change the tenant. So leave the method on GET, and when a query asks for permission, use Modify permissions to consent to AuditLog.Read.All and User.Read.All only.

Everyone, with their sign-in dates:

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

With signInActivity selected, Microsoft says a page holds at most 500 users, so follow @odata.nextLink for more. This is also how you find blanks.

Users whose last successful sign-in is before a date (24 August 2026 is 90 days before this article was checked):

GET https://graph.microsoft.com/v1.0/users?$filter=signInActivity/lastSuccessfulSignInDateTime le 2026-08-24T00:00:00Z

Read the properties carefully:

  • lastSignInDateTime is the last interactive sign-in attempt, successful or not. Microsoft says it may not reflect real usage, because failed attempts count.
  • lastSuccessfulSignInDateTime covers interactive and non-interactive successes, but Microsoft says it is not backfilled from before 1 December 2023.
  • Microsoft says signInActivity supports filtering but not together with other filterable properties, so you cannot ask for "guests inactive since August" in one filter. Query separately and combine.

Step 3: guests

GET https://graph.microsoft.com/v1.0/users?$filter=userType eq 'Guest'&$select=displayName,mail,createdDateTime,externalUserState,signInActivity

Microsoft documents userType as Member or Guest, filterable with eq. Its pages do not say whether selecting signInActivity alongside that filter is allowed, so if Graph rejects it, drop signInActivity from $select and look guests up individually.

GET https://graph.microsoft.com/v1.0/users?$filter=externalUserState eq 'PendingAcceptance'&$select=displayName,mail,createdDateTime,externalUserStateChangeDateTime

This finds invitations nobody accepted. Microsoft says externalUserState is set for guests invited through the invitation API, so guests created another way may not appear.

For a report without queries, go to ID Governance > Dashboard, find the Guest access governance card and select View inactive guests. Microsoft says it uses 90 days by default, counts from the creation date for guests who never signed in, refreshes daily and can be downloaded. It needs Entra ID Governance or the Entra Suite, so on P1 alone the Graph queries are your route.

Step 4: decide with people, not a script

Microsoft's questions for each inactive user: is the person still employed, do they still need access, is the account needed for another reason? Add two practical ones. Is it a shared, service or emergency access account that rarely signs in by design? Could failed attempts, perhaps an attacker's, be refreshing the date on an account nobody uses?

When you do act, Microsoft's access review pattern for stale guests is to block sign-in for 30 days and then remove the user, and it says a deleted guest can be restored for up to 30 days. Access reviews of inactive guests need Entra ID Governance or the Entra Suite. A named person makes any change; nothing above changes a tenant.

Licences at a glance

Step Needs
Last sign-in column, Graph sign-in dates Entra ID P1 or P2
Guest and pending-invitation queries A user-read permission
Inactive guest report, access reviews of inactive guests Entra ID Governance or Entra Suite

An empty result can mean "nothing stale" or "this cannot be seen with your licence". Write down which steps you could run.

See it before you talk to anyone

I work on OpsPilot at Cloudek, a read-only Microsoft 365 review workspace. The interactive demo runs in your browser with sample data: nothing to install and no tenant connected.

Two of its sixteen Live read-only reviews cover this ground, a Stale accounts review and an Identity security review (which looks at idle and guest accounts, among other things). Findings come in plain English with the evidence behind them, graded A to F, and where a check needs a licence you do not have the result says "Not checked: needs ..." instead of passing. OpsPilot reads and reports, never changes your tenant.

Customer access is an invitation-only free trial: 30 days, one organisation of up to 250 users, read-only. To ask for an invitation, email info@cloudekhosting.com. You never need to send tenant data to start.

Open the live demo

Sources (Microsoft Learn): How to manage inactive user accounts; Monitor and clean up stale guest accounts; signInActivity resource type; List users; user resource type; Use Graph Explorer to try Microsoft Graph APIs. Full guide with sources: https://www.cloudekhosting.com/blog/find-stale-accounts-and-guests-entra-id-read-only.html

來源:DEV Community · dev.to