You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit fc240c7
Browse filesBrowse the repository at this point in the historyBrowse files
authored
[6.1.8 Cherry-pick] Improve WAM authentication diagnostics for windowless hosts (#4918)
* Cherry-pick of #4858 requires manual resolution
To resolve, run: git cherry-pick a62aad4
* [6.1.8] Improve WAM authentication diagnostics for windowless hosts (#4858)
Manual port of a62aad4 to release/6.1, where the provider lives in the core driver.
- Catch MSAL window_handle_required for WAM interactive auth on Windows and rethrow
an MsalClientException with the same error code and actionable guidance.
- Document windowless-host alternatives in the provider and options snippets.
- Add WamBrokerErrorTests and SqlAuthenticationProviderCollection.Name.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: ec369fd4-31ce-48fd-94fe-dc893a47a803
---------
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Priyanka Tiwari <prtiwar@microsoft.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: ec369fd4-31ce-48fd-94fe-dc893a47a803
Copy file name to clipboardExpand all lines: doc/snippets/Microsoft.Data.SqlClient/ActiveDirectoryAuthenticationProviderOptions.xml
+8Lines changed: 8 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -29,6 +29,14 @@
29
29
Defaults to <seelangword="false"/> when you provide a custom <seecref="ApplicationClientId"/>.
30
30
Otherwise, WAM broker mode is used automatically on Windows.
31
31
</summary>
32
+
<remarks>
33
+
Setting this property to <seelangword="false"/> does not disable WAM for SqlClient's first-party application ID,
34
+
including when that ID is supplied explicitly. Disabling WAM requires a custom application registration.
35
+
WAM interactive authentication requires a valid parent window handle. Applications with a window can supply
36
+
its handle using <seecref="M:Microsoft.Data.SqlClient.ActiveDirectoryAuthenticationProvider.SetParentActivityOrWindowFunc(System.Func{System.Object})"/>.
37
+
Windowless hosts should use a non-interactive credential with <c>Authentication=Active Directory Default</c>,
38
+
or use their own application registration with WAM disabled if interactive sign-in is required.
// TODO: Localize this message: https://github.com/dotnet/SqlClient/issues/4904
49
+
returnnewMsalClientException(
50
+
ex.ErrorCode,
51
+
"Active Directory Interactive authentication with Windows Web Account Manager (WAM) requires a valid parent window handle. "+
52
+
"Supply an application-owned window handle using ActiveDirectoryAuthenticationProvider.SetParentActivityOrWindowFunc. "+
53
+
"For windowless hosts, such as Azure Functions local workers, use Authentication=Active Directory Default with a configured non-interactive credential. "+
54
+
"To use interactive authentication without WAM, provide your own ApplicationClientId and set UseWamBroker=false. "+
55
+
"WAM cannot be disabled for SqlClient's first-party application ID. "+
56
+
ex.Message,
57
+
ex);
58
+
}
59
+
41
60
#if NETFRAMEWORK
42
61
// Non-broker redirect URI used on .NET Framework when WAM is not in use (legacy embedded
43
62
// WebView path).
@@ -367,23 +386,37 @@ previousPw is byte[] previousPwBytes &&
Copy file name to clipboardExpand all lines: src/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft/Data/SqlClient/SqlAuthenticationProviderCollection.cs
0 commit comments