使用 Microsoft Graph API 过滤以结尾或包含字符串的 proxyAddresses

Filtering on proxyAddresses with Microsoft Graph API that endsWith or contains a string

我需要找到具有以特定字符串结尾的 proxyAddress 的用户和组,例如@acme.com

我可以做 startsWith:

$filter=proxyAddresses/any(x:startswith(x,'smtp:johndoe'))

或等于:

$filter=proxyAddresses/any(x:x eq 'smtp:johndoe@acme.com')

但是 endsWith、contains、like 似乎不起作用:

$filter=proxyAddresses/any(x:contains(x,'@acme.com'))

并导致 BadRequest。

Microsoft Graph 端点不支持 endsWith,并且支持 contains 的端点数量有限。在这种情况下,Azure AD 实体不支持 contains。来自 documentation on $filter:

Note: The following $filter operators are not supported for Azure AD resources: ne, gt, ge, lt, le, and not. The contains string operator is currently not supported on any Microsoft Graph resources.

顺便说一句,您用于 contains 的语法也有点不对劲。正确的语法是 contains({property},'{subString}')。它类似于 startsWith 并且没有 require/support 通配符。