Forums

Resolved
0 votes
Hi!

Is it possible to mass delete user accounts? I have 1000 users, and now I need to remove 700 of them.

Thank's for help!
Sunday, August 29 2010, 06:55 PM
Share this post:
Responses (4)
  • Accepted Answer

    Tuesday, April 09 2019, 11:59 AM - #Permalink
    Resolved
    1 votes
    Hello Michael,
    In v7 there is a handy command line utility:
    /usr/sbin/clearos_user -h
    Like
    1
    The reply is currently minimized Show
  • Accepted Answer

    Monday, August 30 2010, 05:07 PM - #Permalink
    Resolved
    0 votes
    Hi Piotr.

    Here's an example script that will delete the "test5" user. Please excuse the "GroupManager" line -- it shouldn't be necessary but there is a missing library dependency.


    #!/usr/webconfig/bin/php
    <?php

    require_once("/var/webconfig/api/GroupManager.class.php");
    require_once("/var/webconfig/api/User.class.php");

    $user = new User("test5");
    $user->Delete();

    ?>
    The reply is currently minimized Show
  • Accepted Answer

    Tuesday, April 09 2019, 06:54 AM - #Permalink
    Resolved
    0 votes
    Hi!
    I'm in a similar position to delete hundreds of users, provided by a textfile with one username per line. The above script isn't working anymore since locations and file/function names changed a lot since 2010. Could you provide me some help please which libraries to load to use the delete() function and also check check script if it's error-free (I'm no programmer, just adapting existing scripts on the fly.)?


    #!/usr/bin/php
    <?php

    require_once("/var/webconfig/api/GroupManager.class.php");
    require_once("/var/webconfig/api/User.class.php");

    $file = '/root/usernamen.txt';

    $file_handle = fopen($file, 'r');

    while (!feof($file_handle)) {

    $line = fgets($file_handle);
    $user = new User("$line");
    $user->Delete();

    fclose($file_handle);

    }

    ?>


    Thank you!
    Michael
    The reply is currently minimized Show
  • Accepted Answer

    Tuesday, April 09 2019, 12:12 PM - #Permalink
    Resolved
    0 votes
    Nick Howitt wrote:

    Hello Michael,
    In v7 there is a handy command line utility:
    /usr/sbin/clearos_user -h


    As always: It's absolutely helpful here!
    Thx a bunch!
    Michael
    The reply is currently minimized Show
Your Reply