Пример #1
0
        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);
        }
Пример #3
0
        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");

            // add role
            acsWrapper.AddPassThroughRuleToRuleGroup(
                defaultRuleGroup.RuleGroup.Name,
                LitwareIdentityProvider,
                AllOrganizations.ClaimTypes.Group,
                ClaimTypes.Role);

            // 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.");
        }
Пример #4
0
        private static void CreateAdatumRules(ServiceManagementWrapper acsWrapper)
        {
            Console.Write("Creating Adatum.7 mapping rules....");

            var relyingParty         = acsWrapper.RetrieveRelyingParties().Single(rp => rp.Name == "Adatum");
            var defaultRuleGroup     = relyingParty.RelyingPartyRuleGroups.FirstOrDefault();
            var identityProviderName = AdatumIdentityProvider;

            // remove rules
            acsWrapper.RemoveAllRulesInGroup(defaultRuleGroup.RuleGroup.Name);

            // pass name
            acsWrapper.AddPassThroughRuleToRuleGroup(defaultRuleGroup.RuleGroup.Name, identityProviderName, ClaimTypes.Name);

            // transform organization
            acsWrapper.AddPassThroughRuleToRuleGroup(
                defaultRuleGroup.RuleGroup.Name,
                identityProviderName,
                Adatum.ClaimTypes.Organization,
                Fabrikam.ClaimTypes.Organization);

            // add cost center
            acsWrapper.AddPassThroughRuleToRuleGroup(
                defaultRuleGroup.RuleGroup.Name,
                identityProviderName,
                Adatum.ClaimTypes.CostCenter,
                Fabrikam.ClaimTypes.CostCenter);

            // add role
            acsWrapper.AddSimpleRuleToRuleGroupWithoutSpecifyInputClaim(
                defaultRuleGroup.RuleGroup.Name,
                identityProviderName,
                ClaimTypes.Role,
                Fabrikam.Roles.ShipmentCreator);


            // given name
            acsWrapper.AddPassThroughRuleToRuleGroup(
                defaultRuleGroup.RuleGroup.Name,
                identityProviderName,
                ClaimTypes.GivenName,
                ClaimTypes.GivenName);

            // surname
            acsWrapper.AddPassThroughRuleToRuleGroup(
                defaultRuleGroup.RuleGroup.Name,
                identityProviderName,
                ClaimTypes.Surname,
                ClaimTypes.Surname);

            // street address
            acsWrapper.AddPassThroughRuleToRuleGroup(
                defaultRuleGroup.RuleGroup.Name,
                identityProviderName,
                ClaimTypes.StreetAddress,
                ClaimTypes.StreetAddress);


            // state or province
            acsWrapper.AddPassThroughRuleToRuleGroup(
                defaultRuleGroup.RuleGroup.Name,
                identityProviderName,
                ClaimTypes.StateOrProvince,
                ClaimTypes.StateOrProvince);


            // country
            acsWrapper.AddPassThroughRuleToRuleGroup(
                defaultRuleGroup.RuleGroup.Name,
                identityProviderName,
                ClaimTypes.Country,
                ClaimTypes.Country);

            Console.WriteLine("done.");
        }