Microsoft365DSC icon indicating copy to clipboard operation
Microsoft365DSC copied to clipboard

AADConditionalAccessPolicy updating builtinControl mfa to AuthenticationStrength

Open bartvermeersch opened this issue 1 year ago • 3 comments

Description of the issue

When an existing conditional access policy exist with "builtInControls": ['mfa'] and it needs to be changed into authenticationStrength instead, it produces an error.

The empty array for builtinControls is discarded from the request resulting in "1108: Authentication strengths cannot be used alongside the MFA built-in control."

Microsoft 365 DSC Version

1.25.528.1

Which workloads are affected

Azure Active Directory (Entra ID)

The DSC configuration

When applying this DSC:
                @{
                    DisplayName = 'MFA TEST'
                    State = 'enabled'
                    ClientAppTypes = @('All')
                    IncludeApplications = @('All')
                    IncludeGroups = @('Azure-MFA')
                    AuthenticationStrength = 'Multifactor authentication'
                    BuiltInControls = @()
                    GrantControlOperator = 'OR'
                }

The following graph query is created:

{
    "sessionControls": {
        "persistentBrowser": {
            "isEnabled": true,
            "mode": "Always"
        }
    },
    "displayName": "MFA for Guests",
    "grantControls": {
        "authenticationStrength": {
            "id": "00000000-0000-0000-0000-000000000002",
            "@odata.type": "#microsoft.graph.authenticationStrengthPolicy"
        },
        "operator": "OR"
    },
    "conditions": {
        "clientAppTypes": [
            "All"
        ],
        "users": {
            "includeGroups": ["2e05a1f7-1111-2222-3333-a5601431af7f"]
        },
        "applications": {
            "includeApplications": [
                "All"
            ]
        }
    },
    "state": "enabled"
}

However it is missing

"builtInControls":  []

to remove the (legacy) mfa builtInControl despite it being specified through BuiltInControls = @() resulting in the error.

Verbose logs showing the problem

"message": "1108: Authentication strengths cannot be used alongside the MFA built-in control."

Environment Information + PowerShell Version


bartvermeersch avatar Jun 25 '25 08:06 bartvermeersch

Hi Bart,

I suggest creating a policy in Entra ID in a test tenant and exporting this desired policy with Microsoft365DSC. The resulting config will contain the all the parameters for all settings even empty ones. As DSC is short for Desired State, also explicitly unassigned settings need to be explicitly empty, otherwise someone could change the seting to an undesired state and will not be reset by redeployment of you config. The exported config can be adapted for deployment.

I also use the Authentication Strength and BuiltInControls

..... AuthenticationContexts = @(); AuthenticationStrength = " Default MFA"; BuiltInControls = @(); ....

MarzelLaning42 avatar Jun 25 '25 09:06 MarzelLaning42

Sorry If I wasn't clear, I know wat DSC is.

The DSC AADConditionalAccessPolicy resource is not able to correct a policy which is or was using builtinControls (currentValues) but should be using AuthenticationStrength (desiredValues) instead.

bartvermeersch avatar Jun 25 '25 12:06 bartvermeersch

Hi Bart,

I think you are correct and we cannot set authmethod in the same call as removing the builtin controls. I have had issues with this as well. Hopefully someone picks this up. For now I remove the old policy with builtin MFA and create a new one with authmethod.

MarzelLaning42 avatar Jun 26 '25 06:06 MarzelLaning42