【问题标题】:Adding users in Azure AD public client app在 Azure AD 公共客户端应用中添加用户
【发布时间】:2020-03-17 21:17:35
【问题描述】:

我正在尝试让用户通过 Azure 设备代码流登录公共 Azure AD 应用程序。

我认为我得到的异常非常简单:

在我的 Azure AD 门户中,与 Web 应用程序不同,没有添加 用户/组(Azure AD->企业应用程序)的选项,但是可以选择启用 用户分配 strong>(这是我想要实现的)这让它变得更加奇怪,因为它说 如果此选项设置为 yes,则必须先将用户分配给此应用程序,然后才能访问它

如果在 AD 门户中没有选项,如何将用户分配给应用程序? [Azure 文档here]

【问题讨论】:

    标签: azure azure-active-directory


    【解决方案1】:

    有两种选择:

    1.在门户中导航到应用注册->Authentication->将Treat application as a public client设置为No->转到对应的企业应用->Users and groups->添加用户->转到返回将Treat application as a public client 设置为Yes

    2.您可以使用azure powershell New-AzureADUserAppRoleAssignment直接添加用户。

    将用户分配给没有角色的应用程序:

    New-AzureADUserAppRoleAssignment -ObjectId "<user objectid>" -PrincipalId "<user objectid>" -ResourceId "<service principal objectid(i.e. Enterprise Application objectid)>" -Id ([Guid]::Empty)
    

    将用户分配给应用程序中的特定应用程序角色:

    $username = "<You user's UPN>"
    $app_name = "<Your App's display name>"
    $app_role_name = "<App role display name>"
    
    # Get the user to assign, and the service principal for the app to assign to
    $user = Get-AzureADUser -ObjectId "$username"
    $sp = Get-AzureADServicePrincipal -Filter "displayName eq '$app_name'"
    $appRole = $sp.AppRoles | Where-Object { $_.DisplayName -eq $app_role_name }
    
    #Assign the user to the app role
    New-AzureADUserAppRoleAssignment -ObjectId $user.ObjectId -PrincipalId $user.ObjectId -ResourceId $sp.ObjectId -Id $appRole.Id
    

    【讨论】:

    • 第一个选项我自己发现它有效,但它确实是一个 hack,不是吗。也将尝试 2 - 感谢您的回答
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-06-16
    • 2015-08-22
    • 2016-04-18
    • 1970-01-01
    • 1970-01-01
    • 2022-12-18
    • 1970-01-01
    相关资源
    最近更新 更多