azure - 在 Azure AD 上启用 MFA 需要什么级别的权限

标签 azure azure-active-directory azure-powershell azure-automation multi-factor-authentication

需要在 Azure AD 上对我通过自动化帐户使用 powershell 创建的用户帐户启用 MFA,该帐户将在混合工作线程上运行,因此在创建用户时将设置几秒钟的计时器 **Start-Sleep -Seconds * * 要执行 MFA 操作,请协助我了解 Azure Ad 的权限、模块和连接类型,以便使用 Azure AD 上的 powershell 脚本使用自动化帐户启用 MFA,我找到了一些有用的文档,但有基于门户的策略。提前致谢

最佳答案

To enable MFA on Azure AD, you need to have roles like Global Administrator or Security Administrator or Conditional Access Administrator on your Azure AD tenant.

如果要使用条件访问策略来启用 MFA,请务必获取 Azure AD Premium P1 许可证。

在您的自动化帐户所在的订阅下为您分配贡献者角色。

我尝试在本地环境中重现相同的结果,并得到如下结果:

我通过与具有全局管理员角色的用户连接来运行以下脚本,该角色创建了启用了 MFA 的新用户,如下所示:

Connect-MsolService

$user=New-MsolUser -DisplayName "Demo User" -UserPrincipalName "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6206070f0d17110710221a1a1a1a1a1a1a1a1a1a4c0d0c0f0b01100d110d04164c010d0f" rel="noreferrer noopener nofollow">[email protected]</a>" -Password "xxxxxxxxxxxx1234@"

# Wait for the user account to be created
Start-Sleep -Seconds 30

$strongAuth = @()
$strongAuth += New-Object -TypeName Microsoft.Online.Administration.StrongAuthenticationRequirement
$strongAuth[0].RelyingParty = "*"
$strongAuth[0].State = "Enabled"

Set-MsolUser -UserPrincipalName "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="88ecede5e7fdfbedfac8f0f0f0f0f0f0f0f0f0f0f0a6e7e6e5e1ebfae7fbe7eefca6ebe7e5" rel="noreferrer noopener nofollow">[email protected]</a>" -StrongAuthenticationRequirements $strongAuth

回应:

enter image description here

当我在门户中检查相同内容时,名为演示用户的新用户已成功创建,如下所示:

enter image description here

为了检查是否启用了 MFA,我尝试使用上述新创建的要求 MFA 的用户凭据登录,如下所示:

enter image description here

如果您想使用相同的脚本,请确保在运行脚本之前安装 MSOnline 模块,如下所示:

 Install-Module -Name MSOnline
 Import-Module -Name MSOnline
 Connect-MsolService

如果您通过服务主体执行这些操作,则还需要为服务主体分配角色权限

引用: Enable Azure AD Multi-Factor Authentication | Microsoft Learn

关于azure - 在 Azure AD 上启用 MFA 需要什么级别的权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75473197/

相关文章:

python - 错误 conda.core.link :_execute(502): An error occurred while installing package 'conda-forge::astor-0.7.1-py_0'

css - 如何解决 Internet Explorer 11 由于缓存控制 header 而忽略我的字体的问题?

azure - 添加来自一个 Azure Active Directory 的用户以访问另一个 Azure Active Directory 中的应用程序

java - Microsoft Azure 翻译 API 身份验证方法

azure - 无法设置 AppID URI : "Property identifierUris is invalid"

与哈希位置策略一起使用时,使用 ng2-adal 库的 Angular4 azure Active Directory 身份验证失败

azure - 使用 Azure AD B2C 自定义策略签署本地帐户时用户名或密码无效

powershell - 用于交换 Azure 应用服务(网站)部署槽的 Azure Powershell 脚本

azure - 使用 Windows Powershell 自动对 Azure 作为服务主体进行身份验证

powershell - 为 Azure Ubuntu 16.04-LTS 启用磁盘加密失败,说 "' VolumeType' is not supported"