azure-active-directory - 通过 CLI 将成员添加到 Azure Enterprise App
问题描述
我们的 Azure AD 租户中有一个企业应用程序,用于将用户预配到另一个 SaaS 平台。目前它仅使用“仅同步分配的用户和组”选项进行设置,因为我们不希望整个目录被带过来。
我的问题很简单,有没有办法使用 az-cli(目前已安装 2.0.60 版)将用户添加到该企业应用程序?
我检查了:
- az ad sp
- az 广告应用
- az 角色分配(似乎只适用于下面的订阅和资源)
我希望有一个简单的角色分配命令可以运行,通过 upn/objectId 将用户添加到企业应用程序。
我团队中的每个人都在使用 Mac,如果有更好的支持,我们可以使用 PowerShellCore。
谢谢!
解决方案
看来你不能通过 Azure CLI 做到这一点,我的解决方法是使用 powershell 来做到这一点。
我团队中的每个人都在使用 Mac,如果有更好的支持,我们可以使用 PowerShellCore。
首先,你需要安装AzureAD.Standard.Preview
支持powershell core的powershell模块,你可以理解这个模块相当于AzureAD
powershell core中的module,它们的用法是一样的,都是预览版,更多细节见这个链接。
然后尝试以下命令New-AzureADUserAppRoleAssignment
,此示例将用户分配给具有默认应用程序角色 ID 的应用程序。
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
推荐阅读
- python - Keras 当我尝试训练我的模型时,我得到一个“
“ 错误 - python - 在 Whoosh 中一次搜索多个索引
- android - 为什么从我粘贴的内容中更新 IDE 需要这么长时间?
- azure-devops - 由于数据分类语句,Azure DevOps DACPAC 部署失败
- fortran - 将使用 Conda 安装的 FFTW 库链接到 gfortran?
- sql - 动态 SQL 查询
- bootstrap-vue - 与 BootstrapVue 中的属性相关联的动态指令修饰符
- c# - 从服务器加载 Json 时如何修复错误
- python-3.x - 如何在给定的时间内重复此代码
- reactjs - 使用 terser webpack 插件如何避免使用注释构建