Catch exception when querying sys.logins without permissions (#1984)

This commit is contained in:
Karl Burtram
2023-04-03 19:27:05 -07:00
committed by GitHub
parent 0b2eb26d45
commit 539ad243c1

View File

@@ -293,6 +293,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Utility
}
public static string[] LoadItems(ServerConnection serverConnection, string urn)
{
try
{
List<string> items = new List<string>();
Request req = new Request();
@@ -317,5 +319,14 @@ namespace Microsoft.SqlTools.ServiceLayer.Utility
items.Sort();
return items.ToArray();
}
catch (Microsoft.SqlServer.Management.Sdk.Sfc.EnumeratorException)
{
// reading Logins can fail when trying to create a contained/SQL DB user
// when the current session does not have permissions to master
// we can return an empty existing login list in this scenario
// no need to log here since this is an expected non-blocking exception that is recoverable
return new string[0];
}
}
}
}