/// <summary> /// Assigns the <paramref name="ruleGroup"/> to the <paramref name="relyingParty"/> /// </summary> /// <param name="svc"></param> /// <param name="ruleGroup">Relying party</param> /// <param name="relyingParty">Rule group</param> public static void AssignRuleGroupToRelyingParty(this ManagementService svc, RuleGroup ruleGroup, RelyingParty relyingParty) { RelyingPartyRuleGroup relyingPartyRuleGroup = new RelyingPartyRuleGroup(); svc.AddToRelyingPartyRuleGroups(relyingPartyRuleGroup); svc.AddLink(relyingParty, "RelyingPartyRuleGroups", relyingPartyRuleGroup); svc.AddLink(ruleGroup, "RelyingPartyRuleGroups", relyingPartyRuleGroup); }
public static RuleGroup AddPassthroughRule(this ManagementService svc, RelyingParty relyingParty, string ruleGroupName) { Contract.Requires(svc != null); Contract.Requires(relyingParty != null); Contract.Requires(!string.IsNullOrWhiteSpace(ruleGroupName)); var ruleGroup = new RuleGroup() { Name = ruleGroupName }; svc.AddToRuleGroups(ruleGroup); svc.SaveChanges(SaveChangesOptions.Batch); var localAuthority = svc.Issuers.Where( m => m.Name == "LOCAL AUTHORITY").FirstOrDefault(); var passthrough = new Rule(); passthrough.Description = "Passthough all ACS claims"; svc.AddToRules(passthrough); svc.SetLink(passthrough, "RuleGroup", ruleGroup); svc.SetLink(passthrough, "Issuer", localAuthority); var rprg = new RelyingPartyRuleGroup(); svc.AddToRelyingPartyRuleGroups(rprg); svc.AddLink(relyingParty, "RelyingPartyRuleGroups", rprg); svc.AddLink(ruleGroup, "RelyingPartyRuleGroups", rprg); svc.SaveChanges(SaveChangesOptions.Batch); return(ruleGroup); }