Namespace: microsoft.graph.security
Important
APIs under the /beta version in Microsoft Graph are subject to change. Use of these APIs in production applications is not supported. To determine whether an API is available in v1.0, use the Version selector.
Perform actions such as revoking accounts and forcing password reset for identity accounts that are observed in Microsoft Defender for Identity. This action allows reading and performing identity security actions on behalf of the signed-in identity.
This API is available in the following national cloud deployments.
| Global service |
US Government L4 |
US Government L5 (DOD) |
China operated by 21Vianet |
| ✅ |
✅ |
✅ |
❌ |
Permissions
One of the following permissions is required to call this API. Choose the permission or permissions marked as least privileged for this API. Use a higher privileged permission or permissions only if your app requires it. For details about delegated and application permissions, see Permission types. To learn more about these permissions, see the permissions reference.
| Permission type |
Permissions (least privileged listed first) |
| Delegated (work or school account) |
SecurityIdentitiesActions.ReadWrite.All |
| Delegated (personal Microsoft account) |
Not supported. |
| Application |
SecurityIdentitiesActions.ReadWrite.All |
Important
In delegated scenarios with work or school accounts, the signed-in user must be assigned a supported Microsoft Entra role or a custom role with a supported role permission. Security Administrator is the least privileged role supported for this operation.
HTTP request
POST /security/identities/identityAccounts/{identityAccountsId}/invokeAction
Request body
In the request body, supply a JSON representation of the parameters.
The following table lists the parameters that are required when you call this action.
| Parameter |
Type |
Description |
| accountId |
String |
The identifier of the account to perform the action on. |
| action |
microsoft.graph.security.action |
The type of action to perform on the account. The possible values are: disable, enable, forcePasswordReset, revokeAllSessions, requireUserToSignInAgain, markUserAsCompromised. |
| identityProvider |
microsoft.graph.security.identityProvider |
The identity provider associated with the account. The possible values are: entraID, activeDirectory, okta. |
The following table shows the identity providers supported for each action value type:
| Action Value |
Description |
Supported identity providers |
| Disable |
Disable account. The account is unable to authenticate. If the account recently logged in, it doesn't have access to resources. |
activeDirectory, okta |
| Enable |
Enable account. |
activeDirectory, okta |
| ForcePasswordReset |
Force password reset of the account. |
activeDirectory |
| RevokeAllSessions |
Revoke all of active sessions for the account. |
okta |
Response
If successful, this action returns a 200 OK response code and a invokeActionResult in the response body.
Examples
Request
The following example shows a request.
POST https://graph.microsoft.com/beta/security/identities/identityAccounts/0104216-0539-4838-88b1-55baafdc296b/invokeAction
Content-Type: application/json
{
"accountId": "256db173-930a-4991-9061-0d51a9a93ba5",
"action": "disable",
"identityProvider": "activeDirectory"
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Security.Identities.IdentityAccounts.Item.MicrosoftGraphSecurityInvokeAction;
using Microsoft.Graph.Beta.Models.Security;
var requestBody = new InvokeActionPostRequestBody
{
AccountId = "256db173-930a-4991-9061-0d51a9a93ba5",
Action = ActionObject.Disable,
IdentityProvider = IdentityProvider.ActiveDirectory,
};
// To initialize your graphClient, see https://free.blessedness.top/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Security.Identities.IdentityAccounts["{identityAccounts-id}"].MicrosoftGraphSecurityInvokeAction.PostAsync(requestBody);
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphsecurity "github.com/microsoftgraph/msgraph-beta-sdk-go/security"
graphmodelssecurity "github.com/microsoftgraph/msgraph-beta-sdk-go/models/security"
//other-imports
)
requestBody := graphsecurity.NewInvokeActionPostRequestBody()
accountId := "256db173-930a-4991-9061-0d51a9a93ba5"
requestBody.SetAccountId(&accountId)
action := graphmodels.DISABLE_ACTION
requestBody.SetAction(&action)
identityProvider := graphmodels.ACTIVEDIRECTORY_IDENTITYPROVIDER
requestBody.SetIdentityProvider(&identityProvider)
// To initialize your graphClient, see https://free.blessedness.top/en-us/graph/sdks/create-client?from=snippets&tabs=go
microsoftGraphSecurityInvokeAction, err := graphClient.Security().Identities().IdentityAccounts().ByIdentityAccountsId("identityAccounts-id").MicrosoftGraphSecurityInvokeAction().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
com.microsoft.graph.beta.security.identities.identityaccounts.item.microsoftgraphsecurityinvokeaction.InvokeActionPostRequestBody invokeActionPostRequestBody = new com.microsoft.graph.beta.security.identities.identityaccounts.item.microsoftgraphsecurityinvokeaction.InvokeActionPostRequestBody();
invokeActionPostRequestBody.setAccountId("256db173-930a-4991-9061-0d51a9a93ba5");
invokeActionPostRequestBody.setAction(com.microsoft.graph.beta.models.security.Action.Disable);
invokeActionPostRequestBody.setIdentityProvider(com.microsoft.graph.beta.models.security.IdentityProvider.ActiveDirectory);
var result = graphClient.security().identities().identityAccounts().byIdentityAccountsId("{identityAccounts-id}").microsoftGraphSecurityInvokeAction().post(invokeActionPostRequestBody);
const options = {
authProvider,
};
const client = Client.init(options);
const invokeActionResult = {
accountId: '256db173-930a-4991-9061-0d51a9a93ba5',
action: 'disable',
identityProvider: 'activeDirectory'
};
await client.api('/security/identities/identityAccounts/0104216-0539-4838-88b1-55baafdc296b/invokeAction')
.version('beta')
.post(invokeActionResult);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Security\Identities\IdentityAccounts\Item\MicrosoftGraphSecurityInvokeAction\InvokeActionPostRequestBody;
use Microsoft\Graph\Beta\Generated\Models\Security\Action;
use Microsoft\Graph\Beta\Generated\Models\Security\IdentityProvider;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new InvokeActionPostRequestBody();
$requestBody->setAccountId('256db173-930a-4991-9061-0d51a9a93ba5');
$requestBody->setAction(new Action('disable'));
$requestBody->setIdentityProvider(new IdentityProvider('activeDirectory'));
$result = $graphServiceClient->security()->identities()->identityAccounts()->byIdentityAccountsId('identityAccounts-id')->microsoftGraphSecurityInvokeAction()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Security
$params = @{
accountId = "256db173-930a-4991-9061-0d51a9a93ba5"
action = "disable"
identityProvider = "activeDirectory"
}
Invoke-MgBetaInvokeSecurityIdentityAccountAction -IdentityAccountsId $identityAccountsId -BodyParameter $params
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.security.identities.identityaccounts.item.microsoft_graph_security_invoke_action.invoke_action_post_request_body import InvokeActionPostRequestBody
from msgraph_beta.generated.models.action import Action
from msgraph_beta.generated.models.identity_provider import IdentityProvider
# To initialize your graph_client, see https://free.blessedness.top/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = InvokeActionPostRequestBody(
account_id = "256db173-930a-4991-9061-0d51a9a93ba5",
action = Action.Disable,
identity_provider = IdentityProvider.ActiveDirectory,
)
result = await graph_client.security.identities.identity_accounts.by_identity_accounts_id('identityAccounts-id').microsoft_graph_security_invoke_action.post(request_body)
Response
The following example shows the response.
Note: The response object shown here might be shortened for readability.
HTTP/1.1 200 OK
Content-Type: application/json
{
"value":
{
"accountId": "256db173-930a-4991-9061-0d51a9a93ba5",
"action": "disable",
"provider": "activeDirectory",
"correlationId": "ed2f052b-2a01-4cd9-acb3-f6145f83e1a5"
}
}
Note
Actions related to Entra ID are not covered in the current scope.