设置WCF应用程序的凭据?

Oma*_*eji 7 .net c# wcf

我写了一个简单的应用程序,利用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
Run Code Online (Sandbox Code Playgroud)

什么是不被接受的凭证?我该怎么设置它们?

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

很抱歉不是非常具体: 该应用程序使用管道代理,并且没有wcf配置文件,因为wcf代码是手动编码的.

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

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

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

mir*_*zus 11

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

来自MSDN:

WSHttpBinding b = new WSHttpBinding();

b.Security.Mode = SecurityMode.None;
Run Code Online (Sandbox Code Playgroud)

或者在config中添加以下内容:

<wsHttpBinding>

    <binding name="myBinding">

        <security mode="None" />

    </binding>

</wsHttpBinding>
Run Code Online (Sandbox Code Playgroud)


Zom*_*eep 5

创建这样的方法......

void SetImpersonation(ref IServiceClient proxy)
{
  proxy.ClientCredentials.Windows.ClientCredential.Domain = "MYDOMAIN";
  proxy.ClientCredentials.Windows.ClientCredential.UserName = "A_USER";
  proxy.ClientCredentials.Windows.ClientCredential.Password = "P4SSW0RD";
}
Run Code Online (Sandbox Code Playgroud)

并在创建新客户端类时调用它.

IServiceClient proxy = new IServiceClient ();
SetImpersonation(ref proxy);
Run Code Online (Sandbox Code Playgroud)

显然,这是将信息设置为特定用户,如果您的代码被反编译,则会产生安全隐患,但它应该适用于您的(无文件配置文件的情况)