gpt4 book ai didi

c# - ReportingService2005 通过 WCF - 与模拟一起工作,但不与用户名/密码一起工作

转载 作者:太空狗 更新时间:2023-10-30 01:09:15 28 4
gpt4 key购买 nike

我正在通过 WCF 连接到 SSRS 2008 的 ReportingService2005 服务。

我让它与模拟一起工作,像这样:

ReportingService2005SoapClient rService = 
new ReportingService2005SoapClient("endpoint config name", "the url");
rService.ClientCredentials.Windows.AllowedImpersonationLevel =
System.Security.Principal.TokenImpersonationLevel.Impersonation;
rService.ChannelFactory.Credentials.Windows.ClientCredential =
CredentialCache.DefaultNetworkCredentials;

但是当我尝试将特定的用户名/密码传递给它时,如下所示:

rService.ChannelFactory.Credentials.Windows.ClientCredential = 
new NetworkCredential(username, password, domain);

我在第一次方法调用时收到此错误:

The HTTP request is unauthorized with client authentication scheme 'Ntlm'. The authentication header received from the server was 'NTLM'.

这是我的 wcf 绑定(bind)配置的相关部分:

<basicHttpBinding>
<binding name="ReportingService2005Soap" ... blah blah blah ...
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm" proxyCredentialType="Ntlm" realm=""/>
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>

我对在两种不同情况下提到 Ntlm 的错误消息感到困惑。

所以问题是 - 我需要摆弄两个 squillion 不同的 WCF 设置中的哪一个才能让它工作? :)

编辑:这是来自 SSRS 服务器的 RSReportServer.config 的身份验证位:

<Authentication>
<AuthenticationTypes>
<RSWindowsNegotiate/>
<RSWindowsNTLM/>
</AuthenticationTypes>
<EnableAuthPersistence>true</EnableAuthPersistence>
</Authentication>

来自 SSRS web.config:

<authentication mode="Windows" />

编辑:目前为止我会标记最佳答案,但这仍然是开放的,因为我还没有找到允许我在代码中设置任意凭据的解决方案。

最佳答案

好的新尝试。

WCF服务运行在IIS中,SSRS使用windows认证。

当您拥有 Windows 身份验证时,它会起作用,因为使用了用户 Windows 安全上下文。

当您使用用户名和密码时,使用的是 IIS 用户。无法访问 SSRS。

所以让它工作:

  • 在 WCF 服务 web.config 的安全部分设置 impersonate=false。
  • 这将强制它使用应用程序池的标识
  • 然后将应用程序池的身份更改为有权访问 SSRS 的用户

关于c# - ReportingService2005 通过 WCF - 与模拟一起工作,但不与用户名/密码一起工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7390294/

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