mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-16 10:58:30 -05:00
Add security tab (#2187)
This commit is contained in:
@@ -62,7 +62,9 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
|
|||||||
MaxServerMemory = prototype.MaxServerMemory,
|
MaxServerMemory = prototype.MaxServerMemory,
|
||||||
AutoProcessorAffinityMaskForAll = prototype.AutoProcessorAffinityMaskForAll,
|
AutoProcessorAffinityMaskForAll = prototype.AutoProcessorAffinityMaskForAll,
|
||||||
AutoProcessorAffinityIOMaskForAll = prototype.AutoProcessorAffinityIOMaskForAll,
|
AutoProcessorAffinityIOMaskForAll = prototype.AutoProcessorAffinityIOMaskForAll,
|
||||||
NumaNodes = prototype.NumaNodes
|
NumaNodes = prototype.NumaNodes,
|
||||||
|
AuthenticationMode = prototype.AuthenticationMode,
|
||||||
|
LoginAuditing = prototype.LoginAuditing
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
var context = new ServerViewContext(requestParams);
|
var context = new ServerViewContext(requestParams);
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using Microsoft.SqlServer.Management.Smo;
|
||||||
|
|
||||||
namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
|
namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
|
||||||
{
|
{
|
||||||
@@ -35,6 +36,8 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
|
|||||||
public bool AutoProcessorAffinityMaskForAll { get; set; }
|
public bool AutoProcessorAffinityMaskForAll { get; set; }
|
||||||
public bool AutoProcessorAffinityIOMaskForAll { get; set; }
|
public bool AutoProcessorAffinityIOMaskForAll { get; set; }
|
||||||
public List<NumaNode> NumaNodes { get; set; }
|
public List<NumaNode> NumaNodes { get; set; }
|
||||||
|
public ServerLoginMode AuthenticationMode { get; set; }
|
||||||
|
public AuditLevel LoginAuditing { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class NumericServerProperty
|
public class NumericServerProperty
|
||||||
|
|||||||
@@ -331,6 +331,32 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
|
|||||||
this.currentState.NumaNodes = value;
|
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
|
#endregion
|
||||||
|
|
||||||
@@ -363,8 +389,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
|
|||||||
{
|
{
|
||||||
if (this.dataContainer.Server != null)
|
if (this.dataContainer.Server != null)
|
||||||
{
|
{
|
||||||
Microsoft.SqlServer.Management.Smo.Server server = this.dataContainer.Server;
|
Server server = this.dataContainer.Server;
|
||||||
bool changesMade = false;
|
|
||||||
bool alterServerConfig = false;
|
bool alterServerConfig = false;
|
||||||
bool sendCPUAffinityBeforeIO = false;
|
bool sendCPUAffinityBeforeIO = false;
|
||||||
bool sendIOAffinityBeforeCPU = false;
|
bool sendIOAffinityBeforeCPU = false;
|
||||||
@@ -397,16 +422,19 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
|
|||||||
this.currentState.AffinityManagerProcessorMask.Clear();
|
this.currentState.AffinityManagerProcessorMask.Clear();
|
||||||
this.currentState.AffinityManagerIOMask.Clear();
|
this.currentState.AffinityManagerIOMask.Clear();
|
||||||
|
|
||||||
changesMade = UpdateMemoryValues(this.dataContainer.Server);
|
if (UpdateMemoryValues(this.dataContainer.Server))
|
||||||
|
|
||||||
if (changesMade)
|
|
||||||
{
|
{
|
||||||
server.Configuration.Alter(true);
|
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;
|
bool changesMade = false;
|
||||||
if (this.currentState.MinMemory.Value != this.originalState.MinMemory.Value)
|
if (this.currentState.MinMemory.Value != this.originalState.MinMemory.Value)
|
||||||
@@ -425,6 +453,25 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
|
|||||||
return changesMade;
|
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)
|
private bool CheckCPUAffinityBeforeIO(SMO.Server smoServer)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < this.NumaNodes.Count; i++)
|
for (int i = 0; i < this.NumaNodes.Count; i++)
|
||||||
@@ -601,6 +648,8 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
|
|||||||
this.AutoProcessorAffinityMaskForAll = serverInfo.AutoProcessorAffinityMaskForAll;
|
this.AutoProcessorAffinityMaskForAll = serverInfo.AutoProcessorAffinityMaskForAll;
|
||||||
this.AutoProcessorAffinityIOMaskForAll = serverInfo.AutoProcessorAffinityIOMaskForAll;
|
this.AutoProcessorAffinityIOMaskForAll = serverInfo.AutoProcessorAffinityIOMaskForAll;
|
||||||
this.NumaNodes = serverInfo.NumaNodes.ToList();
|
this.NumaNodes = serverInfo.NumaNodes.ToList();
|
||||||
|
this.AuthenticationMode = serverInfo.AuthenticationMode;
|
||||||
|
this.LoginAuditing = serverInfo.LoginAuditing;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -636,6 +685,8 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
|
|||||||
private bool autoProcessorAffinityMaskForAll = false;
|
private bool autoProcessorAffinityMaskForAll = false;
|
||||||
private bool autoProcessorAffinityIOMaskForAll = false;
|
private bool autoProcessorAffinityIOMaskForAll = false;
|
||||||
private List<NumaNode> numaNodes = new List<NumaNode>();
|
private List<NumaNode> numaNodes = new List<NumaNode>();
|
||||||
|
private ServerLoginMode authenticationMode = ServerLoginMode.Integrated;
|
||||||
|
private AuditLevel loginAuditing = AuditLevel.None;
|
||||||
|
|
||||||
private bool initialized = false;
|
private bool initialized = false;
|
||||||
private Server server;
|
private Server server;
|
||||||
@@ -652,32 +703,6 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
|
|||||||
ConfigProperty serverMinMemoryProperty;
|
ConfigProperty serverMinMemoryProperty;
|
||||||
#endregion
|
#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
|
#region Properties
|
||||||
|
|
||||||
// General 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
|
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
|
#endregion
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -1278,6 +1372,8 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
|
|||||||
result.autoProcessorAffinityMaskForAll = this.autoProcessorAffinityMaskForAll;
|
result.autoProcessorAffinityMaskForAll = this.autoProcessorAffinityMaskForAll;
|
||||||
result.autoProcessorAffinityIOMaskForAll = this.autoProcessorAffinityIOMaskForAll;
|
result.autoProcessorAffinityIOMaskForAll = this.autoProcessorAffinityIOMaskForAll;
|
||||||
result.numaNodes = this.numaNodes;
|
result.numaNodes = this.numaNodes;
|
||||||
|
result.authenticationMode = this.authenticationMode;
|
||||||
|
result.loginAuditing = this.loginAuditing;
|
||||||
result.server = this.server;
|
result.server = this.server;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -1317,6 +1413,8 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
|
|||||||
|
|
||||||
this.numaNodes = GetNumaNodes();
|
this.numaNodes = GetNumaNodes();
|
||||||
GetAutoProcessorsAffinity();
|
GetAutoProcessorsAffinity();
|
||||||
|
this.authenticationMode = server.LoginMode;
|
||||||
|
this.loginAuditing = server.AuditLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadMemoryProperties()
|
private void LoadMemoryProperties()
|
||||||
|
|||||||
Reference in New Issue
Block a user