从 ASMX Web 服务访问 SQL Server 时出错

发布于 2024-08-09 02:07:32 字数 411 浏览 1 评论 0原文

我正在通过远程桌面连接访问我的服务器,并在 IIS 中配置了 Web 服务。我可以看到这些方法,但当我单击“调用”按钮时,出现以下错误:

System.Data.SqlClient.SqlException:用户“SOLDev\Server02$”登录失败。 在ShareWare.Web.Service.WebAPI.Reservation.GetInfo()

为什么它以机器名作为用户? 我的 Windows 身份验证用户是 User1Dev。 另外,我在 IIS 中的目录安全性设置如下:

  1. 选项“启用匿名访问”--已禁用
  2. 选项“集成 Windows 身份验证”--选中

我正在使用 .NET Framework 2.0

I am accessing my server through remote desktop connection and have configured a webservice in IIS. I am able to see the methods but when I click on the button to "Invoke" I get the following error:

System.Data.SqlClient.SqlException: Login failed for user 'SOLDev\Server02$'.
at ShareWare.Web.Service.WebAPI.Reservation.GetInfo()

Why is it taking the machine name as the user?
My windows authentication user is User1Dev.
Also my directory security in IIS is setup as follows:

  1. Option "Enable anonymous access" -- it's disabled
  2. Option "Integrated Windows Authentication" -- checked off

I am using .NET framework 2.0

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

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

发布评论

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

评论(2

苍白女子 2024-08-16 02:07:32

您的 Web 服务使用 Windows 身份验证作为运行服务的主体连接到 SQL。在这种情况下,它似乎是 BUILTIN\System 或 BUILTIN\Network Service,两者都在域中作为计算机帐户进行身份验证,即。 “SOLDEV\Server02$”对应于域 SOLDEV 中名为 Server02 的计算机。

如果您希望使用自己的登录名在 SQL Server 上进行身份验证,则 IIS 必须在称为“约束委派”的过程中传递身份验证信息。请参阅配置Kerberos 约束委派 (IIS 6.0)。如何:使用ASP.NET 2.0 中的协议转换和约束委派

如果您希望 Web 服务作为其本身向 SQL Server 进行身份验证,则必须向 SQL 上的 Web 服务主体授予登录权限:CREATE LOGIN [SOLDEV\Server02$] FROM WINDOWS

Your web service connects to the SQL using Windows authentication as the principal running the service. In this case it appears to be BUILTIN\System or BUILTIN\Network Service, both of which authenticate in the domain as the machine account, ie. 'SOLDEV\Server02$' which corresponds to a machine named Server02 in the domain SOLDEV.

If you wish to authenticate on the SQL Server with your own login, then the IIS must flow the authentication information, in a process called Constrained Delegation. See Configuring Constrained Delegation for Kerberos (IIS 6.0). or How To: Use Protocol Transition and Constrained Delegation in ASP.NET 2.0.

If you want the web service to authenticate to SQL Server as itself, then you must grant login permission to the web service principal on SQL: CREATE LOGIN [SOLDEV\Server02$] FROM WINDOWS.

宫墨修音 2024-08-16 02:07:32

这是因为 Web 服务作为网络服务 id 运行,而不是作为登录用户运行。如果您计划使用用户的凭据连接到 SQL Server,您可能还需要在 Web 配置中添加

It's because the web service is running as the Network Service id, not as the logged in user. You probably also need to have <identity impersonate="true" /> in your web config if you are planning to use the user's credentials to connect to SQL Server.

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