mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-13 17:23:02 -05:00
[User Management] Fix a few bugs in login handlers (#1897)
This commit is contained in:
@@ -864,6 +864,10 @@ INNER JOIN sys.sql_logins AS sql_logins
|
||||
internal class LoginPrototype
|
||||
{
|
||||
private SqlCollationSensitiveStringComparer comparer = null;
|
||||
private static string AZURE_SERVER_ROLE_ALTER_QUERY =
|
||||
@"ALTER SERVER ROLE {0}
|
||||
{1} MEMBER [{2}]";
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// string of asterisks to display in lieu of the actual password
|
||||
@@ -912,7 +916,7 @@ INNER JOIN sys.sql_logins AS sql_logins
|
||||
private bool initialized = false;
|
||||
private Login login = null;
|
||||
private Microsoft.SqlServer.Management.Smo.Server server;
|
||||
private static string defaultLanguageDisplay;
|
||||
private static string defaultLanguageDisplay = string.Empty;
|
||||
private bool windowsAuthSupported = true;
|
||||
private bool aadAuthSupported = false;
|
||||
|
||||
@@ -1352,6 +1356,7 @@ INNER JOIN sys.sql_logins AS sql_logins
|
||||
{
|
||||
LoginType = SqlServer.Management.Smo.LoginType.SqlLogin;
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -2088,7 +2093,9 @@ INNER JOIN sys.sql_logins AS sql_logins
|
||||
this.SqlPassword = login.Password;
|
||||
this.OldPassword = login.OldPassword;
|
||||
this.LoginType = GetLoginType(login);
|
||||
if (this.DefaultLanguage != null && 0 != String.Compare(login.DefaultLanguage, SR.DefaultLanguagePlaceholder, StringComparison.Ordinal))
|
||||
if (this.DefaultLanguage != null
|
||||
&& 0 != String.Compare(login.DefaultLanguage, SR.DefaultLanguagePlaceholder, StringComparison.Ordinal)
|
||||
&& (server.DatabaseEngineType == DatabaseEngineType.Standalone|| server.DatabaseEngineEdition == DatabaseEngineEdition.SqlManagedInstance))
|
||||
{
|
||||
this.DefaultLanguage = login.DefaultLanguage.Split(" - ")[1];
|
||||
}
|
||||
@@ -2396,12 +2403,14 @@ INNER JOIN sys.sql_logins AS sql_logins
|
||||
// if the login is currently a member of the role, but wasn't originally a member, add the login to the role
|
||||
if (isCurrentlyARoleMember && !wasOriginallyARoleMember)
|
||||
{
|
||||
//run query to add
|
||||
// run query to add
|
||||
server.ExecutionManager.ConnectionContext.ExecuteNonQuery(string.Format(AZURE_SERVER_ROLE_ALTER_QUERY, role, "ADD", this.LoginName));
|
||||
}
|
||||
// if the login is not currently a member of the role, but originally was a member, remove the login from the role
|
||||
else if (!isCurrentlyARoleMember && wasOriginallyARoleMember)
|
||||
{
|
||||
//run query to drop
|
||||
server.ExecutionManager.ConnectionContext.ExecuteNonQuery(string.Format(AZURE_SERVER_ROLE_ALTER_QUERY, role, "DROP", this.LoginName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user