diff --git a/src/Console/Program.cs b/src/Console/Program.cs index ab173fb7..7c943e61 100644 --- a/src/Console/Program.cs +++ b/src/Console/Program.cs @@ -38,6 +38,12 @@ namespace Bit.Console |_.__/|_|\__| \_/\_/ \__,_|_| \__,_|\___|_| |_|"); Con.ResetColor(); Con.WriteLine(); + Con.WriteLine(Constants.ProgramName); + Con.WriteLine("Copyright 2015-{0}, 8bit Solutions LLC", DateTime.Now.Year); + Con.WriteLine(); + Con.WriteLine("https://bitwarden.com"); + Con.WriteLine("https://github.com/bitwarden/directory-connector"); + Con.WriteLine(); while(true) { @@ -368,6 +374,7 @@ namespace Bit.Console currentType = "3"; break; } + Con.WriteLine(); Con.Write("Type [{0}]: ", currentType); input = Con.ReadLine(); if(!string.IsNullOrEmpty(input)) @@ -394,19 +401,19 @@ namespace Bit.Console input = Con.ReadLine(); if(!string.IsNullOrEmpty(input)) { - config.Azure.Tenant = input; + config.Azure.Tenant = input.Trim(); } Con.Write("Application Id [{0}]: ", config.Azure.Id); input = Con.ReadLine(); if(!string.IsNullOrEmpty(input)) { - config.Azure.Id = input; + config.Azure.Id = input.Trim(); } Con.Write("Secret key: "); input = Con.ReadLine(); if(!string.IsNullOrEmpty(input)) { - config.Azure.Secret = new EncryptedData(input); + config.Azure.Secret = new EncryptedData(input.Trim()); input = null; } } @@ -418,25 +425,25 @@ namespace Bit.Console input = Con.ReadLine(); if(!string.IsNullOrEmpty(input)) { - config.Ldap.Address = input; + config.Ldap.Address = input.Trim(); } Con.Write("Port [{0}]: ", config.Ldap.Port); input = Con.ReadLine(); if(!string.IsNullOrEmpty(input)) { - config.Ldap.Port = input; + config.Ldap.Port = input.Trim(); } Con.Write("Path [{0}]: ", config.Ldap.Path); input = Con.ReadLine(); if(!string.IsNullOrEmpty(input)) { - config.Ldap.Path = input; + config.Ldap.Path = input.Trim(); } Con.Write("Username [{0}]: ", config.Ldap.Username); input = Con.ReadLine(); if(!string.IsNullOrEmpty(input)) { - config.Ldap.Username = input; + config.Ldap.Username = input.Trim(); } Con.Write("Password: "); input = ReadSecureLine(); diff --git a/src/Core/Services/ControllerService.cs b/src/Core/Services/ControllerService.cs index a5b36881..17fdfc8c 100644 --- a/src/Core/Services/ControllerService.cs +++ b/src/Core/Services/ControllerService.cs @@ -17,7 +17,7 @@ namespace Bit.Core.Services private ControllerService() { - Controller = new ServiceController("bitwarden Directory Connector"); + Controller = new ServiceController(Constants.ProgramName); } public static ControllerService Instance diff --git a/src/Core/Utilities/Constants.cs b/src/Core/Utilities/Constants.cs index 24a17134..ad1aecba 100644 --- a/src/Core/Utilities/Constants.cs +++ b/src/Core/Utilities/Constants.cs @@ -11,5 +11,7 @@ namespace Bit.Core.Utilities public static string BaseStoragePath = string.Concat( Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "\\bitwarden\\Directory Connector"); + + public const string ProgramName = "bitwarden Directory Connector"; } } diff --git a/src/Service/Installer.cs b/src/Service/Installer.cs index fa3c6360..0846196b 100644 --- a/src/Service/Installer.cs +++ b/src/Service/Installer.cs @@ -38,7 +38,7 @@ namespace Service _serviceProcessInstaller.AfterInstall += new InstallEventHandler(AfterInstalled); _serviceProcessInstaller.BeforeInstall += new InstallEventHandler(BeforeInstalled); - _serviceInstaller.ServiceName = "bitwarden Directory Connector"; + _serviceInstaller.ServiceName = Constants.ProgramName; _serviceInstaller.Description = "Sync directory groups and users to your bitwarden organization."; Installers.AddRange(new System.Configuration.Install.Installer[] { _serviceProcessInstaller, _serviceInstaller }); } diff --git a/src/Service/Service.cs b/src/Service/Service.cs index e8bd3a62..6cc0804d 100644 --- a/src/Service/Service.cs +++ b/src/Service/Service.cs @@ -22,7 +22,7 @@ namespace Service public Service() { - ServiceName = "bitwarden Directory Connector"; + ServiceName = Constants.ProgramName; _components = new Container(); @@ -99,15 +99,19 @@ namespace Service { try { + var sw = Stopwatch.StartNew(); var result = Sync.SyncAllAsync(false, true).GetAwaiter().GetResult(); + sw.Stop(); if(result.Success) { - _eventLog.WriteEntry($"Synced {result.Groups.Count} groups, {result.Users.Count} users.", + _eventLog.WriteEntry($"Synced {result.Groups.Count} groups, {result.Users.Count} users." + + $"The sync took {(int)sw.Elapsed.TotalSeconds} seconds to complete.", EventLogEntryType.SuccessAudit); } else { - _eventLog.WriteEntry($"Sync failed: {result.ErrorMessage}", EventLogEntryType.FailureAudit); + _eventLog.WriteEntry($"Sync failed after {(int)sw.Elapsed.TotalSeconds} seconds: {result.ErrorMessage}.", + EventLogEntryType.FailureAudit); } } catch(ApplicationException e)