Applies to: Windows Server 2019, Windows Server 2022 and Windows Server 2025, subject to the workload and edition requirements below.
Use a custom identity only for an identified requirement
An IIS application pool identity determines the Windows security context of its worker process. The default ApplicationPoolIdentity gives each pool a distinct virtual identity and is often the simplest secure choice for local application files. A custom domain identity can be appropriate when an application needs its own identity for a remote database, file service or another integrated-authentication dependency. It introduces account lifecycle and privilege responsibilities that should be justified.
This guide changes one pool, PortalPool, to a dedicated domain account while preserving least-privilege file access and a rollback path. It does not make the account a local administrator or grant it broad domain rights. A custom pool identity also does not automatically change every request’s effective identity: Windows Authentication, impersonation, anonymous authentication and virtual-directory credentials can introduce additional contexts. Identify the application’s actual access path before changing the process account.
Create a dedicated account and access inventory
Provision a specifically approved account such as CORP\svc-portal through the directory-management process. Assign an owner, purpose, rotation policy and restrictions against interactive use consistent with organizational policy. Do not use an employee account or Domain Admins credential. Verify that the account is enabled, its credentials are available through an approved secret store and its password lifecycle will not unexpectedly stop the pool.
Inventory the local content, write folders, certificate keys, registry keys and remote resources the application genuinely uses. Distinguish read-only code from uploads, generated reports and temporary data. For remote SMB access, both share and NTFS permissions matter. For SQL Server or another service, grant the application role needed at that service rather than giving blanket server administration.
Managed service accounts can reduce password handling in a compatible deployment, but they require their own AD, host authorization and IIS configuration prerequisites. Do not substitute a gMSA name into an ordinary username/password example and assume it is complete. This walkthrough uses a conventional dedicated account to make the identity and rotation decisions explicit.
Capture the current pool and authentication settings
Back up IIS configuration before changing a production pool, and protect the backup because configuration can contain sensitive identity information. Record the pool’s current identity type and account without exporting plaintext passwords. Identify every application using the pool; changing a shared pool affects all of them, even if the change request mentions only one site.
Import-Module WebAdministration
Get-Item 'IIS:\AppPools\PortalPool' |
Select-Object Name,@{Name='IdentityType';Expression={$_.processModel.identityType}},
@{Name='UserName';Expression={$_.processModel.userName}}
Get-WebApplication | Select-Object Path,ApplicationPool,PhysicalPath
Get-Website | Select-Object Name,ApplicationPool,PhysicalPathReview the site’s Anonymous Authentication identity, Windows Authentication and any application impersonation settings. If anonymous requests still use IUSR, granting only the new process account access may not produce the expected file access. Likewise, an application using explicit credentials for a remote dependency may continue to use them regardless of the pool change. Keep the maintenance scope tied to observed identities.
Grant only the required resource permissions
Grant the dedicated account read and execute on application code and narrowly scoped Modify on approved data directories. The sample paths are illustrative and must already belong to this application. Review inherited entries and ownership before changing established data. Do not recursively replace an entire site tree’s ACL as part of an identity switch.
icacls 'D:\Sites\Portal' /grant:r 'CORP\svc-portal:(OI)(CI)RX'
icacls 'D:\AppData\Portal' /grant:r 'CORP\svc-portal:(OI)(CI)M'
icacls 'D:\Sites\Portal'
icacls 'D:\AppData\Portal'Keep application-writable data outside executable content when the application supports it. Retain SYSTEM and authorized administrator access. Grant remote permissions to the identity actually presented on the network: ApplicationPoolIdentity normally uses the machine account for network access, while a dedicated domain process account can present its own identity. Kerberos delegation and user impersonation are separate designs and should not be enabled broadly to repair an ordinary service-account permission failure.
Set the identity through supported protected configuration
In IIS Manager, open Application Pools, select PortalPool and open Advanced Settings. Under Process Model, open Identity, select Custom account and use Set to enter CORP\svc-portal and its password through the secure configuration dialog. Verify the account name before accepting. IIS management tooling protects configured credentials; do not manually place an unencrypted password into ApplicationHost.config or a shared script.
The resulting identity type is SpecificUser. Confirm the account has the logon right required by the pool’s configured logon type, commonly batch logon, and that a deny policy does not override it. Domain Group Policy can replace a local user-rights change, so correct the managed policy rather than repeatedly adding a local exception. Do not change the account to LocalSystem to avoid a logon-rights error.
If the application requires a loaded user profile for a certificate store or profile-based setting, review loadUserProfile explicitly and test the dependency. Enabling it changes profile behaviour but does not grant missing file or network permissions. Keep credential entry out of PowerShell transcription, screenshots and diagnostic exports.
Recycle once and verify application behaviour
Coordinate the recycle with the application owner because active requests or in-memory state may be interrupted. Restart only the intended pool, then generate a real request to create a worker process if the pool starts on demand. Confirm the pool remains started and the application’s normal operations succeed under the new identity.
Restart-WebAppPool -Name 'PortalPool'
Get-WebAppPoolState -Name 'PortalPool'
& "$env:windir\System32\inetsrv\appcmd.exe" list wp
Get-WinEvent -FilterHashtable @{LogName='System';StartTime=(Get-Date).AddMinutes(-30)} -MaxEvents 80Test both ordinary page delivery and the dependency that motivated the change, such as an authorized report write or remote database operation. Verify that the account cannot write application code or reach unrelated resources. A successful pool start proves credentials and basic activation, not the entire access model. If multiple worker processes briefly appear during an overlapped recycle, account for the transition rather than assuming the identity never changed.
Diagnose startup and access failures by identity
If the pool stops immediately or returns 503, inspect WAS and related events for invalid credentials, expired or locked accounts, missing logon rights and rapid-fail protection. Avoid repeated restarts that can trigger additional account lockouts. Check whether a recent password rotation updated AD but not IIS, or whether a policy denied the configured logon type.
If the pool stays running but a resource fails, identify the exact operation and effective identity at that resource. Review NTFS, share, database and private-key permissions separately. A local certificate may be in a user store that belonged to the old account. An integrated-authentication failure may involve SPNs or delegation rather than file ACLs. Do not add the account to Administrators or grant Everyone Full Control as a diagnostic shortcut; those changes obscure the required permission and expand the consequences of an application compromise.
Rollback and keep the account lifecycle operational
If the change fails, restore the recorded identity type and account through IIS Manager and recycle the intended pool. Preserve logs and evidence before removing the new account’s grants. A previous custom identity may need its protected current credential; an AppCmd configuration restore should not be assumed to recover every external secret or application dependency. A whole-server restore also affects unrelated sites.
After acceptance, remove obsolete permissions from the former identity only when no other pool or service uses them. Document the account owner, resources, user-right policy, profile requirement, rotation process and verification test. Test password rotation in a planned window and monitor pool startup after it. A custom identity is maintainable when its permissions and lifecycle are understood, not merely when one credential makes an access-denied error disappear.
Related guidance and official references
Create a dedicated application pool; Back up IIS configuration; Design resource permissions.