mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-22 09:35:38 -05:00
SQL Agent configuration for Operators, Alerts and Proxies (WIP) (#621)
* Initial non-refactored SQL Agent alert classes (WIP) * Move agent classes into subdirectories * Refactor the agent config code a bit more * Add more implementation for handlers * Add more code to the create alert handler * Clean up agent alert class * Clean up alert methods a bit * Initial Operator contracts * Additonal SQL Agent config changes * More Proxy config cleanup * Cleanup AgentProxy class * Additional cleanups * Run SRGen * Add security service to create credential objects
This commit is contained in:
114
src/Microsoft.SqlTools.ServiceLayer/Security/Credential.cs
Normal file
114
src/Microsoft.SqlTools.ServiceLayer/Security/Credential.cs
Normal file
@@ -0,0 +1,114 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Xml;
|
||||
using Microsoft.SqlServer.Management.Common;
|
||||
using Microsoft.SqlServer.Management.Sdk.Sfc;
|
||||
using Microsoft.SqlServer.Management.Smo;
|
||||
using Microsoft.SqlServer.Management.Diagnostics;
|
||||
using Microsoft.SqlTools.ServiceLayer.Management;
|
||||
using Microsoft.SqlTools.ServiceLayer.Admin;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.Security
|
||||
{
|
||||
internal class Credential : ManagementActionBase
|
||||
{
|
||||
|
||||
// #region Trace support
|
||||
// private const string componentName = "Credential";
|
||||
|
||||
// public string ComponentName
|
||||
// {
|
||||
// get
|
||||
// {
|
||||
// return componentName;
|
||||
// }
|
||||
// }
|
||||
// #endregion
|
||||
|
||||
#region Constants
|
||||
private const int MAX_SQL_SYS_NAME_LENGTH = 128; // max sql sys name length
|
||||
private const string PASSWORD_MASK_STRING = "**********";
|
||||
#endregion
|
||||
|
||||
#region Variables
|
||||
private CredentialData credentialData = null;
|
||||
#endregion
|
||||
|
||||
#region Constructors / Dispose
|
||||
/// <summary>
|
||||
/// required when loading from Object Explorer context
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
public Credential(CDataContainer context)
|
||||
{
|
||||
this.DataContainer = context;
|
||||
this.credentialData = new CredentialData(context);
|
||||
this.credentialData.Initialize();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
protected override void Dispose( bool disposing )
|
||||
{
|
||||
base.Dispose( disposing );
|
||||
if (disposing == true)
|
||||
{
|
||||
if (this.credentialData != null)
|
||||
{
|
||||
this.credentialData.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Overrides SqlManagementUserControl
|
||||
/// <summary>
|
||||
/// called on background thread by the framework to execute the action
|
||||
/// </summary>
|
||||
/// <param name="node"></param>
|
||||
public void OnRunNow(object sender)
|
||||
{
|
||||
this.credentialData.SendDataToServer();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// update logic layer based on content of user interface
|
||||
/// </summary>
|
||||
private void UpdateLogicLayer()
|
||||
{
|
||||
|
||||
this.credentialData.CredentialName = "this.textBoxCredentialName.Text";
|
||||
this.credentialData.CredentialIdentity = "this.textBoxIdentity.Text";
|
||||
|
||||
|
||||
this.credentialData.SecurePassword = AdminService.BuildSecureStringFromPassword("password");
|
||||
this.credentialData.SecurePasswordConfirm = AdminService.BuildSecureStringFromPassword("password");
|
||||
|
||||
if (this.ServerConnection.ServerVersion.Major >= 10)
|
||||
{
|
||||
// need to update only during create time
|
||||
this.credentialData.IsEncryptionByProvider = true; //this.checkBoxUseProvider.Checked;
|
||||
if (this.credentialData.IsEncryptionByProvider)
|
||||
{
|
||||
this.credentialData.ProviderName = "this.comboBoxProviderName.SelectedItem.ToString()";
|
||||
}
|
||||
else
|
||||
{
|
||||
this.credentialData.ProviderName = string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user