Uwierzytelnianie przeciwko ADFS z WCF hostowanym w usłudze Windows
Mam usługę wcf, która wysyła zapytanie do ADFS o token SAML. Jest to wspólny fragment z sieci WWW do zapytania ADFS i odzyskania tokenu SAML. Jednak zawsze kończy się na liniikanał zwrotny. Problem (pierwszy); . Błąd to ID3082: Zakres żądania jest nieprawidłowy lub nie jest obsługiwany. Przynajmniej na wysokim poziomie nie jestem w stanie dowiedzieć się, czy błąd występuje na końcu serwera ADFS, czy też w jaki sposób usługa WCF jest skonfigurowana lub z kodem. Proszę pomóż.
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();
}
}
}