gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 10:30:05 25 4
gpt4 key购买 nike

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

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

所以,上面应该匹配用户“罗伯特托马斯”,而 RegexMatch 目前在过滤器关键字列表中不可用,我只是作为一个例子来完成这个任务。
下面应该匹配 Robin Thomas:-
Filter(RegexMatch(DisplayName("Robi.? Thomas") 以及在 UserPrincipalName 搜索和 id 搜索等情况下。

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

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

最佳答案

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: 可以绑定(bind)多个 and , or子句来执行您的自定义搜索。

希望它会有所帮助。

关于c# - 无法使用通配符搜索模式搜索 Microsoft Graph Api V1.0 用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60457231/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com