wcf - 使用 Silverlight 5、IIS 7.5 的 WCF 服务的 Windows 身份验证

标签 wcf silverlight authentication iis

我在 ASP.net 项目中有一个带有(常规)WCF 服务的 Silverlight 5 Prism 应用程序。我正在使用 IIS 7.5 将其托管在本地主机上。我按照

中的所有步骤操作

How to: Use Windows Authentication to Secure a Service for Silverlight Applications

How to: Host a Secure Service in ASP.NET for Silverlight Applications

但我无法让 Windows 身份验证工作。每当我在 IIS 中关闭匿名身份验证时,我的应用程序都会抛出一个 The remote server returned an error: NotFound. 异常,因为它没有找到 WCF 服务。

当我尝试更新 Visual Studio 中的服务引用时,出现错误Security settings for this service require 'Anonymous' Authentication but it is not enabled for the IIS application that hosts this service。

当我打开匿名身份验证时,该服务可以正常工作,但我没有获得 Windows 用户凭据。我的浏览器(IE 8)设置为使用集成windows身份验证并自动登录本地内网。

我做错了什么?

这是我的 IIS 7.5 配置。应用程序池以集成模式运行:

IIS configuration

网络配置:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.web>
    <compilation debug="true" />
    <authentication mode="Windows" />
  </system.web>
  <system.serviceModel>
  <behaviors>
    <serviceBehaviors>
      <behavior name="">
        <serviceMetadata httpGetEnabled="true" />
        <serviceDebug includeExceptionDetailInFaults="false" />
       </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />  
  </system.serviceModel>
</configuration>

ServiceReferences.ClientConfig:

<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_ISecurityService" maxBufferSize="2147483647"
                    maxReceivedMessageSize="2147483647">
                    <security mode="TransportCredentialOnly" />
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost:85/SecurityService/SecurityService.svc"
                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ISecurityService"
                contract="SecurityServiceReference.ISecurityService" name="BasicHttpBinding_ISecurityService" />
        </client>
    </system.serviceModel>
</configuration>

最佳答案

我只是猜测 WCF 部分可能没有正确设置 Windows 身份验证。 wcf 服务也需要配置为使用 Windows 凭据对来自 IIS 的请求进行身份验证。因此,在那种情况下,我希望服务中需要有一种行为要求这样做。检查您是否已正确配置这些。服务凭证和客户凭证。

serviceCredentials

Security behaviours in WCF

关于wcf - 使用 Silverlight 5、IIS 7.5 的 WCF 服务的 Windows 身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13681086/

相关文章:

c# - silverlight 中的动态图像源绑定(bind)

c# - 双向绑定(bind)不起作用

python - 使用 JWT Auth 对 LDAP 服务进行身份验证

java - 如果窗口之前没有经历过 Java 的登录阶段,如何防止窗口加载?

.net - 使用传输安全时,WCF 是否需要 SSL?

c# - 如何从响应中删除 "method"节点?

.net - 创建异步服务的正确模式是什么?

php - jquery mobile登录和访问/拒绝页面

wcf - 为什么我的WCF端点不抛出Max Clock Skew异常?

http - 使用 HTTP 的 WCF 自定义用户名身份验证