Skip to content

Commit abc2ad6

Browse files
authored
Update scenario-desktop-acquire-token-wam.md
1 parent 9eeb71f commit abc2ad6

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

articles/active-directory/develop/scenario-desktop-acquire-token-wam.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ MSAL is able to call Web Account Manager, a Windows 10 component that ships with
2222

2323
## Availability
2424

25-
MSAL 4.25+ supports WAM on UWP, .NET Classic, .NET Core 3.x, and .NET 5.
25+
MSAL 4.25+ supports WAM on UWP, .NET Classic, .NET Core 3.1, and .NET 5.
2626

27-
For .NET Classic and .NET Core 3.x, WAM functionality is fully supported but you have to add a reference to [Microsoft.Identity.Client.Desktop](https://www.nuget.org/packages/Microsoft.Identity.Client.Desktop/) package, alongside MSAL, and instead of `WithBroker()`, call `.WithWindowsBroker()`.
27+
For .NET Classic and .NET Core 3.1, WAM functionality is fully supported but you have to add a reference to [Microsoft.Identity.Client.Desktop](https://www.nuget.org/packages/Microsoft.Identity.Client.Desktop/) package, alongside MSAL, and instead of `WithBroker()`, call `.WithWindowsBroker()`.
2828

2929
For .NET 5, target `net5.0-windows10.0.17763.0` (or higher) and not just `net5.0`. Your app will still run on older versions of Windows if you add `<SupportedOSPlatformVersion>7</SupportedOSPlatformVersion>` in the csproj. MSAL will use a browser when WAM is not available.
3030

@@ -147,9 +147,27 @@ Applications cannot remove accounts from Windows!
147147

148148
## Troubleshooting
149149

150+
### "Either the user cancelled the authentication or the WAM Account Picker crashed because the app is running in an elevated process" error message
151+
150152
When an app that uses MSAL is run as an elevated process, some of these calls within WAM may fail due to different process security levels. Internally MSAL.NET uses native Windows methods ([COM](/windows/win32/com/the-component-object-model)) to integrate with WAM. Starting with version 4.32.0, MSAL will display a descriptive error message when it detects that the app process is elevated and WAM returned no accounts.
151153

152-
One solution is to not run the app as elevated, if possible. Another potential workaround is to call `WindowsNativeUtils.InitializeProcessSecurity` method when the app starts up. This will set the security of the processes used by WAM to the same levels. See [this sample app](https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/blob/master/tests/devapps/WAM/NetCoreWinFormsWam/Program.cs#L18-L21) for an example. However, note, that this workaround is not guaranteed to succeed to due external factors like the underlying CLR behavior. In that case, an `MsalClientException` will be thrown. See issue [#2560](https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/issues/2560) for additional information.
154+
One solution is to not run the app as elevated, if possible. Another solution is for the app developer to call `WindowsNativeUtils.InitializeProcessSecurity` method when the app starts up. This will set the security of the processes used by WAM to the same levels. See [this sample app](https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/blob/master/tests/devapps/WAM/NetCoreWinFormsWam/Program.cs#L18-L21) for an example. However, note, that this solution is not guaranteed to succeed to due external factors like the underlying CLR behavior. In that case, an `MsalClientException` will be thrown. See issue [#2560](https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/issues/2560) for additional information.
155+
156+
### "WAM Account Picker did not return an account" error message
157+
158+
This indicates that either the end-user of the application closed the dialog which displays accounts, or that the dialog itself crashed. A crash can occur if the AccountsControl, a Windows control, is badly registered in Windows. To repair this component, follow these steps:
159+
160+
1. Right-click the Windows icon in your task bar, and then select Windows PowerShell (Admin).
161+
1. If you're prompted by a User Account Control (UAC) window, select Yes to start PowerShell.
162+
1. Copy and execute the followin script
163+
164+
```powershell
165+
if (-not (Get-AppxPackage Microsoft.AccountsControl)) { Add-AppxPackage -Register "$env:windir\SystemApps\Microsoft.AccountsControl_cw5n1h2txyewy\AppxManifest.xml" -DisableDevelopmentMode -ForceApplicationShutdown } Get-AppxPackage Microsoft.AccountsControl
166+
```
167+
168+
### Connection issues
169+
170+
The end-user of the application is displayed an error message along the lines of "Please check your connection and try again". If this issue occurs regularly, please [see the troubleshooting guide for Office](https://docs.microsoft.com/en-us/office365/troubleshoot/authentication/connection-issue-when-sign-in-office-2016), which also uses WAM.
153171

154172
## Sample
155173

0 commit comments

Comments
 (0)