首页 > 解决方案 > Azure AD Graph API:无法在任何函数下使用 StartsWith

问题描述

我想问一下在 Azure AD Graph Explorer 中查询时如何在 Any 函数中应用 StartsWith。

根据文档,以下是查询多值属性时的示例。

https://graph.windows.net/contoso.com/users?$filter=signInNames/any(x:x/value eq 'joe@example.com')&api-version=1.6

但是,该示例使用“ eq ”,这意味着它正在执行精确匹配。

如果我们可以在这种情况下执行StartsWith ,是否有可能?

我已经检查了本教程,但我得到了如下所示的错误。

使用“test”获取所有 SignName

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

错误:

"value": "An unknown function with name 'x.startswith' was found. This may also be a key lookup on a navigation property, which is not allowed."

标签: azure-ad-graph-api

解决方案


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

不幸的是,它会显示一个错误:value 只支持 equals-match。不支持 PrefixMatch在此处输入图像描述

请在 Azure 广告图中使用以下查询来获取登录名

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

推荐阅读