客户端初始化的先前版本如下:
var client = new ReportExecutionService
{
Url = url,
Credentials = new NetworkCredential(username, password, domain)
});
这是新版本的代码:
var basicHttpBinding = new BasicHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly);
basicHttpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Ntlm;
var endpointAddress = new EndpointAddress(url);
var client = new ReportExecutionServiceSoapClient(basicHttpBinding, endpointAddress);
client.ClientCredentials.Windows.ClientCredential = new NetworkCredential(username, password, domain);
新客户端失败,出现401错误。我已经使用Fiddler检查了请求,它们都具有相似的身份验证令牌格式:
Authorization: NTLM long_base64_string
但是值不同。 NetworkCredential
用相同的值初始化。令牌不同的原因可能是什么?有没有办法解码这些令牌以检查两种情况下实际发送的内容?常规的base64解码会给我一个以NTLMSSP
开头的字符串,然后是一些二进制数据
答案 0 :(得分:0)
最后通过设置AllowedImpersonationLevel
来解决:
client.ClientCredentials.Windows.AllowedImpersonationLevel = TokenImpersonationLevel.Impersonation;