【问题标题】:Using Windows Authenticated WCF services使用 Windows Authenticated WCF 服务
【发布时间】:2012-03-20 05:52:32
【问题描述】:

我有一个经过 Windows 身份验证的 WCF 服务。

使用如下配置:

BasicHttpBinding binding = new BasicHttpBinding();
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Ntlm;
binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;

binding.SendTimeout = TimeSpan.FromMinutes(60);
binding.CloseTimeout = TimeSpan.FromMinutes(60);
binding.OpenTimeout = TimeSpan.FromMinutes(60);
binding.ReceiveTimeout = TimeSpan.FromMinutes(60);

NexumCrmServiceClient client = new NexumCrmServiceClient(binding, new EndpointAddress("http://xxxxxx:81/xxxxxxxxxxxxxx.svc"));
client.ClientCredentials.Windows.AllowNtlm = true;
//client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
client.ClientCredentials.Windows.ClientCredential = new System.Net.NetworkCredential("xxxxxxxx", "xxxxxxxx", "xxxxxxxxx");

我收到此错误:

没有端点监听 http://xxxxxx:81/xxxxxxxxxxxxxxxx.svc 可以接受该消息。 这通常是由不正确的地址或 SOAP 操作引起的。看 InnerException,如果存在,更多细节...

如果我使用下面的配置:

BasicHttpBinding binding = new BasicHttpBinding();
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Ntlm;

binding.SendTimeout = TimeSpan.FromMinutes(60);
binding.CloseTimeout = TimeSpan.FromMinutes(60);
binding.OpenTimeout = TimeSpan.FromMinutes(60);
binding.ReceiveTimeout = TimeSpan.FromMinutes(60);

NexumCrmServiceClient client = new NexumCrmServiceClient(binding, new EndpointAddress("http://xxxxxx:81/xxxxxxxxxxxxxx.svc"));
client.ClientCredentials.Windows.AllowNtlm = true;
//client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
client.ClientCredentials.Windows.ClientCredential = new System.Net.NetworkCredential("xxxxxxxx", "xxxxxxxx", "xxxxxxxxx");

我收到另一个错误:

HTTP 请求未经客户端身份验证方案授权 '匿名的'。从服务器收到的身份验证标头是 '协商,NTLM'。

您能推荐一个成功的配置吗?

提前致谢,

【问题讨论】:

  • 请发布您的服务配置,以便提供准确的答案。

标签: wcf wcf-security windows-authentication


【解决方案1】:

相信你需要设置:

binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows

获取您的问题标题所指的内容。另外,请查看此MSDN article 使用带有 basicHttpBinding 的 Windows 身份验证。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-13
    • 2010-11-04
    • 2011-06-15
    相关资源
    最近更新 更多