C# 调用者未通过 WCF 服务中的服务进行身份验证

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1177487/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 10:06:47  来源:igfitidea点击:

The caller was not authenticated by the service in WCF service

c#wcfauthentication

提问by

Thanks for your reply but no luck with that code..I am sending you complete config files related to service and application ....Give me any valuable suggession.

感谢您的回复,但该代码没有运气...我正在向您发送与服务和应用程序相关的完整配置文件....给我任何有价值的建议。

Service web.config

服务 web.config

application web.config

应用程序 web.config

Thanks in advance

提前致谢

回答by Andrew Hare

The wsHttpBindinghas message-level security and by default it uses Windows authentication. If that is not what you want perhaps you meant to use the basicHttpBinding? This binding is not secured by default.

wsHttpBinding有消息级安全默认情况下它使用Windows身份验证。如果这不是您想要的,也许您打算使用basicHttpBinding? 默认情况下,此绑定不受保护。

BasicHttpBinding:

BasicHttpBinding

The BasicHttpBinding uses HTTP as the transport for sending SOAP 1.1 messages. A service can use this binding to expose endpoints that conform to WS-I BP 1.1, such as those that ASMX clients access. Similarly, a client can use the BasicHttpBinding to communicate with services exposing endpoints that conform to WS-I BP 1.1, such as ASMX Web services or Windows Communication Foundation (WCF) services configured with the BasicHttpBinding.

Security is turned off by default, but can be added setting the BasicHttpSecurityMode to a value other than None in the BasicHttpBinding(BasicHttpSecurityMode) constructor. It uses a "Text" message encoding and UTF-8 text encoding by default.

BasicHttpBinding 使用 HTTP 作为发送 SOAP 1.1 消息的传输。服务可以使用此绑定来公开符合 WS-I BP 1.1 的端点,例如 ASMX 客户端访问的端点。同样,客户端可以使用 BasicHttpBinding 与公开符合 WS-I BP 1.1 的端点的服务进行通信,例如 ASMX Web 服务或使用 BasicHttpBinding 配置的 Windows Communication Foundation (WCF) 服务。

默认情况下安全性是关闭的,但可以在 BasicHttpBinding(BasicHttpSecurityMode) 构造函数中添加将 BasicHttpSecurityMode 设置为 None 以外的值。默认情况下,它使用“文本”消息编码和 UTF-8 文本编码。

WSHttpBinding:

WSHttpBinding

The WSHttpBinding is similar to the BasicHttpBinding but provides more Web service features. It uses the HTTP transport and provides message security, as does BasicHttpBinding, but it also provides transactions, reliable messaging, and WS-Addressing, either enabled by defaultor available through a single control setting.

WSHttpBinding 类似于 BasicHttpBinding,但提供了更多的 Web 服务功能。它使用 HTTP 传输并提供消息安全性,就像 BasicHttpBinding 一样,但它还提供事务、可靠消息传递和 WS-Addressing,默认情况下启用或通过单个控件设置可用。

Edit:Try this configuration:

编辑:试试这个配置:

<system.serviceModel>
    <client>
        <endpoint 
            address="http://miplserver02:9050/UserManagementService/UserManagementService.svc"
            binding="basicHttpBinding" 
            contract="UMS.IUserManagementService">
            <identity>
                <dns value="localhost" />
            </identity>
        </endpoint>
    </client>
</system.serviceModel>

回答by Shiraz Bhaiji

It is probably that authentication is set to anonymous instead of windows.

可能是将身份验证设置为匿名而不是 windows。

Check your IIS configuration and web.config for difference between your local machine and the test machine that is failing.

检查您的 IIS 配置和 web.config 以了解本地计算机和出现故障的测试计算机之间的差异。

Also are you trying to access IIS on a remote machine while you are logged in as a local user.

当您以本地用户身份登录时,您是否还尝试访问远程计算机上的 IIS。

回答by Linh

Set value of security mode to "None".

将安全模式的值设置为“无”。

<security mode="None">