gpt4 book ai didi

web-services - 使用 DefaultCredentials 和 DefaultNetworkCredentials

转载 作者:行者123 更新时间:2023-12-03 10:05:23 26 4
gpt4 key购买 nike

我们很难弄清楚这些凭证对象是如何工作的。事实上,它们可能不会像我们期望的那样工作。这是对当前问题的解释。
我们有 2 个需要通过网络服务相互通信的服务器。第一个(我们称之为 Server01 )有一个 Windows 服务作为 NetworkService 帐户运行。另一个Server02具有与 IIS 6.0 一起运行的 ReportingServices。 Server01 上的 Windows 服务正在尝试使用 Server02 ReportingServices WebService 生成报告并通过电子邮件发送。
所以,这是我们迄今为止尝试过的。
在运行时设置凭据( 这工作得很好 ):

 rs.Credentials = new NetworkCredentials("user", "pass", "domain");
现在,如果我们可以使用通用用户,一切都会好起来的,但是……我们不允许这样做。因此,我们尝试使用 DefaultCredetials 或 DefaultNetworkCredentials 并将其传递给 RS Webservice:
rs.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials
或者:
rs.Credentials = System.Net.CredentialCache.DefaultCredentials
无论哪种方式都行不通。我们总是从 IIS 获得 401 未经授权。现在,我们所知道的是,如果我们想授予对记录为 NetworkService 的资源的访问权限,我们需要将其授予 DOMAIN\MachineName$ ( http://msdn.microsoft.com/en-us/library/ms998320.aspx ):

Granting Access to a Remote SQL Server

If you are accessing a database on another server in the same domain (or in a trusted domain), the Network Service account's network credentials are used to authenticate to the database. The Network Service account's credentials are of the form DomainName\AspNetServer$, where DomainName is the domain of the ASP.NET server and AspNetServer is your Web server name.

For example, if your ASP.NET application runs on a server named SVR1 in the domain CONTOSO, the SQL Server sees a database access request from CONTOSO\SVR1$.


我们假设以与 IIS 相同的方式授予访问权限是可行的。然而,事实并非如此。或者至少,某些东西没有正确设置以正确进行身份验证。
所以,这里有一些问题:
  • 我们已经在某处阅读了“模拟用户”,我们是否需要在 中的某处设置它? Windows 服务 ?
  • 是否可以向远程 IIS 服务器授予对 NetworkService 内置帐户的访问权限?

  • 谢谢阅读!

    最佳答案

    您需要的所有详细信息都包含在 this very old article
    简而言之,当您发现解决此类问题令人困惑时,您应该首先仔细查看 ASP.NET 模拟背后的技术细节。

    关于web-services - 使用 DefaultCredentials 和 DefaultNetworkCredentials,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1058636/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com