如何解决在本地计算机上具有Windows身份验证的HTTP 401.2,但在测试服务器上没有HTTP 401.2
我正在使用IIS中部署的WCF Web服务,但我不了解本地配置与测试服务器上的配置之间的区别。
在测试服务器(IIS 8)上,在IIS中启用的唯一一种身份验证是 Windows身份验证。
通过此设置,我可以在浏览器(Chrome)中访问https://<test server FQDN>/<namespace>.<MyService>.svc
URL,并通过SoapUI发送SOAP请求。
但是,在本地计算机(IIS 10)上,仅启用Windows身份验证无效。
在浏览器中访问URL https://<local machine FQDN>/<namespace>.<MyService>.svc
时,出现以下错误:
主机上配置的身份验证方案 ('IntegratedWindowsAuthentication')不允许在 绑定“ CustomBinding”(“匿名”)。请确保 SecurityMode设置为Transport或TransportCredentialOnly。 此外,这可以通过更改身份验证来解决 通过IIS管理工具针对该应用程序的方案 ServiceHost.Authentication.AuthenticationSchemes属性中的 应用程序配置文件位于 元素,通过更新绑定上的ClientCredentialType属性, 或通过调整HttpTransportBindingElement上的AuthenticationScheme属性。
当我通过SoapUI访问URL时,我收到一个“ HTTP错误401.2-未经授权”的HTML响应(例如描述为here的响应)
在本地计算机和测试Web服务器上,IIS授权规则和.NET授权规则均设置为“允许所有用户”。
这里是web.config
文件的相关部分,在两台计算机上都是相同的。
<binding name="MyServiceBinding">
<security defaultAlgorithmSuite="Default" enableUnsecuredResponse="false"
authenticationMode="UserNameOverTransport" requireDerivedKeys="true"
includeTimestamp="false" messageSecurityVersion="WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10">
</security>
<textMessageEncoding messageVersion="Soap11" />
<httpsTransport />
</binding>
<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>
如果我还在本地计算机上启用了匿名身份验证,则可以无错误地访问Web服务,但是我想了解如何仅启用Windows身份验证(它的方式)在测试服务器上)。谢谢!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。