Mvc应用程序,用户身份验证STS(ADFS)

时间:2016-04-07 12:48:56

标签: authentication claims-based-identity adfs

在MVC应用程序中,用户身份验证STS (ADFS)适用于一个ADFS,但我想在运行时为ADFS中配置的不同Web.config更改all参数像这样:

权威名称 validIssuers 发行人(在system.identityModel.services部分) 等

1 个答案:

答案 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;
    }
}