Add security tab (#2187)

This commit is contained in:
Barbara Valdez
2023-08-31 09:52:58 -07:00
committed by GitHub
parent 724d533090
commit 5f17826359
3 changed files with 136 additions and 33 deletions

View File

@@ -62,7 +62,9 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
MaxServerMemory = prototype.MaxServerMemory,
AutoProcessorAffinityMaskForAll = prototype.AutoProcessorAffinityMaskForAll,
AutoProcessorAffinityIOMaskForAll = prototype.AutoProcessorAffinityIOMaskForAll,
NumaNodes = prototype.NumaNodes
NumaNodes = prototype.NumaNodes,
AuthenticationMode = prototype.AuthenticationMode,
LoginAuditing = prototype.LoginAuditing
};
}
var context = new ServerViewContext(requestParams);

View File

@@ -5,6 +5,7 @@
#nullable disable
using System.Collections.Generic;
using Microsoft.SqlServer.Management.Smo;
namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
{
@@ -35,6 +36,8 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
public bool AutoProcessorAffinityMaskForAll { get; set; }
public bool AutoProcessorAffinityIOMaskForAll { get; set; }
public List<NumaNode> NumaNodes { get; set; }
public ServerLoginMode AuthenticationMode { get; set; }
public AuditLevel LoginAuditing { get; set; }
}
public class NumericServerProperty

View File

@@ -331,6 +331,32 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
this.currentState.NumaNodes = value;
}
}
public ServerLoginMode AuthenticationMode
{
get
{
return this.currentState.AuthenticationMode;
}
set
{
this.currentState.AuthenticationMode = value;
}
}
public AuditLevel LoginAuditing
{
get
{
return this.currentState.LoginAuditing;
}
set
{
this.currentState.LoginAuditing = value;
}
}
#endregion
@@ -363,8 +389,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
{
if (this.dataContainer.Server != null)
{
Microsoft.SqlServer.Management.Smo.Server server = this.dataContainer.Server;
bool changesMade = false;
Server server = this.dataContainer.Server;
bool alterServerConfig = false;
bool sendCPUAffinityBeforeIO = false;
bool sendIOAffinityBeforeCPU = false;
@@ -397,16 +422,19 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
this.currentState.AffinityManagerProcessorMask.Clear();
this.currentState.AffinityManagerIOMask.Clear();
changesMade = UpdateMemoryValues(this.dataContainer.Server);
if (changesMade)
if (UpdateMemoryValues(this.dataContainer.Server))
{
server.Configuration.Alter(true);
}
if (UpdateSecurityValues(this.dataContainer.Server))
{
server.Alter();
}
}
}
public bool UpdateMemoryValues(Microsoft.SqlServer.Management.Smo.Server server)
public bool UpdateMemoryValues(Server server)
{
bool changesMade = false;
if (this.currentState.MinMemory.Value != this.originalState.MinMemory.Value)
@@ -425,6 +453,25 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
return changesMade;
}
public bool UpdateSecurityValues(Server server)
{
bool alterServer = false;
if (this.currentState.AuthenticationMode != this.originalState.AuthenticationMode)
{
// set authentication
server.Settings.LoginMode = this.currentState.AuthenticationMode;
alterServer = true;
}
if (this.currentState.LoginAuditing != this.originalState.LoginAuditing)
{
server.Settings.AuditLevel = this.currentState.LoginAuditing;
alterServer = true;
}
return alterServer;
}
private bool CheckCPUAffinityBeforeIO(SMO.Server smoServer)
{
for (int i = 0; i < this.NumaNodes.Count; i++)
@@ -601,6 +648,8 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
this.AutoProcessorAffinityMaskForAll = serverInfo.AutoProcessorAffinityMaskForAll;
this.AutoProcessorAffinityIOMaskForAll = serverInfo.AutoProcessorAffinityIOMaskForAll;
this.NumaNodes = serverInfo.NumaNodes.ToList();
this.AuthenticationMode = serverInfo.AuthenticationMode;
this.LoginAuditing = serverInfo.LoginAuditing;
}
/// <summary>
@@ -636,6 +685,8 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
private bool autoProcessorAffinityMaskForAll = false;
private bool autoProcessorAffinityIOMaskForAll = false;
private List<NumaNode> numaNodes = new List<NumaNode>();
private ServerLoginMode authenticationMode = ServerLoginMode.Integrated;
private AuditLevel loginAuditing = AuditLevel.None;
private bool initialized = false;
private Server server;
@@ -652,32 +703,6 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
ConfigProperty serverMinMemoryProperty;
#endregion
public AffinityManager AffinityManagerIOMask
{
get
{
return this.affinityManagerIOMask;
}
set
{
this.affinityManagerIOMask = value;
}
}
public AffinityManager AffinityManagerProcessorMask
{
get
{
return this.affinityManagerProcessorMask;
}
set
{
this.affinityManagerProcessorMask = value;
}
}
#region Properties
// General properties
@@ -1197,6 +1222,49 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
}
}
public ServerLoginMode AuthenticationMode
{
get
{
if (!this.initialized)
{
LoadData();
}
return this.authenticationMode;
}
set
{
if (this.initialized)
{
Logger.Error(SR.PropertyNotInitialized("AuthenticationMode"));
}
this.authenticationMode = value;
}
}
public AuditLevel LoginAuditing
{
get
{
if (!this.initialized)
{
LoadData();
}
return this.loginAuditing;
}
set
{
if (this.initialized)
{
Logger.Error(SR.PropertyNotInitialized("LoginAuditing"));
}
this.loginAuditing = value;
}
}
public Microsoft.SqlServer.Management.Smo.Server Server
{
@@ -1214,6 +1282,32 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
}
}
public AffinityManager AffinityManagerIOMask
{
get
{
return this.affinityManagerIOMask;
}
set
{
this.affinityManagerIOMask = value;
}
}
public AffinityManager AffinityManagerProcessorMask
{
get
{
return this.affinityManagerProcessorMask;
}
set
{
this.affinityManagerProcessorMask = value;
}
}
#endregion
/// <summary>
@@ -1278,6 +1372,8 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
result.autoProcessorAffinityMaskForAll = this.autoProcessorAffinityMaskForAll;
result.autoProcessorAffinityIOMaskForAll = this.autoProcessorAffinityIOMaskForAll;
result.numaNodes = this.numaNodes;
result.authenticationMode = this.authenticationMode;
result.loginAuditing = this.loginAuditing;
result.server = this.server;
return result;
}
@@ -1317,6 +1413,8 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
this.numaNodes = GetNumaNodes();
GetAutoProcessorsAffinity();
this.authenticationMode = server.LoginMode;
this.loginAuditing = server.AuditLevel;
}
private void LoadMemoryProperties()