【发布时间】:2013-02-22 06:49:10
【问题描述】:
当我在 IIS 中将 Windows 身份验证启用和匿名设置为禁用时,出现以下错误。
主机上配置的认证方案 ('IntegratedWindowsAuthentication') 不允许那些在 绑定“BasicHttpBinding”(“匿名”)。请确保 SecurityMode 设置为 Transport 或 TransportCredentialOnly。 此外,这可以通过更改身份验证来解决 此应用程序的方案通过 IIS 管理工具,通过 ServiceHost.Authentication.AuthenticationSchemes 属性,在 应用程序配置文件在 元素,通过更新 ClientCredentialType 上的属性 绑定,或者通过调整 AuthenticationScheme 属性 HttpTransportBindingElement。
我的Wcf Service的web.config如下...
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpEndpointBinding">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint binding="basicHttpBinding"
bindingConfiguration="BasicHttpEndpointBinding"
contract="Test.IService1" name="BasicHttpEndpoint" />
</client>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceAuthenticationManager
authenticationSchemes="IntegratedWindowsAuthentication"/>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="false"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpBinding" scheme="http" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
请指教..
【问题讨论】:
-
你没有发布你的 web.config...
-
现在准备好了。请指教。
-
我在您的配置中没有看到服务定义,只是一个客户端。如果这是您的服务的配置文件并且您使用的是 .NET 4.0+,那么您很可能会获得一个默认端点,该端点可能没有正确设置安全性。您还需要将在配置文件中创建的绑定分配给您的服务。
-
谢谢。现在它没有错误。但是如何避免身份验证。意味着如何避免在通过 IIS 浏览服务时询问用户名和密码。请帮忙。
-
如果该用户与机器登录用户相同,那么请推荐一种在通过 IIS 浏览 Wcf 服务时避免此身份验证的方法。