Azure Graph Api Filter by array value

问题描述 投票:0回答:1

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

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

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": "[email protected]"
            },                {
                "type": "emailAddress",
                "value": "[email protected]"
            }
        ]

我已经在官方documentation中进行搜索,但是没有运气...。有任何想法吗?

azure azure-active-directory azure-ad-b2c azure-ad-graph-api
1个回答
1
投票

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

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

不幸的是,它将显示错误:该值仅支持equals-match。不支持PrefixMatch

并且contains字符串运算符当前在任何Microsoft Graph资源上均不受支持。因此我们既不能使用contains

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

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

这不是解决方案。但是似乎没有一种方法可以满足您的需求。

也许您可以查询所有signInName并在代码中处理它们。

© www.soinside.com 2019 - 2024. All rights reserved.