mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-16 18:47:57 -05:00
Catch exception when querying sys.logins without permissions (#1984)
This commit is contained in:
@@ -293,6 +293,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Utility
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static string[] LoadItems(ServerConnection serverConnection, string urn)
|
public static string[] LoadItems(ServerConnection serverConnection, string urn)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
List<string> items = new List<string>();
|
List<string> items = new List<string>();
|
||||||
Request req = new Request();
|
Request req = new Request();
|
||||||
@@ -317,5 +319,14 @@ namespace Microsoft.SqlTools.ServiceLayer.Utility
|
|||||||
items.Sort();
|
items.Sort();
|
||||||
return items.ToArray();
|
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];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user