简体   繁体   English

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

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

I have a Silverlight 5 Prism application with a (regular) WCF service in an ASP.net project. 我在ASP.net项目中有一个带有(常规)WCF服务的Silverlight 5 Prism应用程序。 I'm using IIS 7.5 to host it on the localhost. 我正在使用IIS 7.5在localhost上托管它。 I followed all the steps in 我按照了所有步骤

How to: Use Windows Authentication to Secure a Service for Silverlight Applications 如何:使用Windows身份验证为Silverlight应用程序保护服务

How to: Host a Secure Service in ASP.NET for Silverlight Applications 如何:在ASP.NET中为Silverlight应用程序托管安全服务

but I can't get windows authentication to work. 但我不能让Windows身份验证工作。 Whenever I turn off anonymous authentication in IIS, my application throws an The remote server returned an error: NotFound. 每当我在IIS中关闭匿名身份验证时,我的应用程序都会抛出一个The remote server returned an error: NotFound. exception because it doesn't find the WCF service. 异常,因为它找不到WCF服务。

When I try to update the service reference in Visual Studio I get the error Security settings for this service require 'Anonymous' Authentication but it is not enabled for the IIS application that hosts this service. 当我尝试在Visual Studio中更新服务引用时,我得到错误Security settings for this service require 'Anonymous' Authentication but it is not enabled for the IIS application that hosts this service.

When I turn on Anonymous Authentication the service works, but I don't get the windows user credentials. 当我打开匿名身份验证服务工作,但我没有获得Windows用户凭据。 My browser (IE 8) is set to use integrated windows authentication and automatically logon in the local intranet. 我的浏览器(IE 8)设置为使用集成的Windows身份验证并自动登录本地Intranet。

What am I doing wrong? 我究竟做错了什么?

Here is my IIS 7.5 configuration. 这是我的IIS 7.5配置。 The Application pool is running in Integrated mode: 应用程序池以集成模式运行:

IIS配置

web.config: 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: 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>

I am only guessing on the WCF part that this may not be set up properly for windows authentication. 我只是猜测WCF部分可能无法正确设置Windows身份验证。 The wcf service needs to be configured to authenticate the requests from IIS with windows credentials as well. 需要将wcf服务配置为使用Windows凭据验证来自IIS的请求。 So, in that case, I would expect that there needs to be a behavior in the service demanding this. 因此,在这种情况下,我希望服务中需要有一个行为要求这样做。 Check to see if you have configured these correcntly. 检查您是否已正确配置这些。 servicecredentials and clientcredentials. servicecredentials和clientcredentials。

serviceCredentials serviceCredentials

Security behaviours in WCF WCF中的安全行为

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

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