编程语言
首页 > 编程语言> > c# – ReportingService2005通过WCF – 使用模拟,但不使用用户名/密码

c# – ReportingService2005通过WCF – 使用模拟,但不使用用户名/密码

作者:互联网

我正在通过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绑定配置的相关部分:

<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设置中的哪一个?

标签:c,sql-server,wcf,credentials,reporting-services
来源: https://codeday.me/bug/20190621/1253227.html