mirror of
https://github.com/bitwarden/directory-connector
synced 2025-12-14 23:33:19 +00:00
constant program name. copyright info. stopwatch
This commit is contained in:
@@ -38,6 +38,12 @@ namespace Bit.Console
|
|||||||
|_.__/|_|\__| \_/\_/ \__,_|_| \__,_|\___|_| |_|");
|
|_.__/|_|\__| \_/\_/ \__,_|_| \__,_|\___|_| |_|");
|
||||||
Con.ResetColor();
|
Con.ResetColor();
|
||||||
Con.WriteLine();
|
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)
|
while(true)
|
||||||
{
|
{
|
||||||
@@ -368,6 +374,7 @@ namespace Bit.Console
|
|||||||
currentType = "3";
|
currentType = "3";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Con.WriteLine();
|
||||||
Con.Write("Type [{0}]: ", currentType);
|
Con.Write("Type [{0}]: ", currentType);
|
||||||
input = Con.ReadLine();
|
input = Con.ReadLine();
|
||||||
if(!string.IsNullOrEmpty(input))
|
if(!string.IsNullOrEmpty(input))
|
||||||
@@ -394,19 +401,19 @@ namespace Bit.Console
|
|||||||
input = Con.ReadLine();
|
input = Con.ReadLine();
|
||||||
if(!string.IsNullOrEmpty(input))
|
if(!string.IsNullOrEmpty(input))
|
||||||
{
|
{
|
||||||
config.Azure.Tenant = input;
|
config.Azure.Tenant = input.Trim();
|
||||||
}
|
}
|
||||||
Con.Write("Application Id [{0}]: ", config.Azure.Id);
|
Con.Write("Application Id [{0}]: ", config.Azure.Id);
|
||||||
input = Con.ReadLine();
|
input = Con.ReadLine();
|
||||||
if(!string.IsNullOrEmpty(input))
|
if(!string.IsNullOrEmpty(input))
|
||||||
{
|
{
|
||||||
config.Azure.Id = input;
|
config.Azure.Id = input.Trim();
|
||||||
}
|
}
|
||||||
Con.Write("Secret key: ");
|
Con.Write("Secret key: ");
|
||||||
input = Con.ReadLine();
|
input = Con.ReadLine();
|
||||||
if(!string.IsNullOrEmpty(input))
|
if(!string.IsNullOrEmpty(input))
|
||||||
{
|
{
|
||||||
config.Azure.Secret = new EncryptedData(input);
|
config.Azure.Secret = new EncryptedData(input.Trim());
|
||||||
input = null;
|
input = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -418,25 +425,25 @@ namespace Bit.Console
|
|||||||
input = Con.ReadLine();
|
input = Con.ReadLine();
|
||||||
if(!string.IsNullOrEmpty(input))
|
if(!string.IsNullOrEmpty(input))
|
||||||
{
|
{
|
||||||
config.Ldap.Address = input;
|
config.Ldap.Address = input.Trim();
|
||||||
}
|
}
|
||||||
Con.Write("Port [{0}]: ", config.Ldap.Port);
|
Con.Write("Port [{0}]: ", config.Ldap.Port);
|
||||||
input = Con.ReadLine();
|
input = Con.ReadLine();
|
||||||
if(!string.IsNullOrEmpty(input))
|
if(!string.IsNullOrEmpty(input))
|
||||||
{
|
{
|
||||||
config.Ldap.Port = input;
|
config.Ldap.Port = input.Trim();
|
||||||
}
|
}
|
||||||
Con.Write("Path [{0}]: ", config.Ldap.Path);
|
Con.Write("Path [{0}]: ", config.Ldap.Path);
|
||||||
input = Con.ReadLine();
|
input = Con.ReadLine();
|
||||||
if(!string.IsNullOrEmpty(input))
|
if(!string.IsNullOrEmpty(input))
|
||||||
{
|
{
|
||||||
config.Ldap.Path = input;
|
config.Ldap.Path = input.Trim();
|
||||||
}
|
}
|
||||||
Con.Write("Username [{0}]: ", config.Ldap.Username);
|
Con.Write("Username [{0}]: ", config.Ldap.Username);
|
||||||
input = Con.ReadLine();
|
input = Con.ReadLine();
|
||||||
if(!string.IsNullOrEmpty(input))
|
if(!string.IsNullOrEmpty(input))
|
||||||
{
|
{
|
||||||
config.Ldap.Username = input;
|
config.Ldap.Username = input.Trim();
|
||||||
}
|
}
|
||||||
Con.Write("Password: ");
|
Con.Write("Password: ");
|
||||||
input = ReadSecureLine();
|
input = ReadSecureLine();
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace Bit.Core.Services
|
|||||||
|
|
||||||
private ControllerService()
|
private ControllerService()
|
||||||
{
|
{
|
||||||
Controller = new ServiceController("bitwarden Directory Connector");
|
Controller = new ServiceController(Constants.ProgramName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ControllerService Instance
|
public static ControllerService Instance
|
||||||
|
|||||||
@@ -11,5 +11,7 @@ namespace Bit.Core.Utilities
|
|||||||
public static string BaseStoragePath = string.Concat(
|
public static string BaseStoragePath = string.Concat(
|
||||||
Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData),
|
Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData),
|
||||||
"\\bitwarden\\Directory Connector");
|
"\\bitwarden\\Directory Connector");
|
||||||
|
|
||||||
|
public const string ProgramName = "bitwarden Directory Connector";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ namespace Service
|
|||||||
_serviceProcessInstaller.AfterInstall += new InstallEventHandler(AfterInstalled);
|
_serviceProcessInstaller.AfterInstall += new InstallEventHandler(AfterInstalled);
|
||||||
_serviceProcessInstaller.BeforeInstall += new InstallEventHandler(BeforeInstalled);
|
_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.";
|
_serviceInstaller.Description = "Sync directory groups and users to your bitwarden organization.";
|
||||||
Installers.AddRange(new System.Configuration.Install.Installer[] { _serviceProcessInstaller, _serviceInstaller });
|
Installers.AddRange(new System.Configuration.Install.Installer[] { _serviceProcessInstaller, _serviceInstaller });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace Service
|
|||||||
|
|
||||||
public Service()
|
public Service()
|
||||||
{
|
{
|
||||||
ServiceName = "bitwarden Directory Connector";
|
ServiceName = Constants.ProgramName;
|
||||||
|
|
||||||
_components = new Container();
|
_components = new Container();
|
||||||
|
|
||||||
@@ -99,15 +99,19 @@ namespace Service
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
var sw = Stopwatch.StartNew();
|
||||||
var result = Sync.SyncAllAsync(false, true).GetAwaiter().GetResult();
|
var result = Sync.SyncAllAsync(false, true).GetAwaiter().GetResult();
|
||||||
|
sw.Stop();
|
||||||
if(result.Success)
|
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);
|
EventLogEntryType.SuccessAudit);
|
||||||
}
|
}
|
||||||
else
|
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)
|
catch(ApplicationException e)
|
||||||
|
|||||||
Reference in New Issue
Block a user