From be39647895066c36ed973051b428ff00fa88781d Mon Sep 17 00:00:00 2001 From: Axel Marquez Date: Tue, 20 Feb 2024 12:36:58 -0600 Subject: [PATCH] Add ConnectionString argument --- .../GenerateSecurityGraphs/Program.cs | 40 +++---------------- 1 file changed, 5 insertions(+), 35 deletions(-) diff --git a/Utilities/GenerateSecurityGraphs/GenerateSecurityGraphs/Program.cs b/Utilities/GenerateSecurityGraphs/GenerateSecurityGraphs/Program.cs index 7584edb295..8861289392 100644 --- a/Utilities/GenerateSecurityGraphs/GenerateSecurityGraphs/Program.cs +++ b/Utilities/GenerateSecurityGraphs/GenerateSecurityGraphs/Program.cs @@ -45,22 +45,11 @@ internal class Options [Option('f', "force", Default = false, HelpText = "Create a folder at that path if one doesn't already exist.")] public bool Force { get; set; } - [Option('d', "database", Default = "EdFi_Security", HelpText = "The name of the database containing the authorization metadata.")] - public string Database { get; set; } - - [Option( - 's', "server", Default = "(local)", HelpText = "The name of the SQL Server where the authorization metadata database is located.")] - public string Server { get; set; } - [Option( - 'u', "user", HelpText = - "The SQL Server username to use for connecting to the authorization metadata database. Leave username and password blank to use integrated security.")] - public string User { get; set; } - - [Option( - 'p', "password", HelpText = - "The password to use for connecting to the authorization metadata database. Leave username and password blank to use integrated security.")] - public string Password { get; set; } + 'c', "connectionString", + Default = "Server=(local);Database=EdFi_Security;Trusted_Connection=True;Encrypt=False", + HelpText = "The connection string for connecting to the authorization metadata database. Leave blank to connect to the local 'EdFi_Security' database using integrated security.")] + public string ConnectionString { get; set; } [Option( 'g', "graphviz", Default = @"C:/Program Files/Graphviz/", HelpText = @@ -97,25 +86,6 @@ private static async Task Main(string[] args) if (failedToParse) return; - string connectionString; - - if (options.User == null || options.Password == null) - { - connectionString = string.Format( - "Server={0};Database={1};Trusted_Connection=True;Encrypt=False", - options.Server, - options.Database); - } - else - { - connectionString = string.Format( - "Server={0};Database={1};User ID={2};Password={3};Encrypt=False", - options.Server, - options.Database, - options.User, - options.Password); - } - string baseFolderPath; if (Path.IsPathRooted(options.OutputFolder)) @@ -179,7 +149,7 @@ private static async Task Main(string[] args) Console.WriteLine("Generating graphs, please wait ..."); // Load all authorization metadata into a graph and a list of claim sets - var resourceGraph = LoadAuthorizationMetadataGraph(connectionString, out var claimSetNames); + var resourceGraph = LoadAuthorizationMetadataGraph(options.ConnectionString, out var claimSetNames); var rootNodes = GetRootNodes(resourceGraph); var assetsSourceFolder = Path.Combine(