Exception AADSTS50034: The user account {EmailHidden} does not exist

Palani Ganesh 6 Reputation points
2021-02-08T16:15:03.153+00:00

We are trying to authenticate the users for our Web App & Mobile App using Azure Active Directory via MS Graph API. We are created users and given required access rights for the app. Even for the admin user, we are getting the exception AADSTS50034: The user account {EmailHidden} does not exist in the ab6d6a8a-83ea-4650-a631-5cb43442842b directory.
To sign into this application, the account must be added to the directory.\r\nTrace ID: 68d6f664-6d50-4c1f-9ae8-42f3aa497c00\r\n
Correlation ID: 3d30e47d-b2ac-42cd-bfd5-069dbd8f5c67\r\nTimestamp: 2021-02-08 13:56:51Z"}

.net code to authenticate the username and password is

public async Task<string> GetValidAD(JObject jsonResult)
{
try
{
var scopes = new string[] { "https://graph.microsoft.com/.default" };
dynamic Item = JObject.Parse(jsonResult.ToString());
String clientId = Item.clientId.ToString();
String tenantID = Item.tenantID.ToString();
String email = Item.email.ToString();
String password = Item.password.ToString();
System.Security.SecureString pword = new NetworkCredential(email,password).SecurePassword;
string pwordstr = new NetworkCredential(email, pword).Password;

            IPublicClientApplication publicClientApplication = PublicClientApplicationBuilder
            .Create(clientId)
            .WithTenantId(tenantID)
            .Build();

            try
            {
                var result = await publicClientApplication.AcquireTokenByUsernamePassword(scopes, email, pword).ExecuteAsync();
                return result.ToString();
            }
            catch (MsalUiRequiredException ex)
            {
                return ex.InnerException.ToString();
                // error handling omited here (see sample for details)
            }
        }
        catch (Exception ex)
        {
            return ex.ToString();
        }
    }

Please help me to resolve the issue. Thanks in advance

Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,561 questions
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. Marilee Turscak-MSFT 34,036 Reputation points Microsoft Employee
    2021-02-08T23:37:32.507+00:00

    Hi @PalaniGanesh-1728,

    You mentioned that you are getting this error when logging in with the email address. In Azure AD a user is normally authenticated by the User Principal Name (UPN) and not the email address. Most times it will let you use the form of smtp:username@tenant .onmicrosoft.com to log in. Also, if your company domain has not been registered as a verified domain within your Azure AD tenant you will get an "invalid user name or password error."

    My guess is if you are using an email address that would be your issue and I would check to see if you could log in using the UPN instead.

    1 person found this answer helpful.