gpt4 book ai didi

c# - 为 WCF 应用程序设置凭据?

转载 作者:太空狗 更新时间:2023-10-29 19:57:55 24 4
gpt4 key购买 nike

我编写了一个简单的应用程序,它利用 WCF 在客户端和服务器之间进行通信。当我在本地运行它时它工作正常,但是当我在两个不同的盒子上运行服务器和客户端时我得到以下异常:

Unexpected error occured, while getting the group names from the VDN server
System.ServiceModel.Security.SecurityNegotiationException: The server has rejected the client credentials.
System.Security.Authentication.InvalidCredentialException: The server has rejected the client credentials.
System.ComponentModel.Win32Exception: The logon attempt failed

不被接受的凭据是什么?我该如何设置它们?

有没有办法将服务器配置为不需要身份验证?该应用程序是一个简单的监控应用程序,安全性并不是真正的问题。

抱歉没有说得很具体:该应用程序使用管道代理,并且没有 wcf 配置文件,因为 wcf 代码是手工编码的。

我的 WCF 代码基于本教程中的代码: http://www.switchonthecode.com/tutorials/wcf-tutorial-basic-interprocess-communication

直到我写完所有代码后,我才知道从配置生成 wcf 类是标准过程。现在,每当我查看教程/帮助文档时,他们都会使用生成的代码,并且所有内容都需要更改配置。

我没有足够的带宽(我已经处理了 3 个项目)用一个使用生成代码的组件替换我的 wcf 组件,但我将确保在下次使用 wcf 时使用代码生成。

最佳答案

这是我在搜索禁用 wcf 安全/身份验证时找到的解决方案。

来自 MSDN :

WSHttpBinding b = new WSHttpBinding();

b.Security.Mode = SecurityMode.None;

或者在配置中添加以下内容:

<wsHttpBinding>

<binding name="myBinding">

<security mode="None" />

</binding>

</wsHttpBinding>

关于c# - 为 WCF 应用程序设置凭据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/864202/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com