WCF 身份验证错误

Sta*_*wer 5 c# wcf web-services

我正在访问第三方 WCF 服务(我无权访问服务配置)我们使用 SSL 证书进行身份验证。

我在尝试访问任何提供的方法时收到此错误

HTTP 请求未经客户端身份验证方案“协商”的授权。从服务器收到的身份验证标头是“Negotiate,NTLM”

我检查了很多谷歌链接,但到目前为止没有运气 - 不知道我这边还需要检查什么。

编辑

这是配置

<系统.服务模型>
        <绑定>
            <wsHttpBinding>
                <绑定名称=“wsHttpBinding”closeTimeout=“00:01:00”openTimeout=“00:01:00”
                    receiveTimeout=“00:10:00”sendTimeout=“00:01:00”bypassProxyOnLocal=“假”
                    transactionFlow =“假”hostNameComparisonMode =“StrongWildcard”
                    maxBufferPoolSize =“524288”maxReceivedMessageSize =“65536”
                    messageEncoding =“文本”textEncoding =“utf-8”useDefaultWebProxy =“true”
                    允许Cookies =“假”>
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <reliableSessionordered=“true”inactivityTimeout=“00:10:00”
                        启用=“假”/>
                    <安全模式=“传输”>
                        <transport clientCredentialType="Windows" proxyCredentialType="无"
                            领域=“”/>
                        <message clientCredentialType =“Windows”negotiateServiceCredential =“true”
                            建立SecurityContext =“true”/>
                    </安全>
                </绑定>
            </wsHttpBinding>
        </绑定>
      <客户端>
          <端点地址=“https://url”
              绑定=“wsHttpBinding”绑定配置=“wsHttpBinding”
              合同=“IApiWS”名称=“wsHttpBinding”>
          </端点>
      </客户端>
</system.serviceModel>

Pha*_*bus 1

好吧,这可能有点含糊,所以我提前道歉,本质上服务器告诉你你没有获得授权,通常为此你会在你生成的代理上添加类似下面的内容

svc.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
Run Code Online (Sandbox Code Playgroud)

其中 svc 是您生成的代理。我还在配置错误的 IIS 托管端点上看到了这一点,其中虚拟文件夹没有允许匿名设置(尽管您说您无法访问服务配置,因此这可能没有帮助)。希望这可以帮助

编辑添加更多信息,

根据安全性,类似于下面的设置可能更有用

svc.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Anonymous;
Run Code Online (Sandbox Code Playgroud)

编辑2上面的配置显示您正在使用的wsHttpBinding已将Windows设置为clientCredentialtype以进行传输安全和用户身份验证,这意味着您将通过当前登录用户的凭据发送到服务以使用NTLM进行身份验证(如negotiateServiceCredentials 为 true)您是否确认登录的用户拥有该服务的权限?