Disable user sign-in for an application

There might be situations while configuring or managing an application where you don't want tokens to be issued for an application. Or, you might want to block an application that you don't want your employees to try to access. To block user access to an application, you can disable user sign-in for the application, which prevents all tokens from being issued for that application.

In this article, you learn how to prevent users from signing in to an application in Microsoft Entra ID through both the Microsoft Entra admin center and PowerShell. If you're looking for how to block specific users from accessing an application, use user or group assignment.

Note

The steps in this article disable user sign-in for a single tenant by setting the service principal's accountEnabled property to false. This also makes the enterprise application's Activation status show Deactivated. The label doesn't necessarily mean that the app registration is deactivated. If you need to disable an application across all tenants, see Deactivate an app registration.

Prerequisites

To disable user sign-in, you need:

  • A Microsoft Entra user account. If you don't already have one, you can Create an account.
  • One of the following roles:
    • Cloud Application Administrator
    • Application Administrator
    • owner of the service principal

Disable user sign-in using the Microsoft Entra admin center

  1. Sign in to the Microsoft Entra admin center as at least a Cloud Application Administrator.
  2. Browse to Entra ID > Enterprise apps > All applications.
  3. Search for the application you want to disable a user from signing in, and select the application.
  4. Select Properties.
  5. Select No for Enabled for users to sign-in?.
  6. Select Save.

Disable user sign-in using Microsoft Entra PowerShell

You might know the AppId of an app that doesn't appear on the Enterprise apps list. For example, if you delete the app or the service principal isn't yet created because Microsoft preauthorizes it. You can manually create the service principal for the app and then disable it by using the following Microsoft Entra PowerShell cmdlet.

Ensure you install the Microsoft Entra PowerShell module. In case you're prompted to install a NuGet module or the new Microsoft Entra PowerShell V2 module, type Y and press ENTER. You need to sign in as at least a Cloud Application Administrator.

# Connect to Microsoft Entra PowerShell
Connect-Entra -Environment China -ClientId 'YOUR_CLIENT_ID' -TenantId 'YOUR_TENANT_ID' -scopes "Application.ReadWrite.All"

# The AppId of the service principal to be disabled
$appId = "{AppId}"

# Disable the service principal
$servicePrincipal = Get-EntraServicePrincipal -Filter "appId eq '$appId'"
Set-EntraServicePrincipal -ObjectId $servicePrincipal.ObjectId -AccountEnabled $false

Disable user sign-in using Microsoft Graph PowerShell

You might know the AppId of an app that doesn't appear on the Enterprise apps list. For example, if you delete the app or the service principal isn't yet created due to the app because Microsoft preauthorizes it. You can manually create the service principal for the app and then disable it by using the following Microsoft Graph PowerShell cmdlet.

Ensure you install the Microsoft Graph module (use the command Install-Module Microsoft.Graph). You need to sign in as at least a Cloud Application Administrator.

# Connect to Microsoft Graph PowerShell
Connect-MgGraph -Environment China -ClientId 'YOUR_CLIENT_ID' -TenantId 'YOUR_TENANT_ID' -Scopes "Application.ReadWrite.All"

# Get the AppId of the service principal to be disabled  
$appId = "{AppId}"  
$servicePrincipal = Get-MgServicePrincipal -Filter "appId eq '$appId'"  

# Disable the service principal
Update-MgServicePrincipal -ServicePrincipalId $servicePrincipal.Id -AccountEnabled:$false 

Restore tenant-local sign-in

Before restoring sign-in, review why it was disabled and confirm that restoring access is appropriate. With the permissions listed in Prerequisites in the affected tenant, set Enabled for users to sign-in? to Yes and select Save. For programmatic updates, set the service principal's accountEnabled property to true instead of false.

Enabling tenant-local sign-in doesn't override app registration deactivation or Microsoft disablement. If Activation status still shows Deactivated, check the other conditions described in Activation status.