M365 User SignIn Activity – Neither tenant is B2C or tenant doesn’t have premium license

Problem

I encountered the error “Neither tenant is B2C or tenant doesn’t have a premium license” while attempting to retrieve the last sign-in time (signInActivity) of Microsoft 365 users using the Microsoft Graph API.

The Microsoft Graph API used for querying users’ last sign-in activity date is as follows:

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

Received the following error message:

{"error":{"code":"Authentication_RequestFromNonPremiumTenantOrB2CTenant",
"message":"Neither tenant is B2C or tenant doesn't have premium license"}}

Cause & Solution

Retrieving users with their signInActivity property requires a Microsoft Entra ID (Azure AD) P1 or P2 license and the AuditLog.Read.All permission. I have got the token with AuditLog.Read.All permission, but my tenant lacks the necessary (Azure AD P1 or P2) premium license. Learn more about Get users including their last sign-in time.

To prevent this error and obtain the last sign-in time of users, it is essential to assign/activate the Microsoft Entra ID (Azure AD) premium license (P1 or P2) in your Office 365 tenant. If your tenant lacks the required premium license, retrieving users’ sign-in and other related information is not possible.

Advertisement

Leave a Comment