One problem with developing on Windows XP using IIS 5 is we don't have application pools. So if your hosted system needs to access a domain resource you will get denied because its using the worker process ASPNet_WP. Sure you could use some windows api calls and login as another user but then you have to manage credentials, and also its not needed for production as you can just set the app pool. So, in Windows XP I want IIS 5 to run under a domain service account. After a bit of trial and error here is the process I went through.
- Create a domain user account to be used as a Serivce Account.
- Grant local permissions
- Grant local security policy
- Run aspnet command.
- Update your Machine.Config
- Reboot
Local permissions
You need to grant local ACL permissions for any file access. If it writes log files you will need write permission. If you log to the event log you will need write permission on the appropriate registry key. Or just grant the service account local admin. (Not defence in depth but ok for development)
Local policy
Administrative Tools -> Local Security Policy -> Local Policies -> User Rights Assignment
Add the service account to the following polices:
- Access this computer from the network
- Impersonate a client after authentication
- Logon as a service
IIS Permissions
Start -> Run:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis -GA domain\accountname
Update your Machine.config
Run:
Notepad “C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG\machine.config”
Search the "<processModel" element and Add or edit to look like:
<processModel comImpersonationLevel="Impersonate" userName="domain\accountname" password="password"/>
Note: This is under the element <system.web>, and there should only be 1 processModel element.
After you update the Machine.config you need to reboot.
Note: When you are using WCF here are the command to get the user or the system Account:
Service Account = System.Security.Principal.WindowsIdentity.GetCurrent()
Calling User = System.ServiceModel.ServiceSecurityContext.Current.WindowsIdentity