Azure Graph API按数组值筛选



我正在尝试对Azure B2C Active Directory的用户执行查询。

到目前为止,使用以下查询一切正常:

https://graph.windows.net/myTentant/users?$filter=
startswith(displayName,'test')%20
or%20startswith(givenName,'test')%20
or%20startswith(surname,'test')%20
or%20startswith(mail,'test')%20
or%20startswith(userPrincipalName,'test')
&api-version=1.6

问题是,这些属性只是像这样的简单值:

"displayName: "testValue",
"givenName": "testValue",
"displayName: "testValue",
"surname": "testValue",
"mail: "testValue",
"userPrincipalName": "testValue",

在我的情况下,我需要再使用一个语句,其中我需要检查一个数组是否像其他数组一样包含"test"。这个数组看起来像:

"signInNames": [
{
"type": "emailAddress",
"value": "test@mail.com"
},                {
"type": "emailAddress",
"value": "test2@mail.com"
}
]

我已经在官方文件中搜索过了,但没有找到。。。。有什么想法吗?

理论上,我们应该使用以下格式来确定值是否以"test"开头。

GET https://graph.windows.net/myorganization/users?$filter=signInNames/any(c:startswith(c/value, 'test'))

不幸的是,它将显示一个错误:值只支持equals匹配。不支持PrefixMatch

并且contains字符串运算符目前在任何Microsoft Graph资源上都不受支持。所以我们也不能使用contains

您需要使用equal来查找完全匹配的数据:

GET https://graph.windows.net/myorganization/users?$filter=signInNames/any(c:c/value eq '***')

这不是一个解决方案。但似乎没有办法满足你的需求。

也许你可以查询所有的signInNames并在代码中处理它们。

最新更新