【问题标题】:Azure AD - enable the service principal as a an application administratorAzure AD - 将服务主体启用为应用程序管理员
【发布时间】:2018-08-02 11:24:43
【问题描述】:

我想知道如何在 Azure AD 中拥有一个 ServicePrincipal,它能够更改不属于它的应用注册,例如删除应用或旋转其键。有人告诉我,如果 SP 具有“应用程序管理员”角色,那么它应该有足够的权限来执行此操作。

那么我如何在 Powershell 中实现这一点?

【问题讨论】:

    标签: powershell azure azure-active-directory azure-powershell


    【解决方案1】:

    我认为您正在寻找 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>
    

    【讨论】:

    • “Get-AzureADDirectoryRole”命令仅返回 4 个角色 - “目录读取者”、“设备管理员”、“目录写入者”、“公司管理员”。没有“应用程序管理员”。
    • 那么您必须先启用 AzureAdDirectory 角色。我编辑了我的答案并修复了文档的链接(您可以在其中找到更多信息)。
    • 不错!解决了!但是,请通过在应用程序管理员周围添加缺少的单引号来修复您的答案。谢谢!
    猜你喜欢
    • 2020-09-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-28
    • 1970-01-01
    • 1970-01-01
    • 2017-07-26
    • 1970-01-01
    相关资源
    最近更新 更多