C# 如何配置部署在IIS和远程客户端上的WCF服务以从远程客户端PC进行身份验证?
我是个笨蛋;请帮助我理解这个让我非常困惑的身份验证配置/绑定的东西 我在Win2008的IIS7上部署了一个C#WCF服务。我的客户端是一个Windows Forms C#应用程序。我的客户端在运行WCF服务的同一台服务器上运行时工作正常,但当我尝试从远程PC上运行客户端时,会出现以下异常 System.ServiceModel.Security.SecurityNegotiationException:服务未对调用方进行身份验证 我已经阅读了一些关于这些问题的文章,并且知道我的问题是因为我的服务和客户机被配置为使用Windows身份验证,我猜这是使用Visual Studio创建服务时的默认设置,并将服务引用添加到客户机。下面是我在进行任何更改之前的配置,当时它仍然设置为Windows(删除了不相关的位) Web.ConfigC# 如何配置部署在IIS和远程客户端上的WCF服务以从远程客户端PC进行身份验证?,c#,wcf,authentication,iis,wshttpbinding,C#,Wcf,Authentication,Iis,Wshttpbinding,我是个笨蛋;请帮助我理解这个让我非常困惑的身份验证配置/绑定的东西 我在Win2008的IIS7上部署了一个C#WCF服务。我的客户端是一个Windows Forms C#应用程序。我的客户端在运行WCF服务的同一台服务器上运行时工作正常,但当我尝试从远程PC上运行客户端时,会出现以下异常 System.ServiceModel.Security.SecurityNegotiationException:服务未对调用方进行身份验证 我已经阅读了一些关于这些问题的文章,并且知道我的问题是因为我的服
<system.web>
...
<authentication mode="Windows"/>
...
<system.serviceModel>
<services>
<service name="MCLaborServer.LaborService" behaviorConfiguration="MCLaborServer.LaborServiceBehavior">
<!-- Service Endpoints -->
<endpoint address="" binding="wsHttpBinding" contract="MCLaborServer.ILaborService">
<!--
Upon deployment, the following identity element should be removed or replaced to reflect the
identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
automatically.
-->
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MCLaborServer.LaborServiceBehavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
我已经阅读了以下文章/链接,但仍然感到困惑。谢谢你的帮助
在设置跨域运行的低安全性WCF服务时,我们遇到了类似的问题。最大的问题之一(如果可以这么说的话)是WCF在默认情况下被配置为非常安全。因为我们的应用程序完全在一个安全的网络中,所以我们不想麻烦处理大量复杂的证书。我们的解决方法是创建一个自定义绑定,允许我们在不加密的情况下对服务使用用户名/密码身份验证。我们的实现基于。我建议你看看这个(还有他的) 学习WCF绑定和安全性的一些好资源:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_ILaborService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" establishSecurityContext="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://<myDnsNameGoesHere>/MCLaborServer/LaborService.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ILaborService"
contract="LaborService.ILaborService" name="WSHttpBinding_ILaborService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>
SomeService.ServiceClient someService = new SomeService.ServiceClient();
someService.ClientCredentials.Windows.ClientCredential.UserName="windowsuseraccountname"
someService.ClientCredentials.Windows.ClientCredential.Password="windowsuseraccountpassword"