public InstallationInfo GetDetails(ConnectionInfo connectionInfo)
        {
            string domainDbConnectionString = connectionInfo.CreateConnectionString(_databaseName);

            ILabInformationProvider labInformationProvider = _labDetailsProviderFactory();
            return labInformationProvider.GetLabInfo(domainDbConnectionString);
        }
        public IEnumerable<ConnectionInfo> Guess(ConnectionInfo info)
        {
            string[] userNames = string.IsNullOrEmpty(info.UserName) ? _userNames : new[] { info.UserName };
            string[] passwords = string.IsNullOrEmpty(info.Password) ? _passwords : new[] { info.Password };
            string[] instances = string.IsNullOrEmpty(info.Instance) ? _instances : new[] { info.Instance };

            return GetAllConnectionStringsPermutations(info.Host, instances, userNames, passwords);
        }
        private void ConnectionFailedHandler(ConnectionInfo connectionInfo, Exception exception)
        {
            if (ConnectionFailed != null)
            {
                ConnectionFailed(connectionInfo, exception);
            }

            CountDown();
        }
        private void ConnectionSucceeded(ConnectionInfo connectionInfo)
        {
            InstallationInfo installationInfo = _labDetailsProvider.GetDetails(connectionInfo);

            LabInfo labInfo = new LabInfo(connectionInfo, installationInfo);

            _connectionResolverViewModel.LabInfoViewModels.Add(new LabInfoViewModel(labInfo));
            _connectionResolverViewModel.SelectedLabInfoViewModel = _connectionResolverViewModel.LabInfoViewModels[0];
        }
        private static string ConnectionInfoToConnectionString(ConnectionInfo connectionInfo)
        {
            SqlConnectionStringBuilder connectionStringBuilder = new SqlConnectionStringBuilder
                {
                    ConnectTimeout = 3
                };

            connectionInfo.UpdateConnectionString(connectionStringBuilder);

            return connectionStringBuilder.ConnectionString;
        }
        public void Update(ConnectionInfo connectionInfo)
        {
            IProjectConfiguration projectConfiguration = _configProvider.GetConfig();

            var connectionStringsSection = (ConnectionStringsSection)projectConfiguration.GetSection("connectionStrings");

            foreach (ConnectionStringSettings connectionStringSettings in connectionStringsSection.ConnectionStrings)
            {
                string updatedConnectionString = connectionInfo.UpdateConnectionString(connectionStringSettings.ConnectionString);
                connectionStringSettings.ConnectionString = updatedConnectionString;
            }

            projectConfiguration.Save();
        }
        private IEnumerable<ConnectionInfo> GetAllConnectionStringsPermutations(string ip, IEnumerable<string> instances, string[] userNames, string[] passwords)
        {
            foreach (string instance in instances)
            {
                foreach (string userName in userNames)
                {
                    foreach (string password in passwords)
                    {
                        ConnectionInfo info = new ConnectionInfo();
                        info.Host = ip;
                        info.Instance = instance;
                        info.UserName = userName;
                        info.Password = password;

                        yield return info;
                    }
                }
            }
        }
        public void UpdateConfigsCommandIsExecuted_ItChecksOutAndUpdatesTheConfigFiles()
        {
            var filledConnectionInfo = new ConnectionInfo()
            {
                Host = "expectedHost",
                DataSource = "expectedDataSource",
                Instance = "expectedInstance",
                UserName = "******",
                Password = "******"
            };

            var installationInfo = new InstallationInfo()
            {
                UserSid = 123,
                Version = "3.4.5"
            };

            DeleteBranchFolder();
            DeployBranchFolder();
            ChangeCurrentDirectoryToDaSourceFolder();

            ConnectionResolverViewModel viewModel = CreateViewModel();

            viewModel.InputConnectionDetails = new ConnectionInfoViewModel(filledConnectionInfo);
            viewModel.SelectedLabInfoViewModel = new LabInfoViewModel(new LabInfo(filledConnectionInfo, installationInfo));

            viewModel.UpdateConfigsCommand.Execute(null);

            Configuration daConfiguration = OpenConfig(@"Windows\DataVantage.Windows\app.config");
            Configuration mcConfiguration = OpenConfig(@"..\..\ManagementConsole\Source\Varonis.UI.ManagementConsole.Shell\app.config");
            Configuration serverConfiguration = OpenConfig(@"..\..\Server\Source\Varonis.Server.WindowsService\app.config");

            Assert.AreEqual("3.4.5", daConfiguration.AppSettings.Settings["ProductVersion"].Value);
            Assert.AreEqual("123", daConfiguration.AppSettings.Settings["IMPERSONATION_SIDID"].Value);
            Assert.AreEqual("3.4.5", mcConfiguration.AppSettings.Settings["ProductVersion"].Value);
            Assert.AreEqual("123", mcConfiguration.AppSettings.Settings["IMPERSONATION_SIDID"].Value);
            Assert.AreEqual(@"Data Source=expectedDataSource\expectedInstance;Integrated Security=False;User ID=expectedUserName;Password=expectedPasseword",
                ((ConnectionStringsSection)serverConfiguration.GetSection("connectionStrings")).ConnectionStrings["vrnsDomainDB"].ConnectionString);

            RestoreCurrentFolder();
            DeleteBranchFolder();
        }
        public void Resolve(ConnectionInfo info)
        {
            if (string.IsNullOrEmpty(info.Host))
            {
                throw new Exception("Cannot resolve connection string. IP cannot be null");
            }

            IEnumerable<ConnectionInfo> guessedConnectionInfos = _connectionInfoGuesser.Guess(info);

            IEnumerable<IConnectionStringVerifier> verifiers = guessedConnectionInfos.Select(connectionInfo =>
            {
                var verifier = _connectionStringVerifierFactory(connectionInfo);
                verifier.ConnectionFailed += ConnectionFailedHandler;
                verifier.ConnectionSucceeded += ConnectionSucceededHandler;
                return verifier;
            }).ToArray();

            _progressCountDown = verifiers.Count();

            foreach (ConnectionStringVerifier verifier in verifiers)
            {
                verifier.BeginVerify();
            }
        }
        private void ConnectionSucceededHandler(ConnectionInfo connectionInfo)
        {
            if (ConnectionSucceeded != null)
            {
                ConnectionSucceeded(connectionInfo);
            }

            CountDown();
        }
Beispiel #11
0
 protected bool Equals(ConnectionInfo other)
 {
     return string.Equals(Host, other.Host) && string.Equals(Instance, other.Instance) && string.Equals(UserName, other.UserName) && string.Equals(Password, other.Password);
 }
 public ConnectionStringVerifier(ConnectionInfo connectionInfo)
 {
     _connectionInfo = connectionInfo;
 }
 public LabInfo(ConnectionInfo connectionInfo, InstallationInfo installationInfo)
 {
     ConnectionInfo = connectionInfo;
     InstallationInfo = installationInfo;
 }
 public ConnectionInfoViewModel(ConnectionInfo connectionInfo)
 {
     _connectionInfo = connectionInfo;
 }