public string TestPasswordPolicy(string password)
        {
            var passwordException = new PasswordPolicyException(string.Empty);
            var policy = new PWDTK.PasswordPolicy(NumberUpper, NumberNonAlphaNumeric, NumberNumeric, MinPasswordLength, MaxPasswordLength);
            if (PWDTK.TryPasswordPolicyCompliance(password, policy, ref passwordException))
            {
                return string.Empty;
            }

            return passwordException.Message;
        }
Example #2
0
        private bool PasswordMeetsPolicy(String Password, PWDTK.PasswordPolicy PassPolicy)
        {
            PasswordPolicyException pwdEx = new PasswordPolicyException("");

            if (PWDTK.TryPasswordPolicyCompliance(Password, PassPolicy, ref pwdEx))
            {
                return true;
            }
            else
            {
                //Password does not comply with PasswordPolicy so we get the error message from the PasswordPolicyException to display to the user
                errorPasswd.SetError(txtPassword, pwdEx.Message);
                return false;
            }
        }
Example #3
0
        /// <summary>
        /// Tests the password for compliance against the supplied password policy
        /// </summary>
        /// <param name="password">The password to test for compliance</param>
        /// <param name="pwdPolicy">The PasswordPolicy that we are testing that the Password complies with</param>
        /// <param name="pwdPolicyException">The exception that will contain why the Password does not meet the PasswordPolicy</param>
        /// <returns>True for Password Compliance with the Policy</returns>
        public static Boolean TryPasswordPolicyCompliance(String password, PasswordPolicy pwdPolicy, ref PasswordPolicyException pwdPolicyException)
        {
            try
            {
                PCheckPasswordPolicyCompliance(password, pwdPolicy);
                return true;
            }
            catch(PasswordPolicyException ex)
            {
                pwdPolicyException = ex;
            }

            return false;
        }
Example #4
0
        /// <summary>
        /// Tests the password for compliance against the supplied password policy
        /// </summary>
        /// <param name="password">The password to test for compliance</param>
        /// <param name="pwdPolicy">The PasswordPolicy that we are testing that the Password complies with</param>
        /// <param name="pwdPolicyException">The exception that will contain why the Password does not meet the PasswordPolicy</param>
        /// <returns>True for Password Compliance with the Policy</returns>
        public static Boolean TryPasswordPolicyCompliance(String password, PasswordPolicy pwdPolicy, ref PasswordPolicyException pwdPolicyException)
        {
            try
            {
                PCheckPasswordPolicyCompliance(password, pwdPolicy);
                return(true);
            }
            catch (PasswordPolicyException ex)
            {
                pwdPolicyException = ex;
            }

            return(false);
        }