使用Windows服务上托管的WCF对ADFS进行身份validation

我有一个wcf服务,查询ADFS的SAML令牌。 这是从Web到查询ADFS并获取SAML令牌的常见代码段。 然而它总是最终在线返回通道处断开。问题(rst); 错误是ID3082:请求范围无效或不受支持。 至少在高级别,我无法确定错误是在ADFS服务器端还是在配置WCF服务的方式或代码中。 请帮忙。

public SecurityToken GetSamlToken() { using (var factory = new WSTrustChannelFactory( new UserNameWSTrustBinding(SecurityMode.TransportWithMessageCredential), new EndpointAddress(new Uri("https://serv/adfs/services/trust/13/usernamemixed")))) { factory.Credentials.UserName.UserName = "username"; factory.Credentials.UserName.Password = "password"; factory.Credentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None; factory.TrustVersion = TrustVersion.WSTrust13; WSTrustChannel channel = null; try { string KeyType; var rst = new RequestSecurityToken { RequestType = WSTrust13Constants.RequestTypes.Issue, AppliesTo = new EndpointAddress("net.tcp://localhost:xxxx/Service1/mex"), KeyType = Microsoft.IdentityModel.Protocols.WSTrust.WSTrust13Constants.KeyTypes.Bearer, }; channel = (WSTrustChannel)factory.CreateChannel(); return channel.Issue(rst); } finally { if (channel != null) { channel.Abort(); } factory.Abort(); } } } 

问题在于

 AppliesTo = new EndpointAddress("net.tcp://localhost:xxxx/Service1/mex") 

我用一个依赖方uri替换它,它向我发出令牌。 这里唯一的问题是令人困惑的错误消息。

该错误可能与ADFS端点的配置有关。 以下文章似乎提供了ADFS Web服务通信的良好概述以及解决某些问题的步骤:

http://msinnovations.wordpress.com/2011/03/28/some-tips-on-active-federation-with-adfs-2-0/

为了获得有关错误发生位置(以及可能原因)的更多信息,您可能需要/需要配置WCF跟踪/日志记录。 以下链接提供了概述:

http://msdn.microsoft.com/en-us/library/ms733025.aspx

问候,