Wcf HTTP 401.2,在本地计算机上使用Windows身份验证,但不在测试服务器上
我正在处理部署在IIS中的WCF web服务,我不理解本地配置和测试服务器上的配置之间的区别 在测试服务器(IIS 8)上,IIS中启用的唯一身份验证类型是Windows身份验证 通过此设置,我可以访问Wcf HTTP 401.2,在本地计算机上使用Windows身份验证,但不在测试服务器上,wcf,iis,Wcf,Iis,我正在处理部署在IIS中的WCF web服务,我不理解本地配置和测试服务器上的配置之间的区别 在测试服务器(IIS 8)上,IIS中启用的唯一身份验证类型是Windows身份验证 通过此设置,我可以访问https:///..svcURL,并通过SoapUI发送SOAP请求 但是,在本地计算机(IIS 10)上,仅启用Windows身份验证不起作用 当我访问URLhttps:///..svc在浏览器中,我发现以下错误: 在主机上配置的身份验证方案 ('IntegratedWindowsAuthen
https:///..svc
URL,并通过SoapUI发送SOAP请求
但是,在本地计算机(IIS 10)上,仅启用Windows身份验证不起作用
当我访问URLhttps:///..svc
在浏览器中,我发现以下错误:
在主机上配置的身份验证方案
('IntegratedWindowsAuthentication')不允许在上配置的
绑定“CustomBinding”(“Anonymous”)。请确保
SecurityMode设置为Transport或TransportCredentialOnly。
此外,这可以通过更改身份验证来解决
通过IIS管理工具,通过
中的ServiceHost.Authentication.AuthenticationSchemes属性
应用程序配置文件位于
元素,通过更新绑定上的ClientCredentialType属性,
或者通过调整HttpTransportBindingElement上的AuthenticationScheme属性
当我通过SoapUI访问URL时,我得到一个“HTTP错误401.2-未经授权”的HTML响应(如所述)
IIS授权规则和.NET授权规则设置为“允许本地计算机和测试web服务器上的所有用户”
下面是web.config
文件的相关部分,在两台机器上都是相同的
<binding name="MyServiceBinding">
<security defaultAlgorithmSuite="Default" enableUnsecuredResponse="false"
authenticationMode="UserNameOverTransport" requireDerivedKeys="true"
includeTimestamp="false" messageSecurityVersion="WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10">
</security>
<textMessageEncoding messageVersion="Soap11" />
<httpsTransport />
</binding>
如果我也在本地计算机上启用了匿名身份验证,我可以访问web服务而不会出错,但我想了解如何只启用Windows身份验证(测试服务器上的方式)。谢谢大家! 您可以参考此答案来配置windows身份验证。
<behavior name="MyServiceServiceBehavior">
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" />
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="<namespace>.PasswordValidator, <assembly>" />
</serviceCredentials>
<serviceAuthorization principalPermissionMode="Custom">
<authorizationPolicies>
<add policyType="<namespace>.AuthorizationPolicy, <assembly>"/>
</authorizationPolicies>
</serviceAuthorization>
</behavior>
<service name="<namespace>.<MyService>" behaviorConfiguration="MyServiceServiceBehavior" >
<endpoint address="" binding="customBinding" bindingConfiguration="MyServiceBinding" contract="<namespace>.IMyService" />
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress = "https://localhost/<namespace>" />
</baseAddresses>
</host>
</service>