コード例 #1
0
        public override bool DeleteUser(string userName, bool deleteAllRelatedData)
        {
            /*
             * 	Takes, as input, a user name and deletes that user from the membership data source. DeleteUser returns
             * true if the user was successfully deleted. Otherwise, it returns false. DeleteUser takes a third parameter-a Boolean
             * named deleteAllRelatedData-that specifies whether related data for that user should be deleted also.
             * If deleteAllRelatedData is true, DeleteUser should delete role data, profile data, and all other data associated
             * with that user.
             */
            bool result = false;
            SiteSettings siteSettings = GetSiteSettings();
            // we are ignoring deleteAllRelatedData
            // on purpose because whether to really delete or just flag as deleted
            // is determined by the siteSettings.ReallyDeleteUsers setting

            if ((userName != null) && (siteSettings != null))
            {
                SiteUser siteUser = new SiteUser(siteSettings, userName);
                if (siteUser.UserId > -1)
                {
                    result = siteUser.DeleteUser();

                }
            }

            return result;
        }