用于onPremisesExtensionAttributes的Microsoft Graph过滤器

时间:2018-04-11 00:29:05

标签: office365 azure-active-directory microsoft-graph

我有一个Microsoft Graph用户,其中包含以下属性:

"onPremisesExtensionAttributes": {
            "extensionAttribute1": "attr1",
            "extensionAttribute2": null,
            "extensionAttribute3": null,
            "extensionAttribute4": null,
             etc.
        },

我似乎无法找到有关如何过滤此属性的任何文档或示例。我试过了:

https://graph.microsoft.com/beta/users?$filter=extensionAttribute1 eq 'attr1'
https://graph.microsoft.com/beta/users?$filter=onPremisesExtensionAttributes/extensionAttribute1 eq 'attr1'
https://graph.microsoft.com/beta/users?$filter=onPremisesExtensionAttributes/any(x:startswith(x,'attr1'))

所有这些都会导致错误的请求,所以显然有些问题。

"code": "BadRequest",
"message": "Invalid filter clause",

问题:如何针对onPremisesExtensionAttributes或包含命名属性列表的任何其他属性(例如extensionAttribute1 ... n)格式化过滤器?对于字符串列表(例如proxyAddresses),您可以这样做:

$filter=proxyAddresses/any(x:startswith(x,%27smtp:myemail%27))

1 个答案:

答案 0 :(得分:0)

您现在可以过滤 onPremisesExtensionAttributes

https://graph.microsoft.com/v1.0/users?$count=true&$filter=onPremisesExtensionAttributes/extensionAttribute1 eq 'attr1'

需要注意的两个要点:

  1. 您需要将 ConsistencyLevel 标头设置为 eventual。否则,您将收到 400 状态代码,并显示以下消息 Property 'extensionAttribute1' does not exist as a declared property or extension property.
  2. 即使您不关心计数,您也需要包含 $count=true,否则您将收到带有以下消息 400
  3. Property 'extensionAttribute1' does not exist as a declared property or extension property. 状态代码

来源:https://developer.microsoft.com/en-us/office/blogs/microsoft-graph-advanced-queries-for-directory-objects-are-now-generally-available/