我有一个wcf服务,它向ADFS查询SAML令牌。这是从Web查询ADFS并获取SAML令牌的常见代码段。但是,它总是最终在返回行通道处中断。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();
}
}
}
问题出在
AppliesTo = new EndpointAddress("net.tcp://localhost:xxxx/Service1/mex")
我用一个依赖方uri替换了它,并向我发行了令牌。唯一的问题是令人困惑的错误消息。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句