我正在尝试使用以下代码片段基于通配符正则表达式匹配来搜索用户:
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("Robin.?Thomas"((以及UserPrincipalName搜索和id搜索等情况下的
我想获得一些类似的结果,但在MS Graph V1.0文档中找不到任何正则表达式搜索。
请帮助我使用MS Graph API V1.0 进行regex匹配
Microsoft Graph
V1.0当前不支持像*
或%like%
,尽管目前有$search
选项仅在messages
和person
集合上受支持。
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
子句来执行自定义搜索
希望能有所帮助。