在MVC应用程序中,用户身份验证STS (ADFS)
适用于一个ADFS
,但我想在运行时为ADFS
中配置的不同Web.config
更改all参数像这样:
权威名称
validIssuers
发行人(在system.identityModel.services
部分)
等
答案 0 :(得分:1)
我已经完成了这个问题。 我们可以动态更改以下所有参数:
FederatedAuthentication.FederationConfiguration.IdentityConfiguration.IssuerNameRegistry = new Trust(trust);
FederatedAuthentication.FederationConfiguration.IdentityConfiguration.AudienceRestriction.AllowedAudienceUris.Add(new Uri("https://localhost:44300"));
FederatedAuthentication.FederationConfiguration.WsFederationConfiguration.PassiveRedirectEnabled = true;
FederatedAuthentication.FederationConfiguration.WsFederationConfiguration.Issuer = "https://sts.domainame.com/adfs/ls/";
FederatedAuthentication.FederationConfiguration.WsFederationConfiguration.Realm = "https://localhost:44300";
信任类:
public class Trust : IssuerNameRegistry
{
string trust;
public Trust(string trust)
{
this.trust= trust;
}
public override string GetIssuerName(SecurityToken securityToken)
{
return trust;
}
}