Configure a gMSA directory service account for Defender for Identity
In brief
The instructions now cover multi-domain and multi-forest deployments, require Enterprise Admin permissions when using a root-level group and single gMSA, and document KDS root-key replication timing and group-scope options.
What Defender admins need to know
For applicable deployments, use the required permissions and allow 10 hours for KDS replication. Use the accelerated key timing only in single-domain-controller test environments, not production.
Summaries are generated from the documentation change itself.
Documentation change
The comparison below shows only the changed extract. Use the full-page view for complete context.
Configure a gMSA directory service account for Defender for Identity
Create and configure a group managed service account (gMSA) for the sensor v2.x to use when reading Active Directory data (querying objects, tracking changes, resolving entities). This is separate from the action account used to perform remediation actions like disabling users or resetting passwords. Before you begin, review the prerequisites for creating a gMSA for sensor v2.x deployments.
Choose how to configure password retrieval:
Assign the gMSA account directly to each of the sensors.
Use a group that contains all the sensors that need to use the gMSA account.
Choose the appropriate group based on your deployment:
Single-forest, single-domain deployment:
- Use the built-in Domain Controllers security group if you're not installing sensors on Active Directory Federation Services (AD FS) or Active Directory Certificate Services (AD CS) servers.
Forest with multiple domains:
If you use a single Directory service account (DSA), we recommend creating a universal group and adding each of the domain controllers and AD FS or AD CS servers to the universal group.
In multi-forest or multi-domain environments, make sure the domain where you create the gMSA trusts the sensors’ computer accounts.
Option 1: Use a gMSA per domain. Create a Domain Local group in each domain that includes only the sensors computer accounts from that domain so that only those sensors can retrieve the gMSAs' passwords and perform the local domain authentications.
Option 2: Use ashared gMSA across all domains. Create a Universal group at forest root that includes all sensors computer accounts so that all sensors can retrieve the gMSAs' password and perform the cross-domain authentications.
Create the gMSA account
If you've never used a gMSA account before, you might need to generate a new root key for the Microsoft Group Key Distribution Service (KdsSvc) within Active Directory. This step is required only once per forest. To generate a new root key for immediate use, run the following command:
Add-KdsRootKey -EffectiveImmediatelyAlthough the command name suggests that the key takes effect immediately, wait 10 hours for the KDS root key to replicate and become available on all domain controllers.
If your test domain has only one domain controller, you can expedite the process by setting the key's effective time to 10 hours earlier.
```powershell
# For single-DC test environments only
Add-KdsRootKey -EffectiveTime (Get-Date).AddHours(-10)
```
Run the PowerShell commands as an administrator. This script will:
- Create a gMSA account.
- Create a group for the gMSA account.
- Add the specified computer accounts to that group.
- Configure the gMSA to use AES128 and AES256 Kerberos encryption.
Before running the script:
- Update the variable values to match your environment.
- Make sure to give each gMSA a unique name for each forest or domain.
Define the gMSA creation variables, including the account name, host group, and computer accounts, then run the following script to provision the gMSA:
# Variables:
# Specify the name of the gMSA you want to create:
if ($gMSA_HostsGroupName -eq 'Domain Controllers') {
$gMSA_HostsGroup = Get-ADGroup -Identity 'Domain Controllers'
} else {
# If this group is being created at the root of a forest and will be used across multiple domains or subdomains then the -GroupScope parameter should be changed to Universal
$gMSA_HostsGroup = New-ADGroup -Name $gMSA_HostsGroupName -GroupScope DomainLocal -PassThru
$gMSA_HostNames | ForEach-Object { Get-ADComputer -Identity $_ } |
ForEach-Object { Add-ADGroupMember -Identity $gMSA_HostsGroupName -Members $_ }
}
# Specify the Kerberos encryption type as AES.
$kerberosEncType = ('AES128','AES256')
# Create the gMSA:
New-ADServiceAccount -Name $gMSA_AccountName -DNSHostName "$gMSA_AccountName.$env:USERDNSDOMAIN" `
-PrincipalsAllowedToRetrieveManagedPassword $gMSA_HostsGroup -KerberosEncryptionType $kerberosEncType
Grant required directory service account permissions
The directory service account requires specific read permissions on Active Directory objects so that the sensor can query directory data. The following include details the required permissions and how to grant them:
[!INCLUDE dsa-permissions]
Verify that the gMSA account has the required rights
The Defender for Identity sensor service, Azure Advanced Threat Protection Sensor, runs as a LocalService that impersonates the DSA account. If the Log on as a service policy is configured but the permission wasn't granted to the gMSA account, the impersonation fails. In that case, you see the following health issue: Directory services user credentials are incorrect.
If you see this alert,the health issue Directory services user credentials are incorrect, check to see if the Log on as a service policy is configured either in a Group Policy setting or in a Local Security Policy.
Check the Local Security Policy
Troubleshooting
For more information, see Sensor failed to retrieve the gMSA credentials.
@@ -1,16 +1,16 @@ --- title: Configure a gMSA directory service account for Defender for Identity description: Create and configure a group managed service account (gMSA) for use as the Directory service account in Microsoft Defender for Identity.-ms.date: 06/15/2026+ms.date: 08/03/2026 ms.topic: how-to ms.reviewer: rlitinsky-ms.custom: sfi-image-nochange, msecd-doc-authoring-1014+ms.custom: sfi-image-nochange, msecd-doc-authoring-1015 ai-usage: ai-assisted --- # Configure a gMSA directory service account for Defender for Identity -Create and configure a [group managed service account (gMSA)](/windows-server/security/group-managed-service-accounts/getting-started-with-group-managed-service-accounts) for the sensor v2.x to use when reading Active Directory data (querying objects, tracking changes, resolving entities). This is separate from the [action account](manage-action-accounts.md) used to perform remediation actions like disabling users or resetting passwords.+Create and configure a [group managed service account (gMSA)](/windows-server/security/group-managed-service-accounts/getting-started-with-group-managed-service-accounts) for the sensor v2.x to use when reading Active Directory data (querying objects, tracking changes, resolving entities). This is separate from the [action account](manage-action-accounts.md) used to perform remediation actions like disabling users or resetting passwords. Before you begin, review the [prerequisites](#prerequisites) for creating a gMSA for sensor v2.x deployments. > [!IMPORTANT] > This configuration applies to the sensor v2.x only. The sensor v3.x uses LocalSystem for all AD interactions and doesn't require a gMSA or any other Directory Service Account. If all your sensors are v3.x, skip this page.@@ -25,40 +25,64 @@ Before you create the gMSA account, make sure the following prerequisites are me - Choose how to configure password retrieval: - - Assign the gMSA account directly to each of the sensors.-- - Use a group that contains all the sensors that need to use the gMSA account.-+ - Assign the gMSA account directly to each of the sensors.+ + - Use a group that contains all the sensors that need to use the gMSA account.+ - Choose the appropriate group based on your deployment: - - **Single-forest, single-domain deployment**: Use the built-in Domain Controllers security group if you're not installing sensors on Active Directory Federation Services (AD FS) or Active Directory Certificate Services (AD CS) servers.+ - **Single-forest, single-domain deployment**: + + - Use the built-in Domain Controllers security group if you're not installing sensors on Active Directory Federation Services (AD FS) or Active Directory Certificate Services (AD CS) servers.+ + - **Forest with multiple domains**: + + - If you use a single Directory service account (DSA), we recommend creating a universal group and adding each of the domain controllers and AD FS or AD CS servers to the universal group.+ + - In multi-forest or multi-domain environments, make sure the domain where you create the gMSA trusts the sensors’ computer accounts.+ + - **Option 1**: Use a gMSA per domain. Create a Domain Local group in each domain that includes only the sensors computer accounts from that domain so that only those sensors can retrieve the gMSAs' passwords and perform the local domain authentications.+ + - **Option 2**: Use ashared gMSA across all domains. Create a Universal group at forest root that includes all sensors computer accounts so that all sensors can retrieve the gMSAs' password and perform the cross-domain authentications.+ +## Create the gMSA account - - **Forest with multiple domains**: If you use a single Directory service account (DSA), we recommend creating a universal group and adding each of the domain controllers and AD FS or AD CS servers to the universal group.+> [!IMPORTANT]+> If you are working in a single forest with multiple domains or sub domains and you intend to use a single gMSA account and single group at the root level, then the steps in this section must be performed with an account that has Enterprise Admin permissions. -- In multi-forest or multi-domain environments, make sure the domain where you create the gMSA trusts the sensors’ computer accounts.+1. If you've never used a gMSA account before, you might need to generate a new root key for the Microsoft Group Key Distribution Service (KdsSvc) within Active Directory. This step is required only once per forest.+ To generate a new root key for immediate use, run the following command: -- Create a universal group in each domain that contains sensor computer accounts so that all sensors can retrieve the gMSAs' passwords and perform cross-domain authentications.+ ```powershell+ Add-KdsRootKey -EffectiveImmediately+ ``` + Although the command name suggests that the key takes effect immediately, wait 10 hours for the KDS root key to replicate and become available on all domain controllers. -## Create the gMSA account+ If your test domain has only one domain controller, you can expedite the process by setting the key's effective time to 10 hours earlier. -1. If you've never used a gMSA account before, you might need to generate a new root key for the Microsoft Group Key Distribution Service (KdsSvc) within Active Directory. This step is required only once per forest.- To generate a new root key for immediate use, run the following command:+ > [!IMPORTANT]+ > Don't use this technique in a production environment. ```powershell- Add-KdsRootKey -EffectiveImmediately+ # For single-DC test environments only+ Add-KdsRootKey -EffectiveTime (Get-Date).AddHours(-10) ``` -1. Run the PowerShell commands as an administrator. This script will: +1. Run the PowerShell commands as an administrator. This script will:+ - Create a gMSA account. - Create a group for the gMSA account. - Add the specified computer accounts to that group.+ - Configure the gMSA to use AES128 and AES256 Kerberos encryption. -1. Before running the script: +1. Before running the script: - Update the variable values to match your environment. - Make sure to give each gMSA a unique name for each forest or domain. +Define the gMSA creation variables, including the account name, host group, and computer accounts, then run the following script to provision the gMSA:+ ```powershell # Variables: # Specify the name of the gMSA you want to create:@@ -77,14 +101,18 @@ Import-Module ActiveDirectory if ($gMSA_HostsGroupName -eq 'Domain Controllers') { $gMSA_HostsGroup = Get-ADGroup -Identity 'Domain Controllers' } else {+ # If this group is being created at the root of a forest and will be used across multiple domains or subdomains then the -GroupScope parameter should be changed to Universal $gMSA_HostsGroup = New-ADGroup -Name $gMSA_HostsGroupName -GroupScope DomainLocal -PassThru $gMSA_HostNames | ForEach-Object { Get-ADComputer -Identity $_ } | ForEach-Object { Add-ADGroupMember -Identity $gMSA_HostsGroupName -Members $_ } } +# Specify the Kerberos encryption type as AES.+$kerberosEncType = ('AES128','AES256')+ # Create the gMSA: New-ADServiceAccount -Name $gMSA_AccountName -DNSHostName "$gMSA_AccountName.$env:USERDNSDOMAIN" `- -PrincipalsAllowedToRetrieveManagedPassword $gMSA_HostsGroup+ -PrincipalsAllowedToRetrieveManagedPassword $gMSA_HostsGroup -KerberosEncryptionType $kerberosEncType ``` @@ -102,13 +130,15 @@ To refresh the Kerberos ticket, you can: ## Grant required directory service account permissions +The directory service account requires specific read permissions on Active Directory objects so that the sensor can query directory data. The following include details the required permissions and how to grant them:+ [!INCLUDE [dsa-permissions](../includes/dsa-permissions.md)] ## Verify that the gMSA account has the required rights The Defender for Identity sensor service, *Azure Advanced Threat Protection Sensor*, runs as a *LocalService* that impersonates the DSA account. If the *Log on as a service* policy is configured but the permission wasn't granted to the gMSA account, the impersonation fails. In that case, you see the following health issue: **Directory services user credentials are incorrect.** -If you see this alert, check to see if the *Log on as a service policy* is configured either in a Group Policy setting or in a Local Security Policy.+If you see the health issue **Directory services user credentials are incorrect**, check to see if the *Log on as a service policy* is configured either in a Group Policy setting or in a Local Security Policy. ### Check the Local Security Policy @@ -180,5 +210,3 @@ To connect your sensors with your Active Directory domains, configure Directory ## Troubleshooting For more information, see [Sensor failed to retrieve the gMSA credentials](../troubleshooting-known-issues.md#sensor-failed-to-retrieve-group-managed-service-account-gmsa-credentials).-- 