【发布时间】:2013-10-24 09:45:42
【问题描述】:
我有一个 wcf 服务,它可以在 ADFS 中查询 SAML 令牌。这是从网络查询 ADFS 并取回 SAML 令牌的常见 sn-p。 然而,它总是在 return channel.Issue(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();
}
}
}
【问题讨论】: