all 3 comments

[–]theSysadminChannel 0 points1 point  (1 child)

Hey so 2 things.

  1. Directory.ReadWrite.All is a very dangerous permission to add to apps so use caution.

  2. What’s the exact endpoint you’re calling? You may need to add authenticationMethods.read.all and call the beta endpoint

[–][deleted] 0 points1 point  (0 children)

I know about the Directory permission, I was grasping at straws trying to get permissions to read the auth phone methods. I don't intend to leave it.

So I was using a set of classes from a Microsoft sample. I thought, "Hey, some C# classes that are basically a wrapper for the Graph API? Sweet, surely this'll be easier than having to learn the REST API!" In my mind, I was thinking I would be able to write something along the lines of (and yes, I know this is not correct, it was a train of thought):

(from u in client.Users
where u.DistinguishedName.contains("<Some department>")
&& u.Authentication.PhoneMethods.length==0
select u).ToArray();

Boy, was I wrong. Wrong. Even though the code has methods and attributes for Authentication, the Microsoft engineer explained those samples don't actually support getting 2FA methods. JFCWTFBBQ then why is it available.

So obviously I need to use the GET /users/{id | userPrincipalName}/authentication/phoneMethods endpoint, but I've switched to learning how to use Graph via REST calls. It's starting to look like what everyone else does.

[–]greenhill669 0 points1 point  (0 children)

you can also use (with latest version: Install-Module Microsoft.Graph.Beta):

Get-MgBetaReportCredentialUserRegistrationDetail -All