Exemplo n.º 1
0
        /// <summary>
        /// Updates a providers user information
        /// </summary>
        /// <param name="user">MembershipUser object</param>
        public override void UpdateUser(MembershipUser user)
        {
            // Check User object is not null
            if (user == null)
            {
                ExceptionReporter.ThrowArgumentNull("MEMBERSHIP", "MEMBERSHIPUSERNULL");
            }

            // Update User
            int updateStatus = DB.UpdateUser(this.ApplicationName, user, this.RequiresUniqueEmail);

            // Check update was not successful
            if (updateStatus != 0)
            {
                // An error has occurred, determine which one.
                switch (updateStatus)
                {
                case 1: ExceptionReporter.Throw("MEMBERSHIP", "USERKEYNULL");
                    break;

                case 2: ExceptionReporter.Throw("MEMBERSHIP", "DUPLICATEEMAIL");
                    break;
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Retrieves a MembershipUser object from the criteria given
        /// </summary>
        /// <param name="providerUserKey">User to be found based on UserKey</param>
        /// <param name="userIsOnline">Is the User currently online</param>
        /// <returns>MembershipUser object</returns>
        public override MembershipUser GetUser(object providerUserKey, bool userIsOnline)
        {
            if (providerUserKey == null)
            {
                ExceptionReporter.ThrowArgumentNull("MEMBERSHIP", "USERKEYNULL");
            }

            DataRow dr = DB.GetUser(this.ApplicationName, providerUserKey, null, userIsOnline);

            if (dr != null)
            {
                return(new MembershipUser(Utils.Transform.ToString(this.Name), Utils.Transform.ToString(dr ["Username"]), Utils.Transform.ToString(dr ["UserID"]), Utils.Transform.ToString(dr ["Email"]), Utils.Transform.ToString(dr ["PasswordQuestion"]), Utils.Transform.ToString(dr ["Comment"]), Utils.Transform.ToBool(dr ["IsApproved"]), Utils.Transform.ToBool(dr ["IsLockedOut"]), Utils.Transform.ToDateTime(dr ["Joined"]), Utils.Transform.ToDateTime(dr ["LastLogin"]), Utils.Transform.ToDateTime(dr ["LastActivity"]), Utils.Transform.ToDateTime(dr ["LastPasswordChange"]), Utils.Transform.ToDateTime(dr ["LastLockout"])));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Unlocks a users account
        /// </summary>
        /// <param name="username">User to be found based by Name</param>
        /// <returns>True/False is users account has been unlocked</returns>
        public override bool UnlockUser(string userName)
        {
            // Check for null argument
            if (userName == null)
            {
                ExceptionReporter.ThrowArgumentNull("MEMBERSHIP", "USERNAMENULL");
            }

            try
            {
                DB.UnlockUser(this.ApplicationName, userName);
                return(true);
            }
            catch
            {
                // will return false below
            }

            return(false);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Delete User and User's information from provider
        /// </summary>
        /// <param name="username">Username to delete</param>
        /// <param name="deleteAllRelatedData">Delete all related daata</param>
        /// <returns> Boolean depending on whether the deletion was successful</returns>
        public override bool DeleteUser(string username, bool deleteAllRelatedData)
        {
            // Check username argument is not null
            if (username == null)
            {
                ExceptionReporter.ThrowArgumentNull("MEMBERSHIP", "USERNAMENULL");
            }

            // Process database user deletion request
            try
            {
                DB.DeleteUser(this.ApplicationName, username, deleteAllRelatedData);
                return(true);
            }
            catch
            {
                // will return false...
            }

            return(false);
        }
Exemplo n.º 5
0
        /// <summary>
        /// The delete profiles.
        /// </summary>
        /// <param name="profiles">
        /// The profiles.
        /// </param>
        /// <returns>
        /// The delete profiles.
        /// </returns>
        public override int DeleteProfiles(ProfileInfoCollection profiles)
        {
            if (profiles == null)
            {
                ExceptionReporter.ThrowArgumentNull("PROFILE", "PROFILESNULL");
            }

            if (profiles.Count < 1)
            {
                ExceptionReporter.ThrowArgument("PROFILE", "PROFILESEMPTY");
            }

            var usernames = new string[profiles.Count];

            int index = 0;

            foreach (ProfileInfo profile in profiles)
            {
                usernames[index++] = profile.UserName;
            }

            return(DeleteProfiles(usernames));
        }
Exemplo n.º 6
0
        /// <summary>
        /// Retrieves a MembershipUser object from the criteria given
        /// </summary>
        /// <param name="providerUserKey">User to be found based on UserKey</param>
        /// <param name="userIsOnline">Is the User currently online</param>
        /// <returns>Username as string</returns>
        public override string GetUserNameByEmail(string email)
        {
            if (email == null)
            {
                ExceptionReporter.ThrowArgumentNull("MEMBERSHIP", "EMAILNULL");
            }

            DataTable Users = DB.GetUserNameByEmail(this.ApplicationName, email);

            if (this.RequiresUniqueEmail && Users.Rows.Count > 1)
            {
                ExceptionReporter.ThrowProvider("MEMBERSHIP", "TOOMANYUSERNAMERETURNS");
            }

            if (Users.Rows.Count == 0)
            {
                return(null);
            }
            else
            {
                return(Users.Rows [0] ["Username"].ToString());
            }
        }