+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Bulk Delete Users from Database

Bulk Delete Users from Database

5 posts, 0 answered
  1. Laura
    Laura avatar
    311 posts
    Registered:
    25 Feb 2008
    12 Oct 2010
    Link to this post
    On our site the users log in to a single sign on and we enter them into Sitefinty with their role as a user so they may access the member information.  The problem is that if they do not specifically click the Log Out link (no one ever really does, they just close browser), they remain a user in the database.   With hundreds logging in per day, this can grow quite large. Would you be able to provide me with a SQL script that we could run periodically that would delete these users automatically from the database?   Thank you.
    Version - Sitefinity 3.7.2022.2:1
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    12 Oct 2010
    Link to this post
    Hi Laura,

    Here is a list with the tables that you need to query to remove a user from Sitefinity

    [telerik_UsersInRoles]
    [telerik_Users]
    [telerik_UserMetaInfo]
    [telerik_Profile]

    In all tables you can identify the user by UserID

    Here is a basic query

    DELETE FROM [telerik_Profile]
    where UserId='62DD728E-AC7C-4B62-ABB9-079FFB2601E8'
     
    DELETE FROM [telerik_UsersInRoles]
    where UserId='62DD728E-AC7C-4B62-ABB9-079FFB2601E8'
     
    DELETE FROM [telerik_UsersInRoles]
    where UserId='62DD728E-AC7C-4B62-ABB9-079FFB2601E8'
     
    DELETE FROM [telerik_Users]
    where UserId='62DD728E-AC7C-4B62-ABB9-079FFB2601E8'


    All the best,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Laura
    Laura avatar
    311 posts
    Registered:
    25 Feb 2008
    12 Oct 2010
    Link to this post
    and I suppose I could just run this instead of by GUID but say for users in a certain role created more than 24hours ago or something like that?  Because right now we have over 39,000 to delete and we will probably run this every few days with a few hundred entries in a day.  The reason I want to delete users is because of the growing size, it becomes long and cumbersome to navigate aound in the users section in the Admin. For instance, the sorting just doesn't work after some point.
  4. Roopesh
    Roopesh avatar
    39 posts
    Registered:
    29 Oct 2010
    05 Nov 2010
    Link to this post
    Hello Sir,

    I want to delete all the Templates from my database (Not from sitefinity admin). I got some conflicts in the template data. I want to remove all templates and create it again. Can you provide me the query for that
    Thank You 
    Roops
  5. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    05 Nov 2010
    Link to this post
    Hi Roopesh,

    You should better use DeleteTemplate(Guid templateId) and DeleteTemplate(IPageTemplate template)
    methods of CmsManager class instead of working with the database. Note that this will deprecate all pages that are assigned to the templates you are going to delete.


    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Register for webinar
5 posts, 0 answered