This seems like a good idea. We can compare a given phone number with the phone numbers registered in the phone authentication to list the users with the given phone number.
However, currently we cannot retrieve matching users with a simple API call, which requires some logic calculations. I spent some time writing an execution program using the graph SDK and it worked fine for me, I hope it helps you too.
Please refer to the sample code snippet:
var userIds = await graphClient.Users.GetAsync((requestConfiguration) =>
{
requestConfiguration.QueryParameters.Select = new string[] { "id" };
});
foreach (var userId in userIds.Value)
{
var phoneMethods = await graphClient.Users[userId.Id].Authentication.PhoneMethods.GetAsync();
foreach (var phoneMethod in phoneMethods.Value)
{
if (phoneMethod.PhoneNumber is "xxx xxxxxxxxxx")
{
Console.WriteLine(userId.Id);
}
}
}
Hope this helps.
If the reply is helpful, please click Accept Answer and kindly upvote it. If you have additional questions about this answer, please click Comment.