使用Windows身份验证自托管WCF

时间:2013-10-01 14:10:14

标签: c# .net wcf authentication

我有一个Windows服务,它在里面托管WCF服务。 下面是端点初始化方式的定义:

WebHttpBinding binding = new WebHttpBinding(WebHttpSecurityMode.TransportCredentialOnly);
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
string url = ConfigurationManager.AppSettings["serviceUrl"];
Uri baseAddress = new Uri(url);
Uri metadataAddress = new Uri(url + "Description");
CallService service = new CallService(controller);
ServiceHost host = new WebServiceHost(service);

host.AddServiceEndpoint(typeof (ICallService), binding, baseAddress);
host.Authorization.PrincipalPermissionMode = PrincipalPermissionMode.UseWindowsGroups;
ServiceDebugBehavior stp = host.Description.Behaviors.Find<ServiceDebugBehavior>();
stp.HttpHelpPageEnabled = true;

ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
smb.HttpGetEnabled = true;
smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
smb.HttpGetUrl = metadataAddress;
host.Description.Behaviors.Add(smb);
host.Open();

问题是,当使用计算机名称(例如http://mycomputer.mydomain.int:4544/Somthing)访问此WCF服务时,我首先收到一个身份验证窗口,然后是HTTP:400。
如果使用http://localhost:4544/Something,访问服务或关闭Windows身份验证,则一切正常。

它出了什么问题?

0 个答案:

没有答案