Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 569
AllTech Avatar asked Jan 21 '26 05:01

AllTech


1 Answers

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.

like image 177
Md Farid Uddin Kiron Avatar answered Jan 23 '26 16:01

Md Farid Uddin Kiron



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!