我试图使用户能够通过Azure设备代码流登录公共Azure AD应用。
我认为我得到的例外非常直接:
与Web应用程序不同,在我的Azure AD门户中,没有添加用户/组(Azure AD-> Enterprise应用程序)的选项,但是有一个选项可以启用用户分配 strong>(这是我想要实现的),这使它变得更奇怪,因为它说如果此选项设置为yes,则必须先将用户分配给该应用程序,然后才能访问它。
如果没有从AD门户进行选择的应用程序,如何将用户分配给该应用程序? [Azure文档here]
答案 0 :(得分: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