2011-06-13 89 views
0

我希望能够像使用basicHttpBinding一样指定我的自定义绑定的安全级别。WCF使用Kerberos配置CustomBinding

<customBinding> 
    <binding name="jsonpBinding" >  
     ....     
     <security mode="TransportCredentialOnly"> 
      <transport clientCredentialType="Windows"/> 
     </security> 
    </binding> 
    </customBinding> 

如何正确地做到这一点,因为它不被接受?

+2

你甚至尝试使用谷歌搜索“wcf kerberos”吗?这回答了你的问题了吗?第一个结果:http://stackoverflow.com/questions/1295526/wcf-and-kerberos-authentication – Amy 2011-06-13 17:31:20

+0

@Inuyasha这是特定于CustomBinding它与basicHttpBinding工作正常。 – Jonathan 2011-06-13 17:33:46

回答

0

加入authenticationScheme="Negotiate"解决了这个问题。

添加到您的WCF方法

[OperationBehavior(Impersonation = ImpersonationOption.Required)] 
public int Dosomething() 
{ 
... 
} 

添加到您的WCF的web.config

<customBinding>  
    <binding name="jsonpBinding" >    
     <jsonMessageEncoding/> 
     <httpTransport manualAddressing="true" authenticationScheme="Negotiate"/> 
    </binding> 
</customBinding> 

添加以下到您的客户端(MVC Web应用程序在我的情况)。值得注意的是,svcutil应用程序不会为您的客户端存根产生行为,您必须将其添加为manualy。这让我有一段时间!

<client> 
      <endpoint address="..." 
       binding="customBinding" bindingConfiguration="..." 
       contract="..." name="..." behaviorConfiguration="ImpersonationBehavior" />   
     </client> 
     <behaviors> 
      <endpointBehaviors> 
      <behavior name="ImpersonationBehavior"> 
       <clientCredentials> 
       <windows allowedImpersonationLevel="Impersonation"/> 
       </clientCredentials> 
      </behavior>    
      </endpointBehaviors>   
     </behaviors>