mig*_*lla 9 c# active-directory azure user-roles
使用Azure Active Directory Graph Client,我可以使用ff成功查询AD的用户角色.码:
var activeDirectoryClient = new ActiveDirectoryClient(); // Instantiate the Graph Client here.
var adRoles = await activeDirectoryClient.DirectoryRoles.ExecuteAsync();
Run Code Online (Sandbox Code Playgroud)
但是,有可能得到:
在这种情况下,我对管理员的定义是公司管理员角色下的用户,或者能够授权应用程序的用户(通过格式为https://login.microsoftonline.com/common/oauth2/的身份验证请求URL)授权?response_type = code&client_id = xxx-xxx&resource = yyy-yyy&redirect_uri = zzz-zzz&prompt = admin_consent)
有多种方法可以实现此目的,让我们以 REST API 为起点。
您可以通过发出 GET 请求来获取每个用户的组和角色列表:https: //graph.windows.net/myorganization/users/ {user_id}/$links/memberOf?api-version
成功后,返回该用户所属的 Group 和 DirectoryRole 的链接集合
ref:获取用户的组和目录角色成员身份
要获取组的成员资格,您可以向以下地址发出 GET 请求: https: //graph.windows.net/myorganization/groups/ {object_id}/$links/members?api-version
ref:获取群组的直接成员
但是根据文档:
不能对目录角色调用任何函数或操作
这必须从 USER 对象完成。SDK 将反映这一点。
IPagedCollection<IDirectoryObject> pagedCollection = retrievedUserFetcher.MemberOf.ExecuteAsync();
Run Code Online (Sandbox Code Playgroud)
GraphAPI 控制台应用程序有一些很好的示例,可以向您展示如何完成这些操作:Program.cs
| 归档时间: |
|
| 查看次数: |
1326 次 |
| 最近记录: |