Пример #1
0
        static bool VerifierCorrespondancePasword(CsUtilisateur pUser, string pPassword)
        {
            string _password;

            _password = Cryptage.Encrypt(pPassword);

            return(_password == pUser.PASSE);
        }
Пример #2
0
        static bool VerifierCorrespondancePasword(CsUtilisateur pUser, string pPassword, bool tobeUpdate)
        {
            string _password;

            _password = Cryptage.Encrypt(pPassword);
            bool _match = (_password == pUser.PASSE);

            if (tobeUpdate)
            {
                pUser.DATEDERNIERECONNEXION    = DateTime.Now;
                pUser.DERNIERECONNEXIONREUSSIE = _match;
                return((bool)pUser.DERNIERECONNEXIONREUSSIE);
            }
            else
            {
                return(_match);
            }
        }
Пример #3
0
        /// <summary>
        /// procedure de changement de password par l'utilisateur lui-même
        /// </summary>
        /// <param name="admUser"></param>
        /// <param name="oldPassword"></param>
        /// <param name="newPassword"></param>
        /// <param name="confirmPassword"></param>
        public static bool ChangePassword(CsUtilisateur pUser, CsStrategieSecurite pSecurity, string oldPassword, string newPassword, string confirmPassword, bool TenirCompteAncienPwd)
        {
            //Verifier si le changement de mot de passe peut se faire par rapport à la stratégie
            //Durée Minimale Password
            if (pUser.INITUSERPASSWORD != null && !(bool)pUser.INITUSERPASSWORD && pSecurity.DUREEMINIMALEPASSWORD != 0)
            {
                if (pUser.DATEDERNIEREMODIFICATIONPASSWORD != null && ((DateTime)pUser.DATEDERNIEREMODIFICATIONPASSWORD).AddDays(Convert.ToDouble(pSecurity.DUREEMINIMALEPASSWORD)) > DateTime.Now)
                {
                    throw new Exception(Langue.MsgModPwd);
                }
            }

            if (TenirCompteAncienPwd)
            {
                if (pUser.PASSE != Cryptage.Encrypt(oldPassword)) //EncryptWithOutKey(oldPassword)
                {
                    throw new Exception(Langue.MsgErrAncPwd);
                }
            }

            if (newPassword != confirmPassword)
            {
                throw new Exception(Langue.MsgErrConfPwd);
            }



            if (pSecurity.NEPASCONTENIRNOMCOMPTE)
            {
                if (newPassword.ToLower().Contains(pUser.LOGINNAME.ToLower()))
                {
                    throw new Exception(Langue.MsgPwdCpt);
                }
            }

            pUser.PASSE            = Cryptage.GetPasswordToBeSaved(pSecurity, pUser.LIBELLE, newPassword);
            pUser.INITUSERPASSWORD = false;
            pUser.DATEDERNIEREMODIFICATIONPASSWORD = DateTime.Now;
            //new DBAdmUsers().Update(admUser);
            return(true);
        }