private static void CreateContosoRules(ServiceManagementWrapper acsWrapper) { Console.Write("Creating Contoso mapping rules...."); var identityProviderName = "Windows Live ID"; var relyingParty = acsWrapper.RetrieveRelyingParties().Single(rp => rp.Name == "Contoso"); var defaultRuleGroup = relyingParty.RelyingPartyRuleGroups.FirstOrDefault(); // remove rules acsWrapper.RemoveAllRulesInGroup(defaultRuleGroup.RuleGroup.Name); // add name acsWrapper.AddSimpleRuleToRuleGroup( defaultRuleGroup.RuleGroup.Name, identityProviderName, ClaimTypes.NameIdentifier, null, ClaimTypes.Name, "rick"); // add organization acsWrapper.AddSimpleRuleToRuleGroupWithoutSpecifyInputClaim( defaultRuleGroup.RuleGroup.Name, identityProviderName, Fabrikam.ClaimTypes.Organization, "Contoso"); // add cost center acsWrapper.AddSimpleRuleToRuleGroupWithoutSpecifyInputClaim( defaultRuleGroup.RuleGroup.Name, identityProviderName, Fabrikam.ClaimTypes.CostCenter, Contoso.CostCenters.SingleCostCenter); // add role acsWrapper.AddSimpleRuleToRuleGroupWithoutSpecifyInputClaim( defaultRuleGroup.RuleGroup.Name, identityProviderName, ClaimTypes.Role, Fabrikam.Roles.ShipmentCreator); // given name acsWrapper.AddSimpleRuleToRuleGroupWithoutSpecifyInputClaim( defaultRuleGroup.RuleGroup.Name, identityProviderName, ClaimTypes.GivenName, "Rick"); // surname acsWrapper.AddSimpleRuleToRuleGroupWithoutSpecifyInputClaim(defaultRuleGroup.RuleGroup.Name, identityProviderName, ClaimTypes.Surname, "Rico"); Console.WriteLine("done."); }
private void CreateRulesForTenantWithOwnIP(string organizationInternalName, string identityProviderName, ServiceManagementWrapper acsWrapper, string ruleGroup, string adminClaimType, string adminClaimValue, string costCenterClaimType) { // name acsWrapper.AddPassThroughRuleToRuleGroup(ruleGroup, identityProviderName, ClaimTypes.Name); // add organization acsWrapper.AddSimpleRuleToRuleGroupWithoutSpecifyInputClaim(ruleGroup, identityProviderName, Fabrikam.ClaimTypes.Organization, organizationInternalName); if (!string.IsNullOrEmpty(costCenterClaimType)) { // add costcenter acsWrapper.AddPassThroughRuleToRuleGroup(ruleGroup, identityProviderName, costCenterClaimType, Fabrikam.ClaimTypes.CostCenter); } // add role acsWrapper.AddSimpleRuleToRuleGroup(ruleGroup, identityProviderName, adminClaimType, adminClaimValue, Microsoft.IdentityModel.Claims.ClaimTypes.Role, Fabrikam.Roles.ShipmentCreator); // add role acsWrapper.AddSimpleRuleToRuleGroup(ruleGroup, identityProviderName, adminClaimType, adminClaimValue, Microsoft.IdentityModel.Claims.ClaimTypes.Role, Fabrikam.Roles.Administrator); }
private void CreateRulesForTenantWithSocialIP(string organizationInternalName, string identityProviderName, ServiceManagementWrapper acsWrapper, string ruleGroup, string nameIdentifierValue) { // pass nameidentifier acsWrapper.AddSimpleRuleToRuleGroup(ruleGroup, identityProviderName, ClaimTypes.NameIdentifier, nameIdentifierValue, ClaimTypes.NameIdentifier, nameIdentifierValue); // pass name if (identityProviderName.Equals(SocialIdentityProviders.WindowsLiveId)) { acsWrapper.AddSimpleRuleToRuleGroup(ruleGroup, identityProviderName, ClaimTypes.NameIdentifier, nameIdentifierValue, ClaimTypes.Name, nameIdentifierValue); } else { var userName = ClaimHelper.GetCurrentUserClaim(ClaimTypes.Name).Value; acsWrapper.AddSimpleRuleToRuleGroup(ruleGroup, identityProviderName, ClaimTypes.NameIdentifier, nameIdentifierValue, ClaimTypes.Name, userName); } // add organization acsWrapper.AddSimpleRuleToRuleGroup(ruleGroup, identityProviderName, ClaimTypes.NameIdentifier, nameIdentifierValue, Fabrikam.ClaimTypes.Organization, organizationInternalName); // add costcenter acsWrapper.AddSimpleRuleToRuleGroup(ruleGroup, identityProviderName, ClaimTypes.NameIdentifier, nameIdentifierValue, Fabrikam.ClaimTypes.CostCenter, Fabrikam.ClaimValues.SingleCostCenter); // add role acsWrapper.AddSimpleRuleToRuleGroup(ruleGroup, identityProviderName, ClaimTypes.NameIdentifier, nameIdentifierValue, Microsoft.IdentityModel.Claims.ClaimTypes.Role, Fabrikam.Roles.ShipmentCreator); // add role acsWrapper.AddSimpleRuleToRuleGroup(ruleGroup, identityProviderName, ClaimTypes.NameIdentifier, nameIdentifierValue, Microsoft.IdentityModel.Claims.ClaimTypes.Role, Fabrikam.Roles.Administrator); }
private static void CreateAOrderRules(ServiceManagementWrapper acsWrapper) { Console.Write(string.Format("Creating {0} mapping rules....", AOrderRelyingParty)); var relyingParty = acsWrapper.RetrieveRelyingParties().Single(rp => rp.Name == AOrderRelyingParty); var defaultRuleGroup = relyingParty.RelyingPartyRuleGroups.FirstOrDefault(); // remove rules acsWrapper.RemoveAllRulesInGroup(defaultRuleGroup.RuleGroup.Name); // add cost center acsWrapper.AddPassThroughRuleToRuleGroup( defaultRuleGroup.RuleGroup.Name, LitwareIdentityProvider, Litware.ClaimTypes.CostCenter, Litware.ClaimTypes.CostCenter); // country acsWrapper.AddPassThroughRuleToRuleGroup( defaultRuleGroup.RuleGroup.Name, LitwareIdentityProvider, ClaimTypes.Country, ClaimTypes.Country); // given name acsWrapper.AddPassThroughRuleToRuleGroup( defaultRuleGroup.RuleGroup.Name, LitwareIdentityProvider, ClaimTypes.GivenName, ClaimTypes.GivenName); // pass name acsWrapper.AddPassThroughRuleToRuleGroup( defaultRuleGroup.RuleGroup.Name, LitwareIdentityProvider, ClaimTypes.Name); // add organization acsWrapper.AddSimpleRuleToRuleGroupWithoutSpecifyInputClaim( defaultRuleGroup.RuleGroup.Name, LitwareIdentityProvider, Adatum.ClaimTypes.Organization, "Litware"); // transform group into role acsWrapper.AddSimpleRuleToRuleGroup( defaultRuleGroup.RuleGroup.Name, LitwareIdentityProvider, AllOrganizations.ClaimTypes.Group, Litware.Groups.Sales, ClaimTypes.Role, Adatum.Roles.OrderTracker); acsWrapper.AddSimpleRuleToRuleGroup( defaultRuleGroup.RuleGroup.Name, LitwareIdentityProvider, AllOrganizations.ClaimTypes.Group, Litware.Groups.SalesManager, ClaimTypes.Role, Adatum.Roles.OrderApprover); // state or province acsWrapper.AddPassThroughRuleToRuleGroup( defaultRuleGroup.RuleGroup.Name, LitwareIdentityProvider, ClaimTypes.StateOrProvince, ClaimTypes.StateOrProvince); // street address acsWrapper.AddPassThroughRuleToRuleGroup( defaultRuleGroup.RuleGroup.Name, LitwareIdentityProvider, ClaimTypes.StreetAddress, ClaimTypes.StreetAddress); // surname acsWrapper.AddPassThroughRuleToRuleGroup( defaultRuleGroup.RuleGroup.Name, LitwareIdentityProvider, ClaimTypes.Surname, ClaimTypes.Surname); Console.WriteLine("done."); }