Azure Graph API 按数组值过滤

Fel*_*ber 5 azure azure-active-directory azure-ad-graph-api azure-ad-b2c

我正在尝试对我的 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
Run Code Online (Sandbox Code Playgroud)

问题是,这些属性只是简单的值,如下所示:

"displayName: "testValue",
"givenName": "testValue",
"displayName: "testValue",
"surname": "testValue",
"mail: "testValue",
"userPrincipalName": "testValue",
Run Code Online (Sandbox Code Playgroud)

就我而言,我需要再使用一个语句,其中我需要检查一个数组是否像其他数组一样包含“test”。这个数组看起来像这样:

        "signInNames": [
            {
                "type": "emailAddress",
                "value": "test@mail.com"
            },                {
                "type": "emailAddress",
                "value": "test2@mail.com"
            }
        ]
Run Code Online (Sandbox Code Playgroud)

我已经在官方文档中搜索但没有运气......有什么想法吗?

All*_* Wu 4

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

\n\n
GET https://graph.windows.net/myorganization/users?$filter=signInNames/any(c:startswith(c/value, \'test\'))\n
Run Code Online (Sandbox Code Playgroud)\n\n

不幸的是,它会显示一个错误:value 仅支持 equals-match。不支持前缀匹配

\n\n

contains目前任何 Microsoft Graph 资源都不支持字符串运算符。所以我们两者都不能使用contains

\n\n

您需要使用equal查找精确匹配的数据\xef\xbc\x9a

\n\n
GET https://graph.windows.net/myorganization/users?$filter=signInNames/any(c:c/value eq \'***\')\n
Run Code Online (Sandbox Code Playgroud)\n\n

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

\n\n

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

\n