Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User account not found in MSAL cache on Linux #17744

Closed
bard83 opened this issue Jul 13, 2023 · 5 comments
Closed

User account not found in MSAL cache on Linux #17744

bard83 opened this issue Jul 13, 2023 · 5 comments

Comments

@bard83
Copy link

bard83 commented Jul 13, 2023

Type: Bug

Error when tring to connecting to the server.
After choose Active Directory login and successful login the extension showss a dialog error.

mssql: Failed to connect: Microsoft.Data.SqlClient.SqlException (0x80131904): User account '...' not found in MSAL cache, please add linked account or refresh account credentials.
 ---> System.Exception: User account '...' not found in MSAL cache, please add linked account or refresh account credentials.
   at Microsoft.SqlTools.Authentication.Authenticator.GetTokenAsync(AuthenticationParams params, CancellationToken cancellationToken) in /_/src/Microsoft.SqlTools.Authentication/Authenticator.cs:line 129
   at Microsoft.SqlTools.Authentication.Sql.AuthenticationProvider.AcquireTokenAsync(SqlAuthenticationParameters parameters) in /_/src/Microsoft.SqlTools.Authentication/Sql/AuthenticationProvider.cs:line 90
   at Microsoft.Data.SqlClient.SqlInternalConnectionTds.<>c__DisplayClass147_1.<<GetFedAuthToken>b__1>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.Data.SqlClient.SqlInternalConnectionTds.GetFedAuthToken(SqlFedAuthInfo fedAuthInfo)
   at Microsoft.Data.SqlClient.SqlInternalConnectionTds.GetFedAuthToken(SqlFedAuthInfo fedAuthInfo)
   at Microsoft.Data.SqlClient.SqlInternalConnectionTds.OnFedAuthInfo(SqlFedAuthInfo fedAuthInfo)
   at Microsoft.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
   at Microsoft.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
   at Microsoft.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK)
   at Microsoft.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover)
   at Microsoft.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout)
   at Microsoft.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance)
   at Microsoft.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, Boolean applyTransientFaultHandling, String accessToken, DbConnectionPool pool)
   at Microsoft.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
   at Microsoft.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions)
   at Microsoft.Data.ProviderBase.DbConnectionFactory.<>c__DisplayClass48_0.<CreateReplaceConnectionContinuation>b__0(Task`1 _)
   at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
   at Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection.ReliableSqlConnection.<>c__DisplayClass30_0.<<OpenAsync>b__0>d.MoveNext() in /_/src/Microsoft.SqlTools.ManagedBatchParser/ReliableConnection/ReliableSqlConnection.cs:line 313
--- End of stack trace from previous location ---
   at Microsoft.SqlTools.ServiceLayer.Connection.ConnectionService.TryOpenConnection(ConnectionInfo connectionInfo, ConnectParams connectionParams) in /_/src/Microsoft.SqlTools.ServiceLayer/Connection/ConnectionService.cs:line 692
ClientConnectionId:...

Below the console log information:

[2:40:17 PM] Connecting to server "...database.windows.net,1433" on document "....database.windows.net,1433__DEVCE".
[2:40:17 PM] Error connecting to server "twinner-devtest-sql-server.database.windows.net,1433". Details: User account '@' not found in MSAL cache, please add linked account or refresh account credentials.

Extension version: 1.19.1
VS Code version: Code 1.80.0
OS version: Linux x64 5.19.0-46-generic snap
Modes:

System Info
Item Value
CPUs 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz (8 x 3967)
GPU Status 2d_canvas: unavailable_software
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: disabled_software
multiple_raster_threads: enabled_on
opengl: disabled_off
rasterization: disabled_software
raw_draw: disabled_off_ok
video_decode: disabled_software
video_encode: disabled_software
vulkan: disabled_off
webgl: unavailable_software
webgl2: unavailable_software
webgpu: disabled_off
Load (avg) 1, 1, 1
Memory (System) 15.32GB (3.26GB free)
Process Argv --no-sandbox . --crash-reporter-id 7034c742-3ae5-4ba6-bd12-df5fc63b4452
Screen Reader no
VM 0%
DESKTOP_SESSION ubuntu
XDG_CURRENT_DESKTOP Unity
XDG_SESSION_DESKTOP ubuntu
XDG_SESSION_TYPE x11
A/B Experiments
vsliv368:30146709
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
vserr242:30382549
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
vscorecescf:30445987
vscod805:30301674
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593cf:30376535
pythonvs932:30410667
py29gd2263cf:30784848
vsclangdc:30486549
c4g48928:30535728
dsvsc012:30540252
pynewext54:30695312
azure-dev_surveyone:30548225
3biah626:30602489
pyind779:30671433
f6dab269:30613381
pythonsymbol12:30671437
showlangstatbar:30737416
vsctsb:30748421
pythonms35:30701012
03d35959:30757346
pythonfmttext:30731395
pythoncmvfstrcf:30756944
fixshowwlkth:30771522
hideindicator:30785051
pythongtdpath:30769146
i26e3531:30780429
pythonnosmt12:30779714
pythonidxpt:30784022
pythonnoceb:30776495
h7j2d465:30786200

@bard83
Copy link
Author

bard83 commented Jul 13, 2023

as reference, the same problem happens in azure data studio: microsoft/azuredatastudio#23688

@cheenamalhotra
Copy link
Member

To mitigate this issue in Linux, users can temporarily disable mssql.enableSqlAuthenticationProvider setting until fix arrives in next release.

But if its related to proxy settings, like in ADS (comment) - that would require providing correct proxy URL in http.proxy setting in VS Code. For reference: https://code.visualstudio.com/docs/setup/network#_proxy-server-support

@bard83
Copy link
Author

bard83 commented Jul 14, 2023

To mitigate this issue in Linux, users can temporarily disable mssql.enableSqlAuthenticationProvider setting until fix arrives in next release.

Helped. It's connected to the db. Tried also on ADS and worked as well.

But if its related to proxy settings, like in ADS (microsoft/azuredatastudio#23688 (comment)) - that would require providing correct proxy URL in http.proxy setting in VS Code. For reference: https://code.visualstudio.com/docs/setup/network#_proxy-server-support

As already mentioned in ADS, I'm not behind any proxy. The db connection is tunneled through ssh using bastion to the Azure database instance.

@asinitson
Copy link

asinitson commented Jul 20, 2023

Confirming that the same workaround worked for me on Linux (openSUSE 15.5, Azure Data Studio 1.44.1). For clarity this is where to set it:

  1. Open Settings
  2. Search for mssql.enableSqlAuthenticationProvider: and disable it
    image
  3. (!Important) Restart Azure Data Studio otherwise the setting change is not picked up

@TDuffinNTU
Copy link

Above workaround worked for me when I encountered the same issue on (ARM) MacOS. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants