我有一個wcf服務,用於查詢ADFS的SAML令牌。這是從Web查詢ADFS的常見片段,並取回SAML令牌。 然而,它總是在行返回channel.Isue(rst); 。錯誤ID3082:請求範圍無效或不受支持。 至少在高層次上,我無法弄清楚錯誤是在ADFS服務器端,還是在配置WCF服務的方式或代碼。請幫忙。使用WCF託管在Windows服務上針對ADFS進行身份驗證
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();
}
}
}
博客上顯示「ID3082:請求範圍無效或不受支持,其中一個原因可能是您的應用程序沒有在ADFS中設置依賴方信任關係。」那麼這是否意味着我的wcf服務必須作爲依賴方加入?我是ADFS 2.0的完全新手。我看過關於如何配置依賴方的文章,但是我們是否也爲WCF服務做了同樣的事情?在這個時候,我還沒有物理訪問ADFS服務器。 – simba
既然你特別提到ADFS的觀點,我認爲我必須接受你的答案 – simba