2016-09-06 100 views
0

我已經在Azure AD Premium中設置了一個應用程序,並且需要用戶分配才能訪問該應用程序。我已將自定義應用程序角色添加到應用程序清單。我可以將具有角色的用戶分配給應用程序。獲取Azure Active Directory應用程序用戶和角色

如何獲得分配給應用程序及其分配角色的所有用戶的列表?

+0

從門戶或使用代碼? – Thomas

+0

我一直希望它被嵌入到門戶中。 – Jeremy

回答

3

Azure的門戶(預覽)

在新Azure的門戶網站,「企業應用程序」下>(您的應用程序)>「用戶和組」,現在只能看到誰是用戶的列表分配給應用程序以及分配給它們的應用程序角色。您也可以按應用程序角色進行過濾和排序。這裏有一個例子:

Azure portal/Enterprise applications/Users and groups

注:截至2016年9月,在新Azure的門戶網站在Azure AD管理經驗是預覽。

經典Azure的門戶

在應用的「用戶和組」,您可以列出所有用戶(以及他們的分配狀態),以及所有羣體:

[Classic Azure portal/Active Directory/Application/Users and groups]

PowerShell的

使用新preview (as of Sept 2016) Azure AD PowerShell module,你可以使用下面的例子:

# Get all service principals, and for each one, get all the app role assignments, 
# resolving the app role ID to it's display name. Output everything to a CSV. 
Get-AzureADServicePrincipal | % { 

    # Build a hash table of the service principal's app roles. The 0-Guid is 
    # used in an app role assignment to indicate that the principal is assigned 
    # to the default app role (or rather, no app role). 
    $appRoles = @{ "$([Guid]::Empty.ToString())" = "(default)" } 
    $_.AppRoles | % { $appRoles[$_.Id] = $_.DisplayName } 

    # Get the app role assignments for this app, and add a field for the app role name 
    Get-AzureADServiceAppRoleAssignment -ObjectId ($_.ObjectId) | % { 
    $_ | Add-Member "AppRoleDisplayName" $appRoles[$_.Id] -Passthru 
    } 
} | Export-Csv "app_role_assignments.csv" -NoTypeInformation 

Azure的AD圖形API

隨着Azure的AD圖形API,你可以做的PowerShell腳本做什麼,上面(實際上相當於在新的Azure AD PowerShell模塊對大多數請求使用Azure AD Graph API)。

列出所有服務主體:

GET https://graph.windows.net/{tenant-id}/servicePrincipals 

目錄服務主體的應用角色分配:

GET https://graph.windows.net/{tenant-id}/servicePrincipals/{object-id}/appRoleAssignments 
+0

我曾希望使用門戶來查看用戶及其角色的列表。我可以在經典門戶中看到我點擊「用戶和組」,但它向我展示了AD中的每個用戶,而不僅僅是指派給我的應用的用戶。當我找到一個分配給我的應用的用戶時,它只是說分配的,我無法分辨他們的應用角色是什麼。查看適用於我的應用的用戶列表以及他們的角色的唯一方法是使用Graph API自己構建自定義應用?似乎應該在Azure AD應用程序中顯而易見。 – Jeremy

+1

不幸的是,是的,這是目前唯一的方法。我認爲,Azure AD在新的Azure門戶(https://portal.azure.com)中可用時,這是可以預料的。無論哪種情況,請務必對這兩項功能請求進行投票,其中任何一項都可滿足您的請求:[過濾應用分配](https://feedback.azure.com/forums/169401-azure-active-directory/建議/ 10114377-assigning-users-to-applications),[顯示應用分配](https://feedback.azure。COM /論壇/ 169401-Azure的主動目錄/建議/ 11730363-在應用-I-需要觀看的-組和用戶屁股)。 –

+1

@Jeremy你的選票很快就被考慮到了。 :)我編輯了答案,將新的Azure AD管理功能包含在新的Azure門戶中。有關預覽的更多細節:https://blogs.technet.microsoft.com/enterprisemobility/2016/09/12/the-azuread-admin-experience-in-the-new-azure-portal-is-now-in- public-preview/ –

相關問題