0
是否有一種方法可以向僅使用PowerShell的應用程序授予管理許可?想象一下,您已經完成了Connect-MsolService並提供了作爲租戶管理員的帳戶的憑據;是否有任何方法可以根據應用程序客戶端ID提供租戶範圍的同意?您是否可以通過PowerShell授予管理員對Azure應用程序的訪問權限
是否有一種方法可以向僅使用PowerShell的應用程序授予管理許可?想象一下,您已經完成了Connect-MsolService並提供了作爲租戶管理員的帳戶的憑據;是否有任何方法可以根據應用程序客戶端ID提供租戶範圍的同意?您是否可以通過PowerShell授予管理員對Azure應用程序的訪問權限
爲了澄清,您的意思是授予應用程序作爲管理員訪問目錄的權限嗎?
如果是這樣的話,你可以這樣做:
# 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期間完成授權過程。
謝謝Yi。不幸的是,不需要將該應用程序添加到角色中,需要對您通常通過瀏覽器執行的應用程序進行實際同意(即,當您爲授權代碼執行重定向並將提示符= admin_consent包括到查詢字符串在這種情況下,我在PowerShell中有一個登錄用戶,它是一個租戶管理員,所以我希望他們能夠做同樣的事情,顯然不是在瀏覽器中。是否可能有某種POST直接指向圖可以解決這個問題的API? –