1
votes

I am working on an app that needs to query Azure AD. The query is working on some fields but on some fields like mobile number it's not working.

Query is working when filtering with name

var searchResults = await userCollection.Where(user =>
                (user.UserPrincipalName.StartsWith(searchString) ||
                user.DisplayName.StartsWith(searchString) ||
                user.GivenName.StartsWith(searchString) ||
                user.Surname.StartsWith(searchString) ||
                user.Mail.StartsWith(searchString)) && user.AccountEnabled == true).ExecuteAsync();

but with mobile number and other fields it throws exception

var searchResults = await userCollection
                .Where(x => x.Mobile == "+63 922 3965 021").ExecuteAsync();

Here is the exception "Unsupported or invalid query filter clause specified for property 'mobile' of resource 'User'."

1

1 Answers

2
votes

There are some properties that you can query that way. The Linq query generates a Filter expression towards the Azure AD Graph API. But others, like the mobile number, you can't.

The properties that are filterable can be seen in the reference for user objects.

The ones that you can filter on are marked as such (e.g. the Surname property: "GET ($filter)").