2016-04-07 62 views
0

在MVC應用程序,對於一個ADFS工作的用戶認證STS (ADFS),但我想在運行時不同ADFS它們在Web.config配置這樣的改變所有參數:MVC應用程序,用戶認證STS(ADFS)

機構名稱 validIssuers 發行人(在system.identityModel.services節) 等

回答

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