将 Windows 身份验证集成到 SQL Server

发布于 2024-09-12 00:22:46 字数 422 浏览 2 评论 0原文

我有一个使用 SQL Server 上的数据库的应用程序,我希望用户使用集成 Windows 身份验证连接到该服务器。连接字符串是:

SqlConnection scn = new SqlConnection("Data Source='server name';Initial Catalog=temp;Trusted_Connection=true;Integrated Security=SSPI");

当我从我的电脑运行该应用程序时,它工作得很好并且可以识别我的用户名。但是当我从服务器运行它时,它会出现以下错误:

用户“domain\server Name$”登录失败。

据我了解,它无法识别用户名,并认为用户名是服务器名称。

知道如何修复它吗?

I have an application that uses a database on SQL Server and I want users to connect to that server using integrated windows authentication. The connection string is:

SqlConnection scn = new SqlConnection("Data Source='server name';Initial Catalog=temp;Trusted_Connection=true;Integrated Security=SSPI");

When I run the application from my pc it works just fine and it recognizes my user name. But when I run it from the server then it gives me the following error:

Login failed for user 'domain\server Name$'.

As I understand it doesn't recognize the user name and thinks that the user name is the server name.

Any idea how to fix it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一城柳絮吹成雪 2024-09-19 00:22:46

应用程序作为服务器计算机帐户正确连接。作为 LocalSystemNetwork Service 运行的进程通过网络作为机器 domain\machine$ 进行身份验证,这是设计使然、有意为之。

您可以根据需要授予 domain\server$ 登录 SQL 的权限。或者您可以更改应用程序以在不同的帐户下运行(我假设该应用程序是一项服务?)。

The application correctly connects as the server machine account. Processes running as LocalSystem or as Network Service authenticate over the network as the machine, domain\machine$, this is by design, intentional and desired.

You can grant domain\server$ login rights into SQL as needed. Or you can change the application to run under a different account (I assume the application is a service?).

浮世清欢 2024-09-19 00:22:46

使用 runas 运行应用程序具有正确的凭据。

Use runas to have the application run with the correct credentials.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文