azuread_account_provisioning_activity_report_reviewedazuread_admin_consent_workflow_enabledazuread_admin_user_mfa_enabledazuread_all_user_mfa_enabledazuread_audit_log_search_enabledazuread_authorization_policy_accessing_company_data_not_allowedazuread_global_admin_range_restrictedazuread_group_not_publicazuread_guest_user_infoazuread_legacy_authentication_disabledazuread_microsoft_azure_management_limited_to_administrative_rolesazuread_password_protection_enabledazuread_risky_sign_ins_reportazuread_security_default_disabledazuread_signin_frequency_policyazuread_signin_risk_policyazuread_third_party_application_not_allowedazuread_user_password_not_set_to_expireazuread_user_risk_policyazuread_user_sspr_enabledmicrosoft365_calendar_sharing_disabled
Query: azuread_admin_user_mfa_enabled
Usage
powerpipe query microsoft365_compliance.query.azuread_admin_user_mfa_enabled
SQL
with users_having_admin_roles as ( select array_agg(role_template_id) as rid from azuread_directory_role where display_name like '%Administrator'),policy_with_mfa as ( select tenant_id, count(p.*) from azuread_conditional_access_policy as p, users_having_admin_roles as a where p.built_in_controls ?& array['mfa'] and (p.users -> 'includeRoles')::jsonb ?| (a.rid) and jsonb_array_length(p.users -> 'excludeUsers') < 1 group by tenant_id),tenant_list as ( select distinct on (tenant_id) tenant_id, _ctx from azuread_user)select t.tenant_id as resource, case when (select count from policy_with_mfa where tenant_id = t.tenant_id) > 0 then 'ok' else 'alarm' end as status, case when (select count from policy_with_mfa where tenant_id = t.tenant_id) > 0 then t.tenant_id || ' has MFA enabled for all users in administrative roles.' else t.tenant_id || ' has MFA disabled for all users in administrative roles.' end as reason , t.tenant_id as tenant_idfrom tenant_list as t;
Controls
The query is being used by the following controls:
- 1.1.1 Ensure multifactor authentication is enabled for all users in administrative roles
- 1.1.1 Ensure multifactor authentication is enabled for all users in administrative roles
- 1.1.2 Ensure multifactor authentication is enabled for all users in administrative roles
- 5.2.2.1 Ensure multifactor authentication is enabled for all users in administrative roles