mirror of
https://github.com/bitwarden/directory-connector
synced 2025-12-15 15:53:41 +00:00
constant program name. copyright info. stopwatch
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 });
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user