无法使用通配符搜索模式搜索Microsoft Graph Api V1.0用户

编程入门 行业动态 更新时间:2024-10-17 20:20:40
本文介绍了无法使用通配符搜索模式搜索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 选项目前 仅在messages和person集合上受支持.

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: 您可以绑定多个and,or子句以执行自定义搜索.

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

希望这会有所帮助.

更多推荐

无法使用通配符搜索模式搜索Microsoft Graph Api V1.0用户

本文发布于:2023-11-07 05:58:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1565719.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:通配符   模式   用户   Graph   Api

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!