Exemplo n.º 1
0
 public void SqlCredentialsValidator_ValidUserExceptionMessage()
 {
     try
     {
         SqlCredentialsValidator.ValidateCredentials("(local)", "", "", true, UserMessage);
         Assert.Fail();
     }
     catch (Exception exception)
     {
         Assert.AreEqual(UserMessage, exception.Message);
     }
 }
Exemplo n.º 2
0
 public void SqlCredentialsValidator_CheckNullCredentials()
 {
     try
     {
         SqlCredentialsValidator.ValidateCredentials(null, null, null, false, null);
         Assert.Fail();
     }
     catch (Exception exception)
     {
         Assert.IsNotNull(exception);
     }
 }
Exemplo n.º 3
0
        public ClassicUser FindUserWithCredentials(string username, string password)
        {
            using (var vsiSystem = new VSI_SYSTEMContext())
            {
                // Get the connection string from the DbContext
                var connectionString = new SqlConnectionStringBuilder(vsiSystem.Database.Connection.ConnectionString);

                // Validate the Credentials against the Host.
                SqlCredentialsValidator.ValidateCredentials(connectionString.DataSource, username, password, true);

                // Find and Project the User_ID into a ClassicUser object.
                var user = new User_ID_Repository(vsiSystem).Users.Where(x => x.User_ID1.Equals(username, StringComparison.OrdinalIgnoreCase))
                           .Select(ClassicUserProjection)
                           .FirstOrDefault();
                if (user == null)
                {
                    throw new InvalidCredentialException("The login is not associated with a valid User.  Please contact your system administrator.");
                }

                // Return the User
                return(user);
            }
        }
Exemplo n.º 4
0
        public void SqlCredentialsValidator_ValidateCredentials()
        {
            var isValidCredential = SqlCredentialsValidator.ValidateCredentials("172.16.50.151", "SA", "hurricane", true, null);

            Assert.IsFalse(isValidCredential);
        }