Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AADClaimsMappingPolicy: Get-TargetResource doesn't find policies already created #5505

Closed
ricmestre opened this issue Dec 4, 2024 · 0 comments · Fixed by #5506 or #5512
Closed

AADClaimsMappingPolicy: Get-TargetResource doesn't find policies already created #5505

ricmestre opened this issue Dec 4, 2024 · 0 comments · Fixed by #5506 or #5512

Comments

@ricmestre
Copy link
Contributor

ricmestre commented Dec 4, 2024

Description of the issue

I'm able to create new AADClaimsMappingPolicy resources, but every time I run the deployment it never finds them and it's duplicating the same resource creating new policies all the time.

This happens because on Get-TargetResource the cmdlet Get-MgBetaPolicyClaimMappingPolicy is being called and the result is then filtered on $_.AdditionalProperties.'@odata.type' -eq "#microsoft.graph.ClaimsMappingPolicy" but the policies have null AdditionalProperties so they're never found, this filter was most likely added automatically by the DRG but in this case is causing an issue.

I'll open a PR for this.

Microsoft 365 DSC Version

1.24.1127.1

Which workloads are affected

Azure Active Directory (Entra ID)

The DSC configuration

AADClaimsMappingPolicy "AADClaimsMappingPolicy-AADClaimsMappingPolicy_1"
        {
            ApplicationId         = $AADApplicationId;
            CertificateThumbprint = $AADCertThumbprint;
            Definition            = @(
                MSFT_AADClaimsMappingPolicyDefinition{
                    ClaimsMappingPolicy = MSFT_AADClaimsMappingPolicyDefinitionMappingPolicy{
                        ClaimsSchema = @(
                            MSFT_AADClaimsMappingPolicyDefinitionMappingPolicyClaimsSchema{
                                SamlClaimType = 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier'
                                Source = 'user'
                                Id = 'userprincipalname'
                            }
                            MSFT_AADClaimsMappingPolicyDefinitionMappingPolicyClaimsSchema{
                                SamlClaimType = 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname'
                                Source = 'user'
                                Id = 'givenname'
                            }
                            MSFT_AADClaimsMappingPolicyDefinitionMappingPolicyClaimsSchema{
                                SamlClaimType = 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name'
                                Source = 'user'
                                Id = 'displayname'
                            }
                            MSFT_AADClaimsMappingPolicyDefinitionMappingPolicyClaimsSchema{
                                SamlClaimType = 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname'
                                Source = 'user'
                                Id = 'surname'
                            }
                            MSFT_AADClaimsMappingPolicyDefinitionMappingPolicyClaimsSchema{
                                SamlClaimType = 'username'
                                Source = 'user'
                                Id = 'userprincipalname'
                            }
                        )
                        ClaimsTransformation = @(
                            MSFT_AADClaimsMappingPolicyDefinitionMappingPolicyClaimsTransformation{
                                OutputClaims = @(
                                    MSFT_AADClaimsMappingPolicyDefinitionMappingPolicyClaimsTransformationOutputClaims{
                                        ClaimTypeReferenceId = 'TOS'
                                        TransformationClaimType = 'createdClaim'
                                    }
                                )
                                Id = 'CreateTermsOfService'
                                InputParameters = @(
                                    MSFT_AADClaimsMappingPolicyDefinitionMappingPolicyClaimsTransformationInputParameter{
                                        DataType = 'string'
                                        Id = 'value'
                                        Value = 'sandbox'
                                    }
                                )
                                TransformationMethod = 'CreateStringClaim'
                            }
                        )
                        IncludeBasicClaimSet = $True
                        Version = 1
                    }
                }
            );
            DisplayName           = "AADClaimsMappingPolicy_1";
            Ensure                = "Present";
            Id                    = "fd0dc3f3-cfdf-4d56-bb03-e18161a5ac93";
            IsOrganizationDefault = $False;
            TenantId              = $OrganizationName;
        }

Verbose logs showing the problem

N/A

Environment Information + PowerShell Version

Win11/PS5.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant