Using gMSA
Overview
Let’s set an example where we have a Windows Server 2019 machine named WEB01 and we have multiple IIS sites running; in particular we have one called MySite that we want to have access to a network share. To do this we will create a Group Managed Service Account (gMSA) called gmsa-mysite and assign it to the application pool of MySite.
Procedure
- Create the Security Group. We will create a security group in Active Directory that will contain the IIS server(s) that will be using the gMSA.
New-ADGroup -Name "gmsa-mysite-group" -GroupScope Global -GroupCategory Security -Path "OU=Groups,DC=yourdomain,DC=com"- Add the IIS server to the security group.
Add-ADGroupMember -Identity "gmsa-mysite-group" -Members "WEB01$"- Create gMSA. Now we will create the gMSA and specify that only members of the security group we just created can retrieve the password for the gMSA.
New-ADServiceAccount -Name gmsa-mysite -DNSHostName gmsa-mysite.yourdomain.com -PrincipalsAllowedToRetrieveManagedPassword "gmsa-mysite-group"Grant Permissions to the gMSA. Ensure that the gMSA has the necessary permissions to access the network share. You can do this by adding the gMSA to the appropriate security group or directly granting it access to the share.
Reboot or purge the Kerberos ticket cache on IIS server. After creating the gMSA, you may need to reboot the IIS server or purge the Kerberos ticket cache to ensure that the server is aware of its new security group and gMSA membership. You can purge the Kerberos ticket cache by running the following commands in an elevated PowerShell prompt:
klist -li 0x3e7 purge
gpupdate /force- Test the gMSA account on the IIS server. Before configuring the application pool, test that the gMSA can be used on the IIS server by running:
Test-ADServiceAccount -Identity gmsa-mysiteYou should see a result of True, indicating that the gMSA password can be retrieved and used on the IIS server.
- Configure the Application Pool
Open IIS Manager, navigate to the application pool for
MySite, and change the identity to use the gMSA. In the “Advanced Settings” of the application pool, set the “Identity” to “Custom account” and enter the gMSA in the formatdomain\\gmsa-mysite$.
$ when specifying the gMSA account in IIS.