Fix Sql Auth for Migration Assessments (#1182)

* pass connection string to dma engine

* cleanup

* remove optional parameter

* modified query
This commit is contained in:
Christopher Suh
2021-03-26 15:59:07 -07:00
committed by GitHub
parent 5a8cfab8fa
commit 2badd8e728
2 changed files with 10 additions and 7 deletions

View File

@@ -55,9 +55,13 @@ SELECT @filepath AS FilePath
SELECT [name], [description], [endpoint], [protocol_desc] FROM .[sys].[dm_cluster_endpoints]
END TRY
BEGIN CATCH
DECLARE @endpoint VARCHAR(max)
select @endpoint = CONVERT(VARCHAR(max),SERVERPROPERTY('ControllerEndpoint'))
DECLARE @endpoint VARCHAR(MAX)
SELECT @endpoint = CONVERT(VARCHAR(MAX),SERVERPROPERTY('ControllerEndpoint'))
-- If the endpoint is empty/null then return 0 rows (we don't have any cluster endpoints)
IF @endpoint <> ''
SELECT 'controller' AS name, 'Cluster Management Service' AS description, @endpoint as endpoint, SUBSTRING(@endpoint, 0, CHARINDEX(':', @endpoint))
ELSE
SELECT TOP 0 ''
END CATCH
";
public const string GetHostInfo = @"SELECT [host_platform], [host_distribution], [host_release], [host_service_pack_level], [host_sku], [os_language_version] FROM sys.dm_os_host_info";

View File

@@ -119,7 +119,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Migration
await ConnectionService.Connect(connectParams);
var connection = await ConnectionService.Instance.GetOrOpenConnection(randomUri, ConnectionType.Default);
var serverInfo = ReliableConnectionHelper.GetServerVersion(connection);
var hostInfo = ReliableConnectionHelper.GetServerHostInfo(connection);
@@ -136,8 +135,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Migration
};
var db = SqlAssessmentService.GetDatabaseLocator(server, connection.Database);
var results = await GetAssessmentItems(server);
var connectionString = ConnectionService.BuildConnectionString(connInfo.ConnectionDetails);
var results = await GetAssessmentItems(server, connectionString);
var result = new MigrationAssessmentResult();
result.Items.AddRange(results);
await requestContext.SendResult(result);
@@ -179,9 +178,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Migration
}
}
internal async Task<List<MigrationAssessmentInfo>> GetAssessmentItems(SqlObjectLocator target)
internal async Task<List<MigrationAssessmentInfo>> GetAssessmentItems(SqlObjectLocator target, string connectionString)
{
DmaEngine engine = new DmaEngine(target);
DmaEngine engine = new DmaEngine(connectionString);
var assessmentResults = await engine.GetTargetAssessmentResultsList();
var result = new List<MigrationAssessmentInfo>();