Problem loging in from desktop app and fetching users

Voiculet Catalin 96 Reputation points
2020-05-11T08:45:22.563+00:00

Hello, I am having trouble fetching users and logging in to my active directory from inside a desktop application. I am trying to make a testing application for trying out user login and groups, before that I downloaded an example application namely the "active-directory-wpf-msgraph". I registered the application inside my active directory, I modified the client id and tenant inside the example application along with the redirect url, I create a publicclientapp object and use it to get the accounts and to login, the directory and registered application has 3 users, one being my own user and 2 other test users, the GetAccountsAsync method doesn't return anything and trying to get a token by username and password using a test account tells me that the password is expired. I have tried to follow documentation examples step by step and I had no results. I am trying to do this with a trial account to test out user login, I wish to use the active directory system if it works to manage users inside my desktop application with it.

Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
22,114 questions
{count} votes

Accepted answer
  1. Voiculet Catalin 96 Reputation points
    2020-05-11T09:13:53.65+00:00

    I have managed to login from code on my test user after signin in to the portal and resetting password, I had to grant admin permissions for the last error. I still cannot fetch accounts using GetAccountsAsync and I wish to have users not require to reset password the first time, any help on how I can do that ?


1 additional answer

Sort by: Most helpful
  1. Voiculet Catalin 96 Reputation points
    2020-05-11T09:03:04.693+00:00

    Thank you for the fast response. I have tried to log in to the portal with that account, it asked me to reset the password because it's the first time I'm logging in, is there any way to have accounts not need to do this the first time? After doing so and trying again to run the application, I still don't fetch any accounts using GetAccountsAsync method and the AcquireTokenByUsernamePassword with the user I just logged in the portal with now says :
    'A configuration issue is preventing authentication - check the error message from the server for details.You can modify the configuration in the application registration portal. See https://aka.ms/msal-net-invalid-client for details. Original exception: AADSTS7000218: The request body must contain the following parameter: 'client_assertion' or 'client_secret'.
    Trace ID: 5910082f-da05-4804-ae11-028ac4575200
    Correlation ID: 7d319c9c-3d31-440d-ac44-0bce4fafad48
    Timestamp: 2020-05-11 08:59:22Z'


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.