public override void CreateRole(string rolename)
        {
            if (rolename.Contains(","))
            {
                throw new ArgumentException("Role names cannot contain commas.");
            }

            if (RoleExists(rolename))
            {
                throw new ProviderException("Role name already exists.");
            }

            _helper.ExecuteOdbcQuery("CALL `create_role` ('" + MySqlHelper.DoubleQuoteString(rolename) + "');");
        }
Beispiel #2
0
        public override bool ChangePassword(string username, string oldPwd, string newPwd)
        {
            if (!ValidateUser(username, oldPwd))
            {
                return(false);
            }

            var args = new ValidatePasswordEventArgs(username, newPwd, true);

            OnValidatingPassword(args);

            if (args.Cancel)
            {
                if (args.FailureInformation != null)
                {
                    throw args.FailureInformation;
                }
                else
                {
                    throw new MembershipPasswordException("Change password canceled due to new password validation failure.");
                }
            }

            var parameters = new[] {
                new MySqlParameter("?psw", EncodePassword(newPwd)),
                new MySqlParameter("?username", username)
            };

            return(_helper.ExecuteOdbcQuery("UPDATE `Users` SET `password` = ?psw, `lastPasswordChangedDate` = NOW() WHERE `userName` = ?username", parameters) > 0);
        }