1

On one side I have a Windows service that uses Entity Framework to connect to a SQL Server instance and work with a database there.

On the other side I have a WIX based installer which has a bootstrapper .NET based GUI in which the user can enter connection details to be used in the connection string by the service. In this installer GUI I am also performing a check on the user provided data and check the database connection (using SqlConnection.Open() and even creating/dropping a database).

The issue appears in a workgroup environment, no domain controller present, and when the user chooses Integrated Security as an option. The bootstrapper application successfully connects to the SQL server and performs some operations with it, but then the Windows service fails to connect to the SQL server using Integrated Security. If I follow up by changing that to user and password authentication, the service works correctly.

Is there any way to have the bootstrapper fail connection if the service would fail, or the other way around?

Thanks.

4

1 回答 1

1

最可能的原因是运行服务的用户和运行安装程序的用户不同。

如果运行安装程序的用户可以通过 Windows 身份验证访问 SQL Server,则连接将成功。然后,如果服务在不同的帐户(比如 LocalSystem)下运行,则运行该服务的用户没有使用集成安全性的权限。

解决此问题的方法是使用对服务器具有权限的服务帐户或使用 SQL 身份验证。

我最近在部署服务时遇到了这个问题。使引导程序连接失败的唯一方法是将其作为服务将在其下运行的帐户运行(模拟是实现此目的的一种方法),否则您无法正确测试连接。

由于您提到工作组并且没有域控制器,因此可能会通过用户名和密码进行一些传递。在我工作的一个地方,在一个 SQL 框(域外)上,每个开发人员都有一个本地 Windows 帐户,其密码与他们的域帐户相同。这允许通过身份验证(由于用户名和密码匹配)并访问 SQL Server。这可能是正在发生的事情。

于 2015-04-17T16:32:46.390 回答