Skip to content

Commit 2f09114

Browse files
Merge pull request #681 from ashok672/asram/update-iwa-documenation
Update IWA to reflect that its deprecated and recommend WAM for replacement.
2 parents fd2d8a5 + 0cace8f commit 2f09114

1 file changed

Lines changed: 35 additions & 1 deletion

File tree

msal-dotnet-articles/acquiring-tokens/desktop-mobile/integrated-windows-authentication.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,41 @@ ms.topic: concept-article
1515
# Using MSAL.NET with Integrated Windows Authentication (IWA)
1616

1717
>[!NOTE]
18-
>Integrated Windows Authentication has been replaced with a more reliable way of getting tokens silently - [WAM](wam.md). WAM can login the current windows user silently. This workflow does not require complex setup and it even works for personal (Microsoft) accounts. Internally, the Windows Broker (WAM) will try several strategies to get a token for the current Windows user, including IWA and redeeming the PRT. This eliminates most of the limitations with IWA.
18+
>Integrated Windows Authentication (IWA) is now deprecated and has been replaced by a more robust and modern mechanism for silent token acquisition: [WAM](wam.md).
19+
WAM enables silent Single Sign-On(SSO) for the current Windows user without requiring complex configuration. It also supports personal Microsoft accounts. Under the hood, WAM leverages multiple strategies—including IWA and Primary Refresh Token (PRT) redemption—to obtain tokens silently, thereby addressing many of the limitations associated with traditional IWA.
20+
21+
The IWA documentation should only be referenced for maintaining existing production deployments. If you're planning to migrate to WAM for Single Sign-On (SSO) with OS account, refer to the below sample implementation for guidance and refer to [WAM](wam.md) for more details.
22+
23+
```csharp
24+
var scopes = new[] { "User.Read" };
25+
26+
BrokerOptions options = new BrokerOptions(BrokerOptions.OperatingSystems.Windows);
27+
options.Title = "My Awesome Application";
28+
29+
IPublicClientApplication app =
30+
PublicClientApplicationBuilder.Create("YOUR_CLIENT_ID")
31+
.WithDefaultRedirectUri()
32+
.WithParentActivityOrWindow(GetConsoleOrTerminalWindow)
33+
.WithBroker(options)
34+
.Build();
35+
36+
AuthenticationResult result = null;
37+
38+
try
39+
{
40+
result = await app.AcquireTokenSilent(scopes, PublicClientApplication.OperatingSystemAccount)
41+
.ExecuteAsync(); // this will try to SSO silently with Windows OS logged in account.
42+
}
43+
// Can't get a token silently, go interactive
44+
catch (MsalUiRequiredException ex)
45+
{
46+
result = app.AcquireTokenInteractive(scopes)
47+
.WithAccount(PublicClientApplication.OperatingSystemAccount)
48+
.ExecuteAsync();
49+
}
50+
51+
```
52+
1953

2054
If your desktop or mobile application runs on Windows and on a machine connected to a Windows domain (Active Directory or Microsoft Entra joined) it is possible to use the Integrated Windows Authentication (IWA) to acquire a token silently. No UI is required when using the application.
2155

0 commit comments

Comments
 (0)