我正在通过 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);
我在第一个方法调用时收到此错误:
这是我的 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 的错误消息感到困惑。
所以问题是 - 我需要摆弄两个不同的 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。
所以要让它工作:
关于c# - ReportingService2005 通过 WCF - 适用于模拟,但不适用于用户名/密码,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7390294/