无法使用通配符搜索模式搜索Microsoft Graph Api V1.0用户 [英] Unable to search Microsoft Graph Api V1.0 users using Wildcard search pattern

查看:130
本文介绍了无法使用通配符搜索模式搜索Microsoft Graph Api V1.0用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下代码段根据通配符正则表达式匹配搜索用户:

I am trying to search users based on wild card regex match using below code snippet:

var users = await graphServiceClient.Users.Request().Select(e => new {
    e.DisplayName,
    e.GivenName,
    e.PostalCode
}).Filter(RegexMatch(DisplayName("Rob.* Thomas")
).GetAsync();

因此,以上应该匹配用户"Robert Thomas",并且RegexMatch当前在过滤器关键字列表中不可用,我仅用作实现此任务的示例. 以下应与Robin Thomas相匹配:- Filter(RegexMatch(DisplayName("Robi.?Thomas"),以及UserPrincipalName搜索和ID搜索等情况.

So, above should match user "Robert Thomas"and RegexMatch is currently not available in filter keyword list ,i have just used as an example to achieve this task. Below should match Robin Thomas:- Filter(RegexMatch(DisplayName("Robi.? Thomas") and also in case of UserPrincipalName search and id search etc.

我想获得一些类似的结果,但是无法在MS Graph V1.0文档中找到任何正则表达式搜索.

I want to achieve some similar results ,but unable to find any regex search in MS Graph V1.0 documentation.

请使用MS Graph API V1.0帮助我进行正则表达式匹配

Please Help me with regex match using MS Graph API V1.0

推荐答案

Microsoft Graph V1.0当前不支持通配符,例如*%like%,尽管有 $search 选项目前 仅在messagesperson集合上受支持.

Microsoft Graph V1.0 currently doesn't support wildcard like * or %like% though there is $search option which Currently supported only on messages and person collections.

Work Around:

您可以尝试以下方式

         var users = await graphServiceClient.Users
        .Request()
        .Filter("startswith(displayName,'Rob') and startswith(UserPrincipalName ,'Thomas')")
        .Select( e => new {
                 e.DisplayName,
                 e.GivenName,
                 e.PostalCode
                 })
        .GetAsync();

Note: 您可以绑定多个andor子句以执行自定义搜索.

Note: You can bind multiple and, or clause to execute your custom search.

希望这会有所帮助.

这篇关于无法使用通配符搜索模式搜索Microsoft Graph Api V1.0用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆