Create an Active Directory Managed Service Account for NIM
Microsoft Active Directory guide
Create a single-computer Active Directory managed service account (MSA) for the Tools4ever NIM Service, test it on the NIM server, and grant the required directory and local service permissions.
At a glanceDirect link to At a glance
This procedure creates an MSA for one NIM server using New-ADServiceAccount -RestrictToSingleComputer. Link the account to that server, install it locally, and confirm that Test-ADServiceAccount returns True. Then delegate permissions to the organizational units and object types NIM needs to manage, grant local NIM Service control, and assign the account to the NIM Windows service. The MSA does not need local administrator membership.
MSA or gMSA? The commands below create a single-computer MSA. A group managed service account (gMSA) is a different account type; see Microsoft's New-ADServiceAccount account types and examples before choosing a procedure for your environment.
Before you beginDirect link to Before you begin
Microsoft's group managed service account guidance provides background on managed credentials and service account ownership. This guide creates a single-computer MSA with -RestrictToSingleComputer; confirm which managed account type your environment requires before following the commands. In either case, delegate directory rights separately to the scope NIM manages.
| Requirement | Check before continuing |
|---|---|
| Account type | Use a single-computer MSA for this procedure. Do not use these commands as a gMSA setup guide. |
| NIM server | Identify the domain-joined Windows server that will host the account. Install and test the MSA on that server. |
| PowerShell module | Run Get-Module -ListAvailable ActiveDirectory. If the module is missing, have the server administrator install the Active Directory PowerShell management tools. |
| Permissions | Use an elevated PowerShell session on the NIM server. The executing account also needs delegated directory permissions to create the MSA and associate it with the computer; local administrator rights alone do not grant those AD permissions. |
| Account and computer names | Choose an unused account name and confirm the NIM server's AD computer name. |
| Delegation scope | Identify the organizational units and object types NIM will manage. Grant those rights separately after creating the account. |
Create and install the service accountDirect link to Create and install the service account
1. Create the managed service accountDirect link to 1. Create the managed service account
New-ADServiceAccount -Name <NAMEOFACCOUNT> -RestrictToSingleComputer
Where the managed service account is storedDirect link to Where the managed service account is stored
By default, the MSA is created in the domain's Managed Service Accounts container, such as CN=Managed Service Accounts,DC=example,DC=com. Use the -Path parameter on New-ADServiceAccount to select a different container or organizational unit. -RestrictToSingleComputer selects the single-computer account type.
2. Link the account to the NIM serverDirect link to 2. Link the account to the NIM server
Replace <NIMSERVERNAMEHERE> with the name of the NIM server and <NAMEOFACCOUNT> with the MSA you created.
$TargetServer = Get-ADComputer -Identity <NIMSERVERNAMEHERE>
Add-ADComputerServiceAccount -Identity $TargetServer -ServiceAccount <NAMEOFACCOUNT>
3. Verify and install the accountDirect link to 3. Verify and install the account
Get-ADServiceAccount <NAMEOFACCOUNT>
Install-ADServiceAccount -Identity <NAMEOFACCOUNT>
Test-ADServiceAccount <NAMEOFACCOUNT>
Test-ADServiceAccount should return True. After installation, complete the directory, folder, and local service permissions below, then follow the Configure connection guide to assign the account to the NIM Windows service.
Microsoft documents account creation, host association, and local installation separately: New-ADServiceAccount, Add-ADComputerServiceAccount, and Install-ADServiceAccount.
Delegate Active Directory permissionsDirect link to Delegate Active Directory permissions
-
Create an Active Directory group for the MSA and add the MSA as a member.
-
In Active Directory Users and Computers, right-click the domain root or the relevant organizational unit, then select Delegate Control.
-
Add the group you created and delegate the tasks NIM requires. Common permissions include:
- Create, delete, and manage user accounts
- Reset user passwords and force password change at next sign-in
- Read all user information
- Modify group membership
-
On the NIM server, grant that group Full control to:
C:\ProgramData\Tools4ever\NIMC:\Program Files\Tools4ever\NIM\sysconfig
-
Grant the MSA permission to query status, start, and stop only the local NIM Service, so it can complete service upgrades. Do not add it to local Administrators or grant Full control over the service.
On the NIM server, have an administrator run the following in elevated Windows PowerShell. Replace
<NAMEOFACCOUNT>with the Service Account name shown inservices.msc> NIM Service > General, andNimSvcwith your MSA name. The script backs up the current service ACL and adds the required rights while preserving existing entries.$ErrorActionPreference = 'Stop'$nimServiceName = 'nim'$nimServiceAccount = <NAMEOFACCOUNT>$nimAccountSid = (Get-ADServiceAccount -Identity $nimServiceAccount).SID$nimOutput = & sc.exe sdshow $nimServiceNameif ($LASTEXITCODE -ne 0) { throw 'Cannot read the service ACL.' }$nimSddl = ($nimOutput | Where-Object { $_.Trim().StartsWith('D:') }) -join ''if (-not $nimSddl) { throw 'No service DACL found. Stop and review.' }$nimBackup = Join-Path $env:TEMP ('NIM-service-acl-{0}.sddl' -f [guid]::NewGuid())Set-Content -LiteralPath $nimBackup -Value $nimSddl -Encoding ASCIIWrite-Host "Service ACL backup: $nimBackup"$nimAcl = [System.Security.AccessControl.CommonSecurityDescriptor]::new($false, $false, $nimSddl)if ($null -eq $nimAcl.DiscretionaryAcl -or -not $nimAcl.IsDiscretionaryAclCanonical) {throw 'Service ACL needs administrator review. No permissions changed.'}# 0x34 = query status, start, and stop$nimAcl.DiscretionaryAcl.AddAccess([System.Security.AccessControl.AccessControlType]::Allow, $nimAccountSid, 0x34,[System.Security.AccessControl.InheritanceFlags]::None,[System.Security.AccessControl.PropagationFlags]::None)& sc.exe sdset $nimServiceName ($nimAcl.GetSddlForm([System.Security.AccessControl.AccessControlSections]::Access))if ($LASTEXITCODE -ne 0) { throw 'Failed to update the service ACL.' }Run
sc.exe sdshow $nimServiceNameto confirm the MSA's SID has an allow entry withLCRPWP(query status, start, stop); existing rights may be combined in that entry. If access is still denied, have the administrator check deny entries and any Group Policy managing service security. See Microsoft's service access rights reference. -
Assign the MSA to the NIM Service and restart it during a maintenance window. Confirm the Log On account is the MSA. During the next planned upgrade, verify that maintenance mode clears and the wrapper log no longer reports the service-open error.
Test-ADServiceAccountalone does not verify service-control rights.
Troubleshoot managed service account setupDirect link to Troubleshoot managed service account setup
Problem
AD commands are not recognized
Resolution
Confirm that the Active Directory module is installed and Import-Module ActiveDirectory succeeds in this session.
Problem
The account or computer cannot be found
Resolution
Check the account and AD computer names with Get-ADServiceAccount and Get-ADComputer. Confirm that you are querying the intended domain.
Problem
Creation or host association returns Access denied
Resolution
Check the executing account's AD permissions on the account container and computer object. Running PowerShell as a local administrator does not replace directory delegation.
Problem
Install-ADServiceAccount fails
Resolution
Confirm that the account exists, is associated with the intended computer, and is being installed on that computer. Check domain connectivity and the command's error before continuing.
Problem
Test-ADServiceAccount returns False
Resolution
Stop before changing the NIM service identity. Confirm the account type, intended host association, successful local installation, and domain connectivity. Use Microsoft's Test-ADServiceAccount reference to interpret what the local test checks.
Problem
The test returns True, but NIM receives Access denied
Resolution
Verify the actual NIM service identity and the delegated rights on the affected AD object. Follow the Active Directory permission checks.
Problem
An upgrade stays in maintenance mode
Wrapper log
Cannot open nim service on computer '.'
Resolution
Confirm the NIM service logon account and grant local NIM Service control. A successful Test-ADServiceAccount does not verify service-control rights.