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
在2台机器边界(3台机器)上使用模拟时WCF失败_Wcf_Iis_Impersonation_Delegation - Fatal编程技术网

在2台机器边界(3台机器)上使用模拟时WCF失败

在2台机器边界(3台机器)上使用模拟时WCF失败,wcf,iis,impersonation,delegation,Wcf,Iis,Impersonation,Delegation,这些场景各自为政。当我把它们放在一起的时候,它们就碎了 我有一个使用netTCP的WCF服务,该服务使用模拟来获取呼叫者ID(在此级别将使用基于角色的安全性) 除此之外,还有一个WCF服务,它使用basicHTTP和TransportCreditionalOnly,还使用模拟 然后我有一个连接到basicHttp的客户端前端 游戏的目的是从底部的netTCP服务返回客户端用户名,这样我就可以在这里使用基于角色的安全性了 每个服务都位于不同的计算机上,当您在本地和远程为其他服务运行客户端时,当您删

这些场景各自为政。当我把它们放在一起的时候,它们就碎了

我有一个使用netTCP的WCF服务,该服务使用模拟来获取呼叫者ID(在此级别将使用基于角色的安全性)

除此之外,还有一个WCF服务,它使用basicHTTP和TransportCreditionalOnly,还使用模拟

然后我有一个连接到basicHttp的客户端前端

游戏的目的是从底部的netTCP服务返回客户端用户名,这样我就可以在这里使用基于角色的安全性了

每个服务都位于不同的计算机上,当您在本地和远程为其他服务运行客户端时,当您删除它们对其他服务的任何调用时,每个服务都会工作。IE问题仅在您跨越多个机器边界时才会显现

IE当我将每个部件连接在一起时,设置会中断,但它们自己可以正常工作

我还要具体说明

方法中的[OperationBehavior(Impersonation=ImpersonationOption.Required)],以及

将IIS设置为仅允许windows身份验证(实际上,我仍然启用了同名身份验证,但禁用它没有任何区别)

这种模拟在以下场景中工作得很好:我在机器a上有一个netTCP服务,在机器B上有一个basichtp服务的客户端,在机器B上也有一个basichtp服务的clinet。。。但是,如果将该客户端移动到任何计算机C,则会出现以下错误:

例外情况是“套接字连接已中止”。这可能是由于处理消息时出错、远程主机超过接收超时或基础网络资源问题造成的。本地套接字超时为“00:10:00” 内部消息是“远程主机已强制关闭现有连接”

我开始认为这更像是一个网络问题而不是配置问题。。。但我却在抓救命稻草

配置文件如下所示(从客户端到netTCP层)


为客户机提供的服务(basicHttp服务和为netTCP服务提供的客户机)


最后是netTCP层的服务

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="basicHttpBindingEndpoint" closeTimeout="00:02:00"
                    openTimeout="00:02:00" receiveTimeout="00:10:00" sendTimeout="00:02:00"
                    allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                    useDefaultWebProxy="true">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <security mode="TransportCredentialOnly">
                        <transport clientCredentialType="Windows" proxyCredentialType="None"
                            realm="" />
                        <message clientCredentialType="UserName" algorithmSuite="Default" />
                    </security>
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://panrelease01/WCFTopWindowsTest/Service1.svc"
                binding="basicHttpBinding" bindingConfiguration="basicHttpBindingEndpoint"
                contract="ServiceReference1.IService1" name="basicHttpBindingEndpoint" 
 behaviorConfiguration="ImpersonationBehaviour" />
        </client>
  <behaviors>
   <endpointBehaviors>
    <behavior name="ImpersonationBehaviour">
     <clientCredentials>
      <windows allowedImpersonationLevel="Impersonation"/>
     </clientCredentials>
    </behavior>
   </endpointBehaviors>
  </behaviors>
    </system.serviceModel>
</configuration>
<?xml version="1.0" encoding="UTF-8"?>
<configuration>

  <system.web>
   <authentication mode="Windows"></authentication>
   <authorization>
    <allow roles="*"/>
   </authorization>
    <compilation debug="true" targetFramework="4.0" />
        <identity impersonate="true" />
  </system.web>
  <system.serviceModel>
   <bindings>
    <netTcpBinding>
     <binding name="netTCPwindows">
      <security mode="Transport">
       <transport clientCredentialType="Windows"></transport>
      </security>
     </binding>
    </netTcpBinding>
   </bindings>
   <services>
    <service behaviorConfiguration="netTCPwindows.netTCPwindowsBehaviour" name="netTCPwindows.Service1">
     <endpoint address="" bindingConfiguration="netTCPwindows" binding="netTcpBinding" name="netTcpBindingEndpoint" contract="netTCPwindows.IService1">
      <identity>
       <dns value="localhost" />
      </identity>
     </endpoint>  
     <endpoint address="mextcp" binding="mexTcpBinding" contract="IMetadataExchange"/>
     <host>
      <baseAddresses>     
       <add baseAddress="net.tcp://localhost:8721/test2" />
      </baseAddresses>
     </host>
    </service>       
   </services>   
    <behaviors>  
      <serviceBehaviors>
        <behavior name="netTCPwindows.netTCPwindowsBehaviour">  

          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="false" />
          <!-- 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="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
        <directoryBrowse enabled="true" />
  </system.webServer>

</configuration>

如果您需要进行一次以上的跳跃,则需要为该跳跃启用委派。你可以得到更多的信息


也就是说,如果您只需要确定调用后端服务(netTcp)的用户的角色,则不一定需要模拟,因为WindowsIdentity的TokenImpersonationLevel应该只是确定角色成员身份的信息。在这种情况下,您只需确保模拟在中间层(basicHttp)进行。

谢谢您提供的信息。我需要的不仅仅是他们的授权信息,因为数据可能来自多个来源——其中一些来源是我无法控制的。访问角色信息的目的是为了实现基于角色的声明性安全性。(我正在尽我所能使我的安全实施得到支持和独立。)。由于该信息具有洞察力,因此给出a+1:D
<?xml version="1.0" encoding="UTF-8"?>
<configuration>

  <system.web>
   <authentication mode="Windows"></authentication>
   <authorization>
    <allow roles="*"/>
   </authorization>
    <compilation debug="true" targetFramework="4.0" />
        <identity impersonate="true" />
  </system.web>
  <system.serviceModel>
   <bindings>
    <netTcpBinding>
     <binding name="netTCPwindows">
      <security mode="Transport">
       <transport clientCredentialType="Windows"></transport>
      </security>
     </binding>
    </netTcpBinding>
   </bindings>
   <services>
    <service behaviorConfiguration="netTCPwindows.netTCPwindowsBehaviour" name="netTCPwindows.Service1">
     <endpoint address="" bindingConfiguration="netTCPwindows" binding="netTcpBinding" name="netTcpBindingEndpoint" contract="netTCPwindows.IService1">
      <identity>
       <dns value="localhost" />
      </identity>
     </endpoint>  
     <endpoint address="mextcp" binding="mexTcpBinding" contract="IMetadataExchange"/>
     <host>
      <baseAddresses>     
       <add baseAddress="net.tcp://localhost:8721/test2" />
      </baseAddresses>
     </host>
    </service>       
   </services>   
    <behaviors>  
      <serviceBehaviors>
        <behavior name="netTCPwindows.netTCPwindowsBehaviour">  

          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="false" />
          <!-- 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="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
        <directoryBrowse enabled="true" />
  </system.webServer>

</configuration>