From 54bd06ef98f89dbfd47c5f10544d78f1fe2a2c07 Mon Sep 17 00:00:00 2001 From: Karl Burtram Date: Mon, 17 Apr 2023 16:11:49 -0700 Subject: [PATCH] Prepopulate server roles in Login dialog (#2011) --- src/Microsoft.SqlTools.ServiceLayer/Security/LoginActions.cs | 3 +-- src/Microsoft.SqlTools.ServiceLayer/Security/LoginData.cs | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.SqlTools.ServiceLayer/Security/LoginActions.cs b/src/Microsoft.SqlTools.ServiceLayer/Security/LoginActions.cs index c737222e..c4899aeb 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/Security/LoginActions.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/Security/LoginActions.cs @@ -101,8 +101,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Security } // TODO move this to LoginData - // TODO support role assignment for Azure - prototype.ServerRoles.PopulateServerRoles(); + // TODO support role assignment for Azure foreach (string role in login.ServerRoles ?? Enumerable.Empty()) { prototype.ServerRoles.SetMember(role, true); diff --git a/src/Microsoft.SqlTools.ServiceLayer/Security/LoginData.cs b/src/Microsoft.SqlTools.ServiceLayer/Security/LoginData.cs index a80c0fdf..d664a075 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/Security/LoginData.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/Security/LoginData.cs @@ -1514,6 +1514,7 @@ INNER JOIN sys.sql_logins AS sql_logins } this.serverRoles = new ServerRoles(server, login.Name); + this.serverRoles.PopulateServerRoles(); this.databaseRolesCollection = new HybridDictionary(); if (server.Information.Version.Major == 9 && !string.IsNullOrEmpty(login.Credential)) { @@ -1539,6 +1540,7 @@ INNER JOIN sys.sql_logins AS sql_logins this.defaultLanguage = LoginPrototypeData.DefaultLanguageDisplay; this.serverRoles = new ServerRoles(server); + this.serverRoles.PopulateServerRoles(); this.databaseRolesCollection = new HybridDictionary(); this.credentials = new StringCollection(); }