Mostly a reminder for myself, but hopefully useful to somebody else –

Often it is important to specify a specific user for a service to run as; it appears the setup is completely different when using IIS 5.1 or 6 (and higher).

When using IIS 5.1

  • Set the anonymous user on the virtual directory to the user you want to run as.
  • Disable any other authentication method on the vdir
  • In the web.config turn impersonation ON (<identity impersonate=”true” /> under System.web.)
  • Under System.serviceModel add <serviceHostingEnvironment aspNetCompatibilityEnabled=”true”/>
  • To the service class add [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]

When using IIS 6.0

  • In the web.config turn impersonation OFF(<identity impersonate=”false” /> under System.web.)
  • Set the required identity in the app pool your virtual directory runs under.

(which one do you prefer? ;-))