Skip to content

Commit

Permalink
Fix to (re)enable lower-privilege connection strings
Browse files Browse the repository at this point in the history
  • Loading branch information
cgillum committed Sep 13, 2024
1 parent 92bc1f0 commit 0fc69eb
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/DurableTask.SqlServer/SqlDbManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,21 @@ async Task EnsureDatabaseExistsAsync()
{
// Note that we may not be able to connect to the DB, let alone obtain the lock,
// if the database does not exist yet. So we obtain a connection to the 'master' database for now.
// If the current connection doesn't have permission to access the master database, this will fail
// with a "Login failed for user ..." error, in which case we log and return.
using SqlConnection connection = this.settings.CreateConnection("master");
await connection.OpenAsync();
try
{
await connection.OpenAsync();
}
catch (SqlException e) when (e.Number == 18456 /* LOGON_FAILED */)
{
this.traceHelper.GenericInfoEvent(
"Failed to connect to the master database. The user may not have permission to access the " +
"master database. Skipping database exists check.",
instanceId: null);
return;
}

if (!await this.DoesDatabaseExistAsync(this.settings.DatabaseName, connection))
{
Expand Down

0 comments on commit 0fc69eb

Please sign in to comment.