我正在尝试使用以下代码段根据通配符正则表达式匹配搜索用户:
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用户
发布评论