2015-06-03 39 views

回答

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 

從這裏:https://social.msdn.microsoft.com/Forums/azure/en-US/f12c15b7-e2cc-4056-8f0c-1dbfceaeec24/error-adding-service-principal-to-role-this-role-does-not-exist-check-the-name-and-try-again?forum=WindowsAzureAD&prof=required

同意由應用程序(通過其RequiredResourceAccess)所要求的權限只能通過ADAL期間完成授權過程。

+0

謝謝Yi。不幸的是,不需要將該應用程序添加到角色中,需要對您通常通過瀏覽器執行的應用程序進行實際同意(即,當您爲授權代碼執行重定向並將提示符= admin_consent包括到查詢字符串在這種情況下,我在PowerShell中有一個登錄用戶,它是一個租戶管理員,所以我希望他們能夠做同樣的事情,顯然不是在瀏覽器中。是否可能有某種POST直接指向圖可以解決這個問題的API? –

相關問題