如何将AAD组分配给企业应用程序?
我想知道如何将一个或多个组分配给应用程序?
我已经尝试过,但是我遇到了一个错误: 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
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
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的错误清楚地表明了失败的零件。
在上一个语句中没有提供
objectid
,因为您的$ aadgroup.ObjectID
is$ null
查看您的代码摘录:
$ groupName
如果您将其与get -azureadGroup -objectID $ groupName
语句使用。它行不通。-ObjectID
期望组的对象ID GUID,而不是其名称(您可能已经正确地执行了它,我的假设来自您的变量名称)。这将解释您没有返回的任何组以及发生错误的原因。
如果要使用组名称,则需要使用
get-azureadgroup
使用-SearchString
而不是-ObjectID
。Your error indicate clearly the part which is failing.
There is no
ObjectId
provided to the last statement because your$AADGroup.ObjectId
is$null
Looking at an excerpt of your code:
$GroupName
is a very bad name for this variable if you are using it along with theGet-AzureADGroup -ObjectId $GroupName
statement right after. 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).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
.