Skip to content

Commit 2cc01dc

Browse files
authored
Updates from editor
1 parent 34b87f0 commit 2cc01dc

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

support/entra/entra-id/app-integration/msal-client-exception-failed-to-get-user-name.md

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,31 @@
11
---
2-
title: MsalClientException - Failed to get user name
3-
description: PDiscusses a "Failed to get user name" error when an application uses Integrated Windows Authentication (IWA) with Microsoft Authentication Library (MSAL) and provide solutions.
2+
title: MsalClientException - Failed to Get User Name
3+
description: Resolves the Failed to get user name error when an application uses Integrated Windows Authentication (IWA) with Microsoft Authentication Library (MSAL).
44
ms.service: entra-id
5-
ms.date: 06/23/2025
5+
ms.date: 06/30/2025
66
ms.reviewer: willfid, v-weizhu
77
ms.custom: sap:Developing or Registering apps with Microsoft identity platform
88
---
99

1010
# Microsoft.Identity.Client.MsalClientException: Failed to get user name
1111

12-
This article provides a solution to a "Failed to get user name" error that occurs when an application uses Integrated Windows Authentication (IWA) with Microsoft Authentication Library (MSAL).
12+
This article provides a solution to the "Failed to get user name" error that occurs when an application uses Integrated Windows Authentication (IWA) together with Microsoft Authentication Library (MSAL).
1313

1414
## Symptoms
1515

16-
When your application uses IWA with MSAL, if calling the `AcquireTokenByIntegratedWindowsAuth` method as follows:
16+
When your application uses IWA with together MSAL, if calling the `AcquireTokenByIntegratedWindowsAuth` method as follows:
1717

1818
```csharp
1919
result = await app.AcquireTokenByIntegratedWindowsAuth(scopes)
2020
```
2121

2222
You encounter one of the following errors:
2323

24-
> Microsoft.Identity.Client.MsalClientException: Failed to get user name>
25-
> System.ComponentModel.Win32Exception: No mapping between account names and security IDs was done
24+
- > Microsoft.Identity.Client.MsalClientException: Failed to get user name>
25+
> System.ComponentModel.Win32Exception: No mapping between account names and security IDs was done
2626

27-
Or
28-
29-
> Microsoft.Identity.Client.MsalClientException: Failed to get user name>
30-
> System.ComponentModel.Win32Exception: Access Denied
27+
- > Microsoft.Identity.Client.MsalClientException: Failed to get user name>
28+
> System.ComponentModel.Win32Exception: Access Denied
3129

3230
## Cause
3331

@@ -38,12 +36,12 @@ The error originates from Windows. It occurs because MSAL calls the [GetUserName
3836
> [!NOTE]
3937
> Before you begin, ensure the following minimum requirements are met:
4038
>
41-
> - You run the application as a local Active Directory user and not a local computer user account.
42-
> - The device where the application run is joined to the domain.
39+
> - Run the application as a local Active Directory user, not a local computer user account.
40+
> - The device running the application is joined to the domain.
4341

4442
To resolve this issue, pass the username to `AcquireTokenByIntegratedWindowsAuth`.
4543

46-
If the username is known beforehand, you can manually pass it to MSAL, as follows:
44+
If the username is known beforehand, you can manually pass it to MSAL as follows:
4745

4846
`result = await app.AcquireTokenByIntegratedWindowsAuth(scopes).WithUsername("<service-account>@contoso.com")`
4947

@@ -71,10 +69,10 @@ If the username isn't known beforehand, dynamically retrieve the username and th
7169
```
7270

7371
> [!NOTE]
74-
> This method tries to access the Windows Account Broker to get the user signed into the device. It doesn't work if the application runs on Internet Information Services (IIS) or Windows Servers.
72+
> This method tries to access the Windows Account Broker to sign the user into the device. It doesn't work if the application runs on Internet Information Services (IIS) or Windows Server.
7573

7674
## Reference
7775

7876
[Using MSAL.NET with Integrated Windows Authentication (IWA)](/entra/msal/dotnet/acquiring-tokens/desktop-mobile/integrated-windows-authentication)
7977

80-
[!INCLUDE [Azure Help Support](../../../includes/azure-help-support.md)]
78+
[!INCLUDE [Azure Help Support](../../../includes/azure-help-support.md)]

0 commit comments

Comments
 (0)