如何使用.Net Client SDK从Microsoft Graph获取我所属的管理员角色? [英] How to get admin roles that I am a member of, from Microsoft Graph using .Net Client SDK?

查看:84
本文介绍了如何使用.Net Client SDK从Microsoft Graph获取我所属的管理员角色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道如何使用下面的其余查询按类型过滤成员目录角色:

I know how to get member directory roles filtering by type using the rest query below:

https://graph.microsoft.com/v1.0/me/memberOf/$/microsoft.graph.directoryRole

因此,来自MS Graph api的响应仅包含directoryRole对象.不确定如何使用MS Graph .Net客户端SDK来完成此操作,因为我们没有在实际的Rest请求中指定任何OData关键字,例如SelectFilter.

So the response from MS Graph api only contains directoryRole objects. Not sure how this can be done using the MS Graph .Net client SDK as we do not specify any OData keyword like Select or Filter in the actual Rest request.

请注意,我不想只调用memberOf并在客户端的内存中过滤directoryRole类型的响应,我希望此过滤器像上面的URL一样成为查询的一部分,因此memberOf响应包含仅directoryRole秒.

Note that I do not want to call just memberOf and filter directoryRole type responses in memory on client side, I want this filter to be part of the query as in the URL above, so memberOf response contains only directoryRole s.

推荐答案

使用SDK,过滤是应用于对象的函数.例如:

With the SDK, filtering is a function applied to the object. For example:

var users = await graphClient
    .Users
    .Request()
    .Filter("startswith(displayName,'A')")
    .GetAsync();

很遗憾,这对您没有帮助,因为/memberOf不支持$filter.因此,您需要在客户端上进行过滤.

Unfortunately, this won't help you here since /memberOf doesn't support $filter. So you would need to do the filtering on the client.

如果您要检查特定的 /members 端点确实支持按成员id进行过滤:

If you're checking a specific directoryRole, you could come at this from the other direction. The /members endpoint does support filtering by member id:

v1.0/directoryRoles/{role-id}/members?$filter=id eq '{user-id}'

重要的是在这里要注意,/members仅支持通过实际的id进行的userPrincipalName过滤.

It is important to note here that /members does not support filtering by userPrincipalName, only by the actual id.

这篇关于如何使用.Net Client SDK从Microsoft Graph获取我所属的管理员角色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆