New to Azure AD. I have a Winforms application that I'm adding Azure AD (with MFA) authentication to.
In Azure AD, I've registered an application and added some test users. The users have MFA enabled (through Azure). I'm using the Microsoft Identity Client and authorization works as expected.
Is there any way to force the Authentication popup to preload with a user name and prohibit users from entering a different one?
Here is the code snippet for aquiring the token:
authResult = await PublicClientApp.AcquireTokenInteractive(scopes)
.WithAccount(firstAccount)
.WithParentActivityOrWindow(parentForm.Handle)
.WithPrompt(Prompt.ForceLogin) // or Prompt
.ExecuteAsync();
We would like the popup to be preloaded with a specific username rather than typing or selecting an available one from the prompt.
CodePudding user response:
You can use the WithLoginHint() method and pass the UPN of the account as a parameter: https://docs.microsoft.com/en-us/dotnet/api/microsoft.identity.client.acquiretokeninteractiveparameterbuilder.withloginhint?view=azure-dotnet#microsoft-identity-client-acquiretokeninteractiveparameterbuilder-withloginhint(system-string)