我有一個使用basicHttpBinding和IIS 7託管的NTLM(禁用匿名身份驗證並啓用Windows身份驗證)的WCF Web服務。 AppPool使用傳遞身份驗證。我有一個遠程連接到Web服務的控制檯應用程序。如何使用NTLM對使用WCF Web服務的控制檯應用程序進行身份驗證?
如果我使用連接我的域用戶,該過程成功連接。如果我連接使用的域創建一個新的服務帳戶,我收到以下錯誤:
The HTTP request is unauthorized with client authentication scheme 'Ntlm'. The authentication header received from the server was 'NTLM'.
內部異常是:
The remote server returned an error: (401) Unauthorized.
這與域帳戶有問題還是我的身份驗證方案?錯誤消息意味着它是身份驗證方案,但它爲什麼會在我的帳戶下工作,而不是在同一個域上創建的服務帳戶?
服務器配置
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm" proxyCredentialType="None" realm="" />
</security>
客戶消費
public static WMServiceClient CreateWMServiceProxy()
{
var proxy = new WMServiceClient();
proxy.Endpoint.Address = new EndpointAddress(ConfigurationCache.WMServiceEndpoint);
proxy.Endpoint.Binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly)
{
MaxBufferSize = 2147483647,
MaxReceivedMessageSize = 2147483647
};
((BasicHttpBinding) proxy.Endpoint.Binding).Security.Transport.ClientCredentialType = HttpClientCredentialType.Ntlm;
return proxy;
}
這些消息往往會有內部異常,解釋引擎蓋下正在發生的事情。我的第一個想法是,該服務帳戶沒有適當的AD權限來驗證您的身份。 – Sean 2012-04-26 05:28:32
好點 - 我會抓住內部的異常並將我發現的內容回傳。 – 2012-04-26 14:11:17
更新後的內部例外。看起來像一個401.我會得到安全團隊。 – 2012-04-26 14:22:49