Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何配置部署在IIS和远程客户端上的WCF服务以从远程客户端PC进行身份验证?_C#_Wcf_Authentication_Iis_Wshttpbinding - Fatal编程技术网

C# 如何配置部署在IIS和远程客户端上的WCF服务以从远程客户端PC进行身份验证?

C# 如何配置部署在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:服务未对调用方进行身份验证 我已经阅读了一些关于这些问题的文章,并且知道我的问题是因为我的服

我是个笨蛋;请帮助我理解这个让我非常困惑的身份验证配置/绑定的东西

我在Win2008的IIS7上部署了一个C#WCF服务。我的客户端是一个Windows Forms C#应用程序。我的客户端在运行WCF服务的同一台服务器上运行时工作正常,但当我尝试从远程PC上运行客户端时,会出现以下异常

System.ServiceModel.Security.SecurityNegotiationException:服务未对调用方进行身份验证

我已经阅读了一些关于这些问题的文章,并且知道我的问题是因为我的服务和客户机被配置为使用Windows身份验证,我猜这是使用Visual Studio创建服务时的默认设置,并将服务引用添加到客户机。下面是我在进行任何更改之前的配置,当时它仍然设置为Windows(删除了不相关的位)

Web.Config

<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绑定和安全性的一些好资源:


我通过将绑定更改为basicHttpBinding、将身份验证更改为表单以及关闭安全性来修复此问题

只有当客户端和服务器位于同一个域上,或者位于彼此信任的域上时,才能使用windows身份验证。如果不是,Windows身份验证将无法工作,因为它取决于两端是否在同一个域或同一系列受信任域中。谢谢,这可能是一个可行的选择。有没有什么好的参考资料可以让我了解不同的安全类型,并了解使用每种安全类型的一些部署场景?到目前为止,我所发现的一切都假设我知道每种安全类型的功能,并且假设我有很多不知道的知识。所以,如果你知道的话,我正在寻找一个初学者的参考资料。也谢谢你的链接,我将试用clear username绑定。@Jim-我添加了一些链接,这些链接在我开始使用WCF时对我很有帮助。我发现MSDN上和Google上都有how-tos,可用于绑定和安全性的几乎所有受支持的组合(例如,这里的传输安全性是在几个不同绑定的上下文中解释的:)关闭安全性是什么意思?
<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"