繁体   English   中英

使用Silverlight 5,IIS 7.5进行WCF服务的Windows身份验证

[英]Windows Authentication for WCF service with Silverlight 5, IIS 7.5

我在ASP.net项目中有一个带有(常规)WCF服务的Silverlight 5 Prism应用程序。 我正在使用IIS 7.5在localhost上托管它。 我按照了所有步骤

如何:使用Windows身份验证为Silverlight应用程序保护服务

如何:在ASP.NET中为Silverlight应用程序托管安全服务

但我不能让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身份验证并自动登录本地Intranet。

我究竟做错了什么?

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

IIS配置

web.config中:

<?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和clientcredentials。

serviceCredentials

WCF中的安全行为

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM