Trouble Shoothing

Sometimes you will have problems accessing the database when running as a service. This could be caused by the security context of the service.

When you run the web server as a normal program it will run as the logged in user. This means that it will use the security context of the logged in user. Database servers such as Microsoft SQL Server can use the security of the logged in user to connect to the database. However, when you run as a service the user credentials may be different.

There are two obvious ways you can fix this problem:

  1. Configure the database to allow access from the security context of the service.
  2. Change the security context of the service.

The steps you need to take in order to give the service user access to the database depends on the type of database you are connecting to.

Changing the security context of the service can be easily done from the service manager's list of services on the computer. If you open the properties of a service there is an option to let the service run as a different user.