我遵循了許多msdn文章和codeplex指導,但無法讓WCF與Kerberos身份驗證和委派一起工作,並希望得到一些幫助。WCF和Kerberos身份驗證
設置
我有一個IIS網站的WCF服務的遠程機
- 在IIS 6.0在Windows 2003 R2 - SP 2
- 的SPN機已添加(http/myserver & & http/myserver:8080)
- 爲IIS應用程序池創建了一個AD帳戶
- 廣告帳戶的設置,允許委派(使用Kerberos),設置爲true
我使用8080 Brian Booth's debug site和站點通行證Kerberos委派的所有要求。調試IIS站點關閉了匿名身份驗證,並啓用了集成Windows身份驗證。
我已將這些設置鏡像到承載WCF服務的網站。
Web服務 - Web配置(原件)
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WsHttpBindingConfig">
<security>
<message negotiateServiceCredential="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="ServiceBehavior" name="Service">
<endpoint address=""
binding="wsHttpBinding"
bindingConfiguration="WsHttpBindingConfig"
contract="IService">
<identity>
<servicePrincipalName value="http/myserver" />
<dns value="" />
</identity>
</endpoint>
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceAuthorization
impersonateCallerForAllOperations="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
Web服務 - Web方法
[OperationBehavior(Impersonation = ImpersonationOption.Required)]
public string GetCurrentUserName()
{
string name = WindowsIdentity.GetCurrent().Name;
return name;
}
客戶端應用 - 應用程序配置
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IService"
... />
...
<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://myserver/Service.svc"
binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IService"
contract="KerberosService.IService"
name="WSHttpBinding_IService">
<identity>
<servicePrincipalName value="http/myserver" />
</identity>
</endpoint>
</client>
</system.serviceModel>
應用程序錯誤
當我的測試應用程序,WinForms應用程序,試圖調用web方法發生以下錯誤:
「的HTTP請求是未經授權的 客戶認證方案 ‘匿名’ 。認證頭從服務器接收 是 '協商,NTLM'「
事件日誌
下面的錯誤是在事件日誌中:
例外: 系統.ServiceModel.ServiceActivationException: 由於 compila中的異常,服務「/Service.svc」不能爲 激活灰。 的例外消息是:此服務的安全設置 需要「匿名」身份驗證,但 未啓用託管此服務的IIS 應用程序。
我不明白。此服務的重點是不允許匿名身份驗證,每個用戶/請求必須使用Kerberos票據進行身份驗證,然後將其傳遞到其他計算機。
我應該如何配置此WCF服務以進行Kerberos身份驗證和委派?
修訂1
讀取this SO question後我刪除元數據端點。這並沒有解決這個問題。
修訂2
更多研發後,我發現了幾個帖子建議改變的wsHttpBinding到basicHttpBinding的。對web.config的那部分的修改已經包含在下面,並且服務端點已經被更新以引用該綁定。
Web服務 - Web配置(修訂)
<basicHttpBinding>
<binding name="basicBindingConfig">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows"
proxyCredentialType="Windows"
realm="" />
</security>
</binding>
</basicHttpBinding>
客戶端應用 - 應用程序配置(修訂)
<!-- ... -->
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows"
proxyCredentialType="Windows"
realm="" />
<message clientCredentialType="UserName"
algorithmSuite="Default" />
</security>
<!-- ... -->
錯誤(修訂)
目前錯誤看起來像包含Kerberos驗證碼驗證標頭。
HTTP請求是未經授權的客戶端 認證方案 '協商'。從服務器接收認證頭 是 「協商SOMEHUGESCARYKEYHERE
請注意,我發佈和刪除了類似的東西昨天,這篇文章包括基於更多的研究修訂,應該更清晰的閱讀。 – blu 2009-08-18 18:02:22
我根據marc_s的反饋添加了修改後的應用配置。 – blu 2009-08-18 21:06:44