2016-09-23 91 views
1

我已將IIS WCF Web服務設置爲使用Windows身份驗證(通過https)並訪問WSDL我從服務器獲取請求以進行身份​​驗證,然後工作。所以一切都很好。WCF:無法爲具有權限的SSL/TLS安全通道建立信任關係

但是,我無法弄清楚如何通過當前用戶的Windows憑據,我不斷收到在主題中詳細的錯誤。

這是服務器的web.config:

<?xml version="1.0" encoding="UTF-8"?> 
    <configuration> 
    <system.serviceModel> 

     <bindings> 
     <wsHttpBinding> 
      <binding name="wsBindingTest"> 
      <security mode="Transport"> 
       <message negotiateServiceCredential="true" clientCredentialType="Windows"/> 
       <transport clientCredentialType="Windows"/> 
      </security> 
      </binding> 
     </wsHttpBinding> 
     </bindings> 

     <protocolMapping> 
     <remove scheme="http" /> 
     <add scheme="http" binding="wsHttpBinding" bindingConfiguration="wsBindingTest" /> 
     </protocolMapping> 

     <behaviors> 
     <serviceBehaviors> 
      <behavior name=""> 
      <serviceMetadata httpGetEnabled="true" /> 
      <serviceDebug includeExceptionDetailInFaults="true" /> 
      </behavior> 
     </serviceBehaviors> 
     </behaviors> 

     <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
    </system.serviceModel> 
    </configuration> 

這是客戶:

<?xml version="1.0" encoding="utf-8" ?> 
    <configuration> 
     <system.serviceModel> 
      <bindings> 
       <wsHttpBinding> 
        <binding name="BasicHttpBinding_ITRIMService"> 
        <security mode="Transport"> 
         <transport clientCredentialType="Windows" proxyCredentialType="None" /> 
         <message clientCredentialType="Windows" negotiateServiceCredential="true"/> 
        </security> 
        </binding> 
       </wsHttpBinding> 
      </bindings> 
      <client> 
       <endpoint address="https://servername.net/TRIMDev/TRIMService.svc" 
        binding="wsHttpBinding" bindingConfiguration="BasicHttpBinding_ITRIMService" 
        contract="Service.ITRIMService" name="BasicHttpBinding_ITRIMService"> 
        <identity> 
         <servicePrincipalName value="host/servername.net" /> 
        </identity> 
       </endpoint> 
      </client> 
     </system.serviceModel> 
    </configuration> 

這是最終創建信道的代碼:

ConfigurationChannelFactory<ITRIMService> channelFactory = new ConfigurationChannelFactory<ITRIMService>("BasicHttpBinding_ITRIMService", config, null); 
var channel = channelFactory.CreateChannel(); 

我試圖將以下內容添加到客戶端配置中,沒有運氣,希望可以在不必將任何代碼編入t的情況下完成他的客戶:

<system.web> 
     <identity impersonate="true"/> 
     <authentication mode="Windows" /> 
    </system.web> 

任何幫助將非常感激,因爲我只是不知道,足以知道爲什麼它不工作。

回答

0

Windows身份驗證不支持wsHttpBinding,它僅支持NetTcpBinding。參考信息here

+0

我不這麼認爲,wsHTTPbinding是當前版本,而wsBasic是遺留的。 但是,我有它的工作,但我不完全確定爲什麼。如果我有部分,它會起作用,但如果它被移除,它將通過匿名傳遞 –

相關問題