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 received #23286

Closed
DoblerDanRolfe opened this issue Jun 1, 2023 · 21 comments
Closed

User account not received #23286

DoblerDanRolfe opened this issue Jun 1, 2023 · 21 comments
Assignees
Labels
Area - Azure Bug Pri: 1 Size: S For a small complexity issue - only when fixed with a PR Triage: Done

Comments

@DoblerDanRolfe
Copy link

  • Azure Data Studio Version: Latest
  • OS Version: Windows 11 22H2 22621.1702

Steps to Reproduce:

  1. Updated ADS
  2. Database connections no longer work

Microsoft.Data.SqlClient.SqlException (0x80131904): User account not received.
---> System.Exception: User account not received.
at Microsoft.SqlTools.Authentication.Authenticator.GetTokenAsync(AuthenticationParams params, CancellationToken cancellationToken) in //src/Microsoft.SqlTools.Authentication/Authenticator.cs:line 110
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.<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.b__0(Task1 _) at System.Threading.Tasks.ContinuationResultTaskFromResultTask2.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.<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:e2c36b21-edfd-45cc-a3cd-6361fa610244

Does this issue occur when all extensions are disabled?: Yes/No
Yes

@github-actions
Copy link

github-actions bot commented Jun 1, 2023

We need more info to debug your Azure Active Directory issue. If you could attach your logs to the issue (ensure no private data is in them), it would help us fix the issue much faster.

  • In the settings menu, find the setting titled Azure: Logging Level and select the Verbose option
  • Run the process that produces your error
  • Open command palette (Click View -> Command Palette)
  • Run the command: Developer: Open Logs Folder
  • Follow this path to find the Azure Accounts log file: [default log folder]/exthost1/output_logging_[earliest timestamp]/#-Azure Acounts.log
  • Please attach the Azure-Accounts.log file to the issue.

@cheenamalhotra
Copy link
Member

Hi @DoblerDanRolfe

Please share verbose logs from "Azure accounts" output pane or Azure Accounts log file as per details above. You may need to reload ADS to enable verbose logging.

@DoblerDanRolfe
Copy link
Author

1-Azure Accounts.log

@cheenamalhotra
Copy link
Member

Hi @DoblerDanRolfe

Thanks for the logs, I'm able to reproduce the error, please follow below steps to mitigate the issue:

  • Close Azure Data Studio
  • Remove the cache files in folder: C:\Users\~\AppData\Roaming\azuredatastudio\Azure Accounts
  • Delete these credentials in "Windows Credentials Manager":
    • image
    • image
  • Restart Azure Data Studio and refresh credentials as prompted.

These files/creds will be regenerated fresh for you and you should be unblocked. I'll look into making sure the cleanup happens when this situation arises.

@DoblerDanRolfe
Copy link
Author

DoblerDanRolfe commented Jun 1, 2023 via email

@cheenamalhotra
Copy link
Member

Can you provide new 'VERBOSE' logs and confirm that the credentials (IV/KEY) are created for you?
You should see these logs if credentials were saved to Credential Manager:

[Information]: FileEncryptionHelper: Successfully saved encryption key accessTokenCache-iv for MSAL persistent cache encryption in system credential store. - []
[Information]: FileEncryptionHelper: Successfully saved encryption key accessTokenCache-key for MSAL persistent cache encryption in system credential store. - []

@DoblerDanRolfe
Copy link
Author

DoblerDanRolfe commented Jun 1, 2023 via email

@DoblerDanRolfe
Copy link
Author

DoblerDanRolfe commented Jun 1, 2023 via email

@cheenamalhotra
Copy link
Member

Closing issue as fix has been merged in Main, will be available in July release!

@RyanGDay
Copy link

RyanGDay commented Jun 8, 2023

Hi @DoblerDanRolfe

Thanks for the logs, I'm able to reproduce the error, please follow below steps to mitigate the issue:

  • Close Azure Data Studio

  • Remove the cache files in folder: C:\Users\~\AppData\Roaming\azuredatastudio\Azure Accounts

  • Delete these credentials in "Windows Credentials Manager":

    • image
    • image
  • Restart Azure Data Studio and refresh credentials as prompted.

These files/creds will be regenerated fresh for you and you should be unblocked. I'll look into making sure the cleanup happens when this situation arises.

These steps resolved the "User account 'foo@bar.com' not found in MSAL cache, please add linked account or refresh account credentialsl."

@DoblerDanRolfe
Copy link
Author

Hi @DoblerDanRolfe
Thanks for the logs, I'm able to reproduce the error, please follow below steps to mitigate the issue:

  • Close Azure Data Studio

  • Remove the cache files in folder: C:\Users\~\AppData\Roaming\azuredatastudio\Azure Accounts

  • Delete these credentials in "Windows Credentials Manager":

    • image
    • image
  • Restart Azure Data Studio and refresh credentials as prompted.

These files/creds will be regenerated fresh for you and you should be unblocked. I'll look into making sure the cleanup happens when this situation arises.

These steps resolved the "User account 'foo@bar.com' not found in MSAL cache, please add linked account or refresh account credentialsl."

Thanks @RyanGDay - looks like this bugfix has already been implemented into main branch and will come out in july release

@svenakela
Copy link

Is there a work around for this issue until the July release?
Installed the latest release (1.44.1 Linux Generic) on Ubuntu 23.04. Azure DS can browse available databases but as soon as I try to connect to one of them this error pops.

@DavidP-Vitro
Copy link

Hi @DoblerDanRolfe

Thanks for the logs, I'm able to reproduce the error, please follow below steps to mitigate the issue:

  • Close Azure Data Studio

  • Remove the cache files in folder: C:\Users\~\AppData\Roaming\azuredatastudio\Azure Accounts

  • Delete these credentials in "Windows Credentials Manager":

    • image
    • image
  • Restart Azure Data Studio and refresh credentials as prompted.

These files/creds will be regenerated fresh for you and you should be unblocked. I'll look into making sure the cleanup happens when this situation arises.

The first time I tried this it did not resolve the issue. The second time I also ensured that the login page opened in a Chrome window using the "Guest" profile so that it didn't have a cached login and it worked.

@mishioo
Copy link

mishioo commented Jul 4, 2023

I'm still unable to resolve the issue on Linux, unfortunately.

Azure Data Studio Version: 1.44.1
Commit: 8f53a31
Date: 2023-06-01T02:10:44.473Z
OS: Linux x64 6.4.1-arch1-1

I tried unlinking account from Azure Data Studio, removing directories ~/.config/azuredatastudio/Azure Accounts and ~/.config/azuredatastudio/CachedData, and logging back in via private chrome window to ensure there is no cached login, but to no avail, I still get the error when I try to connect.

Any more tips how could I resolve the problem, while waiting for the July release?

Stacktrace:

Microsoft.Data.SqlClient.SqlException (0x80131904): User account '[redacted]@[redacted]' not found in MSAL cache, please add linked account or refresh account credentials.
 ---> System.Exception: User account '[redacted]@[redacted]' 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:[redacted]

1-Azure-Acount-redacted.log

@cheenamalhotra
Copy link
Member

@mishioo

Please try clearing token cache with command: Azure Accounts: Clear Azure Account token cache and refresh account credentials again when prompted, that should help resolve any cache issues.

@Anganthier
Copy link

I am also running 1.44.1 with linux. Clearing the Account token cache did not help. Same error.

bye

Microsoft.Data.SqlClient.SqlException (0x80131904): User account '[redacted]' not found in MSAL cache, please add linked account or refresh account credentials.
 ---> System.Exception: User account '[redacted]' 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:e2078ec1-4f4b-47d1-8f69-c70fc4a5fcc6

@cheenamalhotra
Copy link
Member

cheenamalhotra commented Jul 7, 2023

Hi @mishioo @Anganthier

Opened a new issue to investigate (#23688) as it's a different error message and specific to Linux. Please follow the same for updates on this.

Is it possible to attach Verbose MSSQL logs on the issue as per instructions in #23688 (comment)?

@tylerberens
Copy link

@cheenamalhotra I am still receiving this error after trying all the recommendations. I've tried the manual clearing and also using the Azure Accounts: Clear Azure Account token cache. It keeps asking me to sign in and when I do I get the error.

image

@cheenamalhotra
Copy link
Member

Hi @tylerberens

Could you please capture logs as per comment (restart ADS after enabling setting) and upload them in a new issue for investigation?

@dcchristopher
Copy link

dcchristopher commented Sep 7, 2023

For users on macOS, simply find and toggle (off and back on) the Mssql: Enable Sql Authentication Provider setting. It will clear the cache and resolve the "User account 'foo@bar.com' not found in MSAL cache, please add linked account or refresh account credentials" issue. I was having this issue on 1.45.1 after months of not having accessed a particular server but where my AAD account's password had since changed.

@svenakela
Copy link

For users on macOS, simply find and toggle (off and back on) the Mssql: Enable Sql Authentication Provider setting. It will clear the cache and resolve the "User account 'foo@bar.com' not found in MSAL cache, please add linked account or refresh account credentials" issue. I was having this issue on 1.45.1 after months of not having accessed a particular server but where my AAD account's password had since changed.

This quick fix works on Linux too, but I left it disabled and used MFA access.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area - Azure Bug Pri: 1 Size: S For a small complexity issue - only when fixed with a PR Triage: Done
Projects
None yet
Development

No branches or pull requests

9 participants