有没有办法只使用PowerShell授予应用程序管理同意权?想象一下,您已完成Connect-MsolService并提供了作为租户管理员的帐户的凭据;有没有办法根据应用程序客户端ID提供租户范围内的同意?
答案 0 :(得分:0)
澄清一下,您的意思是授予应用程序作为管理员访问目录的能力吗?
如果是这种情况,您可以这样做:
# Using the Windows Azure Active Directory Module for Windows PowerShell
#
# Connect to the tenant to modify
Connect-MsolService # => login
# Get Service Principal to add the role to
$servicePrincipal = Get-MsolServicePrincipal -ServicePrincipalName Principal.Name
# Get role object ID
# Alternatively, you can list all the roles (in order to get a different role name) using just `Get-MsolRole`
$roleId = (Get-MsolRole -RoleName "Directory Readers").ObjectId
# Add role to service principal
Add-MsolRoleMember -RoleObjectId $roleId -RoleMemberObjectId $servicePrincipal.ObjectId -RoleMemberType servicePrincipal
# Check our work
Get-MsolRoleMember -RoleObjectId $roleId # => should include Principal.Name in list
同意应用程序请求的权限(通过其RequiredResourceAccess)只能在授权过程中通过ADAL完成。