Exemplo n.º 1
0
        public InstallationInfo GetDetails(ConnectionInfo connectionInfo)
        {
            string domainDbConnectionString = connectionInfo.CreateConnectionString(_databaseName);

            ILabInformationProvider labInformationProvider = _labDetailsProviderFactory();
            return labInformationProvider.GetLabInfo(domainDbConnectionString);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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];
        }
Exemplo n.º 5
0
        private static string ConnectionInfoToConnectionString(ConnectionInfo connectionInfo)
        {
            SqlConnectionStringBuilder connectionStringBuilder = new SqlConnectionStringBuilder
                {
                    ConnectTimeout = 3
                };

            connectionInfo.UpdateConnectionString(connectionStringBuilder);

            return connectionStringBuilder.ConnectionString;
        }
Exemplo n.º 6
0
        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();
        }
Exemplo n.º 7
0
        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();
        }
Exemplo n.º 9
0
        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();
            }
        }
Exemplo n.º 10
0
        private void ConnectionSucceededHandler(ConnectionInfo connectionInfo)
        {
            if (ConnectionSucceeded != null)
            {
                ConnectionSucceeded(connectionInfo);
            }

            CountDown();
        }
Exemplo n.º 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);
 }
Exemplo n.º 12
0
 public ConnectionStringVerifier(ConnectionInfo connectionInfo)
 {
     _connectionInfo = connectionInfo;
 }
Exemplo n.º 13
0
 public LabInfo(ConnectionInfo connectionInfo, InstallationInfo installationInfo)
 {
     ConnectionInfo = connectionInfo;
     InstallationInfo = installationInfo;
 }
Exemplo n.º 14
0
 public ConnectionInfoViewModel(ConnectionInfo connectionInfo)
 {
     _connectionInfo = connectionInfo;
 }