Unable to search Microsoft Graph Api V1.0 users using Wildcard search pattern

眉间皱痕 提交于 2020-06-28 05:43:04

问题


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();

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.

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

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


回答1:


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:

You could try bellow way

         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: You can bind multiple and, or clause to execute your custom search.

Hope it would help.



来源:https://stackoverflow.com/questions/60457231/unable-to-search-microsoft-graph-api-v1-0-users-using-wildcard-search-pattern

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!