pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

使用 Graph Api 對租戶進行角色計數

Role Count using Graph Api against a tenant(使用 Graph Api 對租戶進行角色計數)
本文介紹了使用 Graph Api 對租戶進行角色計數的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

有沒有辦法找到針對 tenant 存在的每個 role 和針對每個 分配的 number of users角色 使用 GraphServiceClientGraphConnection 類?我正在使用 C#.

Is there a way to find each role that exists against a tenant and number of users which have been assigned against each role using GraphServiceClient or GraphConnection class? I am using C#.

推薦答案

目錄角色 - 為租戶查找所有目錄角色及其成員數量

Directory Roles - Finding all directory roles and count of their members for tenant

我已經給出了 Microsoft Graph API (https://graph.microsoft.com) 的示例代碼以及 Azure AD Graph API (https://graph.windows.net),但它會很強大建議使用較新的 Microsoft Graph API,除非您無法從中獲得特定的東西,然后才查看 Azure AD Graph API.

I have given sample code for both Microsoft Graph API (https://graph.microsoft.com) as well as Azure AD Graph API (https://graph.windows.net), but it would be strongly recommended to use newer Microsoft Graph API unless there is something specific that you aren't able to get from it and only then look at Azure AD Graph API.

在此處查看更詳細的比較 Microsoft Graph 或 Azure AD Graph

Look here for more detailed comparisons Microsoft Graph or Azure AD Graph

這里是 nuget 包和類的詳細信息,正如您在評論中詢問的那樣:

Here are nuget package and class details, as you've asked in comments:

  • Microsoft.Graph nuget 包 - 使用 Microsoft Graph API 并使用 GraphServiceClient 類.

  • Microsoft.Graph nuget package - to work with Microsoft Graph API and use GraphServiceClient class.

Microsoft.Azure.ActiveDirectory.GraphClient nuget 包 - 使用 Azure AD Graph API 并使用 ActiveDirectoryClient 類.

Microsoft.Azure.ActiveDirectory.GraphClient nuget package - to work with Azure AD Graph API and use ActiveDirectoryClient class.

微軟圖形 API

API - 列出目錄角色 和 列出成員

var roles = await graphServiceClient.DirectoryRoles.Request().GetAsync();

var members = graphServiceClient.DirectoryRoles[role.Id].Members.Request().GetAsync();

Azure AD 圖形 API

API - 獲取目錄角色和獲取目錄角色的成員

var directoryRoles =  activeDirectoryClient.DirectoryRoles.ExecuteAsync();

var members = await activeDirectoryClient.DirectoryRoles[role.ObjectId].Members.ExecuteAsync();

注意:在測試代碼時,我還注意到 2 個 API 的行為略有不同.Microsoft Graph 僅在您請求目錄角色的成員時返回用戶.另一方面,Azure AD Graph 返回用戶和服務主體.有關 Azure AD Graph 的特殊檢查,請參閱我的代碼.

NOTE: While testing code I also noticed a slight difference in behavior of the 2 API's. Microsoft Graph only returns Users when you ask for members of a directory role. Azure AD Graph on the other hand returned both users and service principals. See my code for a special check in case of Azure AD Graph.

另請注意,您獲得的許多結果將是分頁集合,因此您可能需要在多頁結果的情況下處理分頁.

Also note that many of the results you get will be paginated collections, so you may need to handle pagination in case of multiple pages of results.

應用程序角色 - 查找應用程序的所有應用程序角色,然后通過應用程序角色分配找到用戶數.

Application Roles - Finding all Application Roles for an application and then finding Number of users through App Role Assignments.

應用程序角色特定于在 Azure AD 中注冊的應用程序.可以通過在租戶中瀏覽該應用程序的服務主體來讀取該應用程序的角色分配集合.

Application Roles are specific to an application registered in Azure AD. Role Assignments collection for that application can be read by going through the service principal for that application in the tenant.

Azure AD 圖形 API

應用角色

var app = activeDirectoryClient.Applications["<applicationObjectId>"].ExecuteAsync().Result;
var appRoles = app.AppRoles;

應用角色分配

ActiveDirectoryClient activeDirectoryClient = new ActiveDirectoryClient(new Uri("https://graph.windows.net/<tenantGuid>"),
async () => await GetTokenForApplication());

var servicePrincipal = activeDirectoryClient.ServicePrincipals.Where(x => x.AppId == "<applicationId>").ExecuteAsync().Result.CurrentPage[0];
var appRoleAssignments = activeDirectoryClient.ServicePrincipals[servicePrincipal.ObjectId].AppRoleAssignedTo.ExecuteAsync().Result;
int userCountForApp = 0;
foreach(var appRoleAssignment in appRoleAssignments.CurrentPage)
{
    if (appRoleAssignment.PrincipalType == "User")
    {
        userCountForApp++;
        Console.WriteLine("Role Id = {0} and User Name = {1}", appRoleAssignment.Id, appRoleAssignment.PrincipalDisplayName);
    }
}

微軟圖形 API

讀取分配給用戶的所有應用程序特定角色(即 AppRoleAssignments)的功能僅作為 Microsoft Graph API beta 端點的一部分提供.所以它不夠穩定,無法在生產代碼中使用,而且您找不到 C# 的 Client SDK 支持.閱讀 此 SO 帖子中的更多具體點馬克·拉弗勒(Marc LaFleur)

The ability to read all application specific roles assigned to a user (i.e. AppRoleAssignments) is only available as part of Microsoft Graph API beta endpoint. So it's not stable enough to be used in production code and you won't find Client SDK support for C#. Read more specific points in this SO Post by Marc LaFleur

以下是相關的 API:

Here are the relevant API's though:

  • AppRoleAssignments
  • AppRoles

這篇關于使用 Graph Api 對租戶進行角色計數的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

ASP.NET Core authenticating with Azure Active Directory and persisting custom Claims across requests(ASP.NET Core 使用 Azure Active Directory 進行身份驗證并跨請求保留自定義聲明)
ASP.NET Core 2.0 Web API Azure Ad v2 Token Authorization not working(ASP.NET Core 2.0 Web API Azure Ad v2 令牌授權不起作用)
ASP Core Azure Active Directory Login use roles(ASP Core Azure Active Directory 登錄使用角色)
How do I get Azure AD OAuth2 Access Token and Refresh token for Daemon or Server to C# ASP.NET Web API(如何獲取守護進程或服務器到 C# ASP.NET Web API 的 Azure AD OAuth2 訪問令牌和刷新令牌) - IT屋-程序員軟件開發技
.Net Core 2.0 - Get AAD access token to use with Microsoft Graph(.Net Core 2.0 - 獲取 AAD 訪問令牌以與 Microsoft Graph 一起使用)
Azure KeyVault Active Directory AcquireTokenAsync timeout when called asynchronously(異步調用時 Azure KeyVault Active Directory AcquireTokenAsync 超時)
主站蜘蛛池模板: 北京网络营销推广_百度SEO搜索引擎优化公司_网站排名优化_谷歌SEO - 北京卓立海创信息技术有限公司 | 厚壁钢管-厚壁无缝钢管-小口径厚壁钢管-大口径厚壁钢管 - 聊城宽达钢管有限公司 | 云阳人才网_云阳招聘网_云阳人才市场_云阳人事人才网_云阳人家招聘网_云阳最新招聘信息 | 锌合金压铸-铝合金压铸厂-压铸模具-冷挤压-誉格精密压铸 | 多物理场仿真软件_电磁仿真软件_EDA多物理场仿真软件 - 裕兴木兰 | 衢州装饰公司|装潢公司|办公楼装修|排屋装修|别墅装修-衢州佳盛装饰 | 高精度电阻回路测试仪-回路直流电阻测试仪-武汉特高压电力科技有限公司 | 时代北利离心机,实验室离心机,医用离心机,低速离心机DT5-2,美国SKC采样泵-上海京工实业有限公司 工业电炉,台车式电炉_厂家-淄博申华工业电炉有限公司 | 混合气体腐蚀试验箱_盐雾/硫化氢/气体腐蚀试验箱厂家-北京中科博达 | 护腰带生产厂家_磁石_医用_热压护腰_登山护膝_背姿矫正带_保健护具_医疗护具-衡水港盛 | 煤棒机_增碳剂颗粒机_活性炭颗粒机_木炭粉成型机-巩义市老城振华机械厂 | 百方网-百方电气网,电工电气行业专业的B2B电子商务平台 | 艾乐贝拉细胞研究中心 | 国家组织工程种子细胞库华南分库 | 搪瓷反应釜厂家,淄博搪瓷反应釜-淄博卓耀 | 上海风淋室_上海风淋室厂家_上海风淋室价格_上海伯淋 | 政府回应:200块在义乌小巷能买到爱情吗?——揭秘打工族省钱约会的生存智慧 | 知网论文检测系统入口_论文查重免费查重_中国知网论文查询_学术不端检测系统 | 重庆中专|职高|技校招生-重庆中专招生网 | 青州搬家公司电话_青州搬家公司哪家好「鸿喜」青州搬家 | 金属软管_不锈钢金属软管_巩义市润达管道设备制造有限公司 | 北京翻译公司_同传翻译_字幕翻译_合同翻译_英语陪同翻译_影视翻译_翻译盖章-译铭信息 | 氧化锆陶瓷_氧化锆陶瓷加工_氧化锆陶瓷生产厂家-康柏工业陶瓷有限公司 | 煤粉取样器-射油器-便携式等速飞灰取样器-连灵动 | 清水-铝合金-建筑模板厂家-木模板价格-铝模板生产「五棵松」品牌 | 水冷散热器_水冷电子散热器_大功率散热器_水冷板散热器厂家-河源市恒光辉散热器有限公司 | 气动隔膜泵-电动隔膜泵-循环热水泵-液下排污/螺杆/管道/化工泵「厂家」浙江绿邦 | 金属检测机_金属分离器_检针验针机_食品药品金属检探测仪器-广东善安科技 | 沥青车辙成型机-车托式混凝土取芯机-混凝土塑料试模|鑫高仪器 | RFID电子标签厂家-上海尼太普电子有限公司 | 招商帮-一站式网络营销服务|互联网整合营销|网络推广代运营|信息流推广|招商帮企业招商好帮手|搜索营销推广|短视视频营销推广 | 昆明化妆培训-纹绣美甲-美容美牙培训-昆明博澜培训学校 | 检验科改造施工_DSA手术室净化_导管室装修_成都特殊科室建设厂家_医疗净化工程公司_四川华锐 | sus630/303cu不锈钢棒,440C/430F/17-4ph不锈钢研磨棒-江苏德镍金属科技有限公司 | 哈希PC1R1A,哈希CA9300,哈希SC4500-上海鑫嵩实业有限公司 | 北京中航时代-耐电压击穿试验仪厂家-电压击穿试验机 | 精密机械零件加工_CNC加工_精密加工_数控车床加工_精密机械加工_机械零部件加工厂 | 纸箱抗压机,拉力机,脂肪测定仪,定氮仪-山东德瑞克仪器有限公司 | 新能源汽车电机定转子合装机 - 电机维修设备 - 睿望达 | 工业洗衣机_工业洗涤设备_上海力净工业洗衣机厂家-洗涤设备首页 bkzzy在职研究生网 - 在职研究生招生信息咨询平台 | 河南mpp电力管_mpp电力管生产厂家_mpp电力电缆保护管价格 - 河南晨翀实业 | 油漆辅料厂家_阴阳脚线_艺术漆厂家_内外墙涂料施工_乳胶漆专用防霉腻子粉_轻质粉刷石膏-魔法涂涂 |