【发布时间】:2018-08-02 11:24:43
【问题描述】:
我想知道如何在 Azure AD 中拥有一个 ServicePrincipal,它能够更改不属于它的应用注册,例如删除应用或旋转其键。有人告诉我,如果 SP 具有“应用程序管理员”角色,那么它应该有足够的权限来执行此操作。
那么我如何在 Powershell 中实现这一点?
【问题讨论】:
标签: powershell azure azure-active-directory azure-powershell
我想知道如何在 Azure AD 中拥有一个 ServicePrincipal,它能够更改不属于它的应用注册,例如删除应用或旋转其键。有人告诉我,如果 SP 具有“应用程序管理员”角色,那么它应该有足够的权限来执行此操作。
那么我如何在 Powershell 中实现这一点?
【问题讨论】:
标签: powershell azure azure-active-directory azure-powershell
我认为您正在寻找 Add-AzureADDirectoryRoleMember PowerShell cmdlet。
这是一个例子:
# Fetch role instance
$role = Get-AzureADDirectoryRole | Where-Object {$_.displayName -eq 'Application Administrator'}
# If role instance does not exist, instantiate it based on the role template
if ($role -eq $null) {
# Instantiate an instance of the role template
$roleTemplate = Get-AzureADDirectoryRoleTemplate | Where-Object {$_.displayName -eq 'Application Administrator'}
Enable-AzureADDirectoryRole -RoleTemplateId $roleTemplate.ObjectId
# Fetch role
$role = Get-AzureADDirectoryRole | Where-Object {$_.displayName -eq 'Application Administrator'}
}
# Add the SP to role
Add-AzureADDirectoryRoleMember -ObjectId $role.ObjectId -RefObjectId <ObjectID of your SP>
【讨论】: