Alex Rivera | Logout

How to connect to sql-server with windows authentication from windows-service?

Asked 2010-02-11T13:54:32.777
18

I have programmed a Windows Service in C# which should connect to an SQL-Server 2005 Express Database with System.Data.SqlClient.

As Microsoft prefers to use Windows Authentication over SQL Authentication I tried to connect to the database with Trusted Connection / Integrated Security.

However that doesn't work as I get a:

System.Data.SqlClient.SqlException: Login failed for user 'NT AUTHORITY\LOCAL SERVICE'.

Is it possible to login with a different Windows Account?

Edit
Report

1 Answer

3

If you want to use trusted windows authentication, the easiest thing to do is to run the service with a domain account (with the least privilleges required) that is permissioned to the sql server database.

answered 2010-02-11T14:00:05.043

Your Answer