Beispiel #1
0
        /// <summary>
        /// Gets the user management configuration.
        /// </summary>
        /// <returns></returns>
        public UserManagementConfiguration GetUserManagementConfiguration()
        {
            using (var sqlConnection = GetOpenedSqlConnection()) {
                using (SqlCommand sqlCommand = new SqlCommand(GetUserManagementConfig, sqlConnection)) {
                    sqlCommand.CommandType = CommandType.StoredProcedure;

                    UserManagementConfiguration configuration = new UserManagementConfiguration();

                    var sqlDataReader = sqlCommand.ExecuteReader();
                    while (sqlDataReader.Read())
                    {
                        try {
                            string key   = sqlDataReader.GetString(0);
                            object value = sqlDataReader.GetValue(1);
                            if (key != null && !(value is DBNull))
                            {
                                AssignUserManagementConfigProperties(configuration, key, value);
                            }
                        } catch (InvalidCastException ex) {
                            //TODO: log error
                        }
                    }

                    return(configuration);
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Assigns the user management configuration properties.
        /// </summary>
        /// <param name="configuration">The configuration.</param>
        /// <param name="propertyName">Name of the property.</param>
        /// <param name="propertyValue">The property value.</param>
        private void AssignUserManagementConfigProperties(UserManagementConfiguration configuration, String propertyName, Object propertyValue)
        {
            switch (propertyName.ToUpperInvariant())
            {
            case LoginvalidationstringForWeb:
                configuration.LoginValidationStringForWeb = (String)propertyValue;
                break;

            case NumOfInvalidPasswordAttempts:
                configuration.NumOfInvalidPasswordAttempts = Convert.ToInt32(propertyValue);
                break;

            case InvalidPasswordAttemptsPeriodSeconds:
                configuration.InvalidPasswordAttemptsPeriodSeconds = Convert.ToInt32(propertyValue);
                break;

            case InvalidPasswordBlockSeconds:
                configuration.InvalidPasswordBlockSeconds = Convert.ToInt32(propertyValue);
                break;

            case PasswordValidity:
                configuration.PasswordValidity = (string)propertyValue;
                break;

            case LoginValidity:
                configuration.LoginValidity = (string)propertyValue;
                break;

            case UnderwriterLogin:
                configuration.Underwriters.Add((string)propertyValue);
                break;

            default:
                //TODO: log unexpected property
                break;
            }
        }
 public UserManagementController(IMcmRepository mcmRepository, UserManagementConfiguration configuration)
 {
     McmRepository = mcmRepository;
     Configuration = configuration;
 }