简体   繁体   English

如何将 AAD 组分配给企业应用程序?

[英]How to assign AAD Group to an Enterprise App?

i would like to know how to assign one or multiple groups to an application?我想知道如何将一个或多个组分配给一个应用程序?

I've tried this but im getting an error: Get-AzureADGroup : Error occurred while executing GetGroup我已经尝试过了,但出现错误:Get-AzureADGroup:执行 GetGroup 时发生错误

connect-azuread

$GroupName = "TEST"
$app_name = "Intranet"
$app_role_name = "Default Access"

# Get the group to assign
$AADGROUP = Get-AzureADGroup -ObjectId $GroupName
$sp = Get-AzureADServicePrincipal -Filter "displayName eq '$app_name'"
$appRole = $sp.AppRoles | Where-Object { $_.DisplayName -eq $app_role_name }

# Assign the group to the app role
New-AzureADGroupAppRoleAssignment -ObjectId $AADGROUP.ObjectId -PrincipalId $AADGROUP.ObjectId -ResourceId $sp.ObjectId -Id $appRole.Id

Your error indicate clearly the part which is failing.您的错误清楚地表明了失败的部分。 There is no ObjectId provided to the last statement because your $AADGroup.ObjectId is $null没有为最后一条语句提供ObjectId ,因为您的$AADGroup.ObjectId$null

Looking at an excerpt of your code:查看您的代码摘录:

$GroupName = 'test'
$AADGROUP = Get-AzureADGroup -ObjectId $GroupName
#...
# Assign the group to the app role
New-AzureADGroupAppRoleAssignment -ObjectId $AADGROUP.ObjectId -PrincipalId $AADGROUP.ObjectId -ResourceId $sp.ObjectId -Id $appRole.Id

$GroupName is a very bad name for this variable if you are using it along with the Get-AzureADGroup -ObjectId $GroupName statement right after.如果将$GroupName GroupName 与之后的Get-AzureADGroup -ObjectId $GroupName语句一起使用,则此变量的名称非常糟糕。 It won't work.它行不通。 -ObjectId is expecting the object ID GUID of the group, not its name (You might be already doing it correctly, my assumption come from your variable name). -ObjectId期望组的对象 ID GUID,而不是其名称(您可能已经正确执行此操作,我的假设来自您的变量名称)。

That would explain where you don't have any group returned and why the error occur.这将解释您没有返回任何组的位置以及发生错误的原因。 If you want to use the group name, you will need to call the Get-AzureADGroup with -SearchString instead of -ObjectId .如果要使用组名,则需要使用-SearchString而不是 -ObjectId 调用Get-AzureADGroup -ObjectId

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用PowerShell将服务主体分配给托管的VSTS发布管道中的AAD组? - How might I assign a service principal to an AAD group in my hosted VSTS release pipeline using PowerShell? 如何在AAD应用程序中将AAD组设置为所有者? - How can I set an AAD group as an owner on an AAD application? 如何将 AAD 组添加为 SharePoint 在线访问者 - How to add AAD Group as SharePoint Online visitors 如何使用循环 powershell 分配多个用户访问一个应用程序组? - How to use loop powershell to assign multiple users to access an app group? 如何使用 Powershell 为组中的用户分配自定义应用程序设置策略? - How to Assign a custom app setup policy to users in a group using Powershell? 如何使用 Powershell 将用户分配的标识添加到 AAD 组? - How to add user assigned identity to AAD group with Powershell? 如何授予管理员同意 Powershell 中的 Azure AAD 应用程序? - How to grant admin consent to an Azure AAD app in Powershell? 如何使用 Powershell Function App 从 AAD 获取组? - How do I get groups from AAD using Powershell Function App? 分配对用户AAD应用程序Powershell或Graph API的访问权限 - Assign access to users AAD application powershell or Graph API 通过 Powershell 中的图形 API 将计算机设备添加到 AAD 组 - Add Computer Device to AAD Group via Graph API in Powershell
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM