public static void Main()
ListMultiFactorMethods("SOME_USER@DOMAIN.COM");
private static ClientSecretCredential _Credential = null;
private static GraphServiceClient _Client = null;
private static bool Initialized = false;
private static bool Initializing = false;
private const string TENANT_ID = "YOUR_TENANT_ID";
private const string CLIENT_ID = "YOUR_CLIENT_ID";
private const string CLIENT_SECRET = "YOUR_CLIENT_SECRET";
private const string GRAPH_ENDPOINT = "https://graph.microsoft.com/.default";
private static GraphServiceClient Client => GetClient();
public static void Init()
_Credential = new ClientSecretCredential(TENANT_ID, CLIENT_ID, CLIENT_SECRET);
_Client = new GraphServiceClient(_Credential, new[]{GRAPH_ENDPOINT});
private static GraphServiceClient GetClient()
if (!Initialized && Initializing)
else if (Initialized == false)
public static void DisposeClient()
#endregion Get Azure Client
#region List Multi Factor Methods
public static void ListMultiFactorMethods(string UPN)
var AllMethods = Client.Users[UPN].Authentication.Methods.Request().GetAsync().Result;
foreach (var Method in AllMethods)
Console.WriteLine($"{Method.ODataType} - {Method.Id} - {Method.AdditionalData}");
var EmailMethods = Client.Users[UPN].Authentication.EmailMethods.Request().GetAsync().Result;
foreach (var Method in EmailMethods)
Console.WriteLine($"Email: {Method.EmailAddress}");
var PhoneMethods = Client.Users[UPN].Authentication.PhoneMethods.Request().GetAsync().Result;
foreach (var Method in PhoneMethods)
Console.WriteLine($"phone: {Method.PhoneNumber}");
var MSAuthMethods = Client.Users[UPN].Authentication.MicrosoftAuthenticatorMethods.Request().GetAsync().Result;
foreach (var Method in MSAuthMethods)
Console.WriteLine($"MS Auth: {Method.DisplayName}");
var FidoMethods = Client.Users[UPN].Authentication.Fido2Methods.Request().GetAsync().Result;
foreach (var Method in FidoMethods)
Console.WriteLine($"Fido: {Method.DisplayName}");
var OathMethods = Client.Users[UPN].Authentication.SoftwareOathMethods.Request().GetAsync().Result;
foreach (var Method in OathMethods)
Console.WriteLine($"Software Oath: {Method.Id}");
#endregion List Multi Factor Methods
#region Delete All Multi Factor Methods
public static async void DeleteMultiFactorMethods(string UPN)
var Methods = Client.Users[UPN].Authentication.Methods.Request().GetAsync().Result;
foreach (var Method in Methods.Where(e => e.ODataType == "#microsoft.graph.emailAuthenticationMethod"))
await Client.Users[UPN].Authentication.EmailMethods[Method.Id].Request().DeleteAsync();
foreach (var Method in Methods.Where(e => e.ODataType == "#microsoft.graph.phoneAuthenticationMethod"))
await Client.Users[UPN].Authentication.PhoneMethods[Method.Id].Request().DeleteAsync();
foreach (var Method in Methods.Where(e => e.ODataType == "#microsoft.graph.microsoftAuthenticatorAuthenticationMethod"))
await Client.Users[UPN].Authentication.MicrosoftAuthenticatorMethods[Method.Id].Request().DeleteAsync();
foreach (var Method in Methods.Where(e => e.ODataType == "#microsoft.graph.fido2AuthenticationMethod"))
await Client.Users[UPN].Authentication.Fido2Methods[Method.Id].Request().DeleteAsync();
foreach (var Method in Methods.Where(e => e.ODataType == "#microsoft.graph.softwareOathAuthenticationMethod"))
await Client.Users[UPN].Authentication.SoftwareOathMethods[Method.Id].Request().DeleteAsync();
#endregion Delete All Multi Factor Methods