/// <summary>
        /// Adds a new membership user to the data source.
        /// </summary>
        /// <param name="username">The user name for the new user.</param>
        /// <param name="password">The password for the new user.</param>
        /// <param name="email">The e-mail address for the new user.</param>
        /// <param name="passwordQuestion">The password question for the new user.</param>
        /// <param name="passwordAnswer">The password answer for the new user</param>
        /// <param name="isApproved">Whether or not the new user is approved to be validated.</param>
        /// <param name="providerUserKey">The unique identifier from the membership data source for the user.</param>
        /// <param name="status">A <see cref="T:System.Web.Security.MembershipCreateStatus"/> enumeration value indicating whether the user was created successfully.</param>
        /// <returns>
        /// A <see cref="T:System.Web.Security.MembershipUser"/> object populated with the information for the newly created user.
        /// </returns>
        public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status)
        {
            try
            {
                // Create the new user
                CosmoMongerMembershipUser user = CosmoMongerMembershipUser.CreateUser(username, password, email);

                status = MembershipCreateStatus.Success;
                return(user);
            }
            catch (ArgumentException ex)
            {
                if (ex.ParamName == "username")
                {
                    status = MembershipCreateStatus.DuplicateUserName;
                }
                else if (ex.ParamName == "email")
                {
                    status = MembershipCreateStatus.DuplicateEmail;
                }
                else if (ex.ParamName == "password")
                {
                    status = MembershipCreateStatus.InvalidPassword;
                }
                else
                {
                    // We don't know how to handle this error
                    status = MembershipCreateStatus.ProviderError;
                }

                return(null);
            }
        }
        /// <summary>
        /// Clears a lock on a user so that the user can login.
        /// </summary>
        /// <param name="userName">The membership user whose lock status you want to clear.</param>
        /// <returns>
        /// true if the membership user was successfully unlocked; otherwise, false.
        /// </returns>
        public override bool UnlockUser(string userName)
        {
            CosmoMongerMembershipUser user = (CosmoMongerMembershipUser)this.GetUser(userName, false);

            if (user != null)
            {
                return(user.UnlockUser());
            }

            return(false);
        }
        /// <summary>
        /// Change the password for a user
        /// </summary>
        /// <param name="username">The user to update the password for.</param>
        /// <param name="oldPassword">The current password for the specified user.</param>
        /// <param name="newPassword">The new password for the specified user.</param>
        /// <returns>
        /// true if the password was updated successfully; otherwise, false.
        /// </returns>
        public override bool ChangePassword(string username, string oldPassword, string newPassword)
        {
            CosmoMongerMembershipUser user = (CosmoMongerMembershipUser)this.GetUser(username, true);

            if (user != null)
            {
                return(user.ChangePassword(oldPassword, newPassword));
            }

            return(false);
        }
        /// <summary>
        /// Verifies that the specified user name and password exist in the CosmoMonger database and that the user is active and validated.
        /// </summary>
        /// <param name="username">The name of the user to validate.</param>
        /// <param name="password">The password for the specified user.</param>
        /// <returns>
        /// true if the specified username and password are valid; otherwise, false.
        /// </returns>
        public override bool ValidateUser(string username, string password)
        {
            CosmoMongerMembershipUser user = (CosmoMongerMembershipUser)this.GetUser(username, true);

            if (user != null)
            {
                return(user.ValidatePassword(password) &&
                       user.IsApproved &&
                       !user.IsLockedOut);
            }

            return(false);
        }
        /// <summary>
        /// Resets a user's password to a new, automatically generated password.
        /// </summary>
        /// <param name="username">The user to reset the password for.</param>
        /// <param name="answer">The password answer for the specified user.</param>
        /// <returns>The new password for the specified user.</returns>
        public override string ResetPassword(string username, string answer)
        {
            CosmoMongerMembershipUser user = (CosmoMongerMembershipUser)this.GetUser(username, false);

            if (user != null && user.CheckResetPasswordCode(answer))
            {
                string newPassword = Membership.GeneratePassword(8, 0);
                if (user.ChangePassword(newPassword))
                {
                    return(newPassword);
                }
            }

            return(String.Empty);
        }