Menu

Bulk Import of Users

Help
nikonaum
2014-01-26
2020-01-15
  • nikonaum

    nikonaum - 2014-01-26

    There was a bulk inport procedure/script in Yfi MAnager but not such a thing in RadiusDesk, or atleast I can't find any tutorial on that. So, can someone point me to a way to import users into the system. I need "username" with "password" added to a "plan/profile"

     
  • Dirk van der Walt

    Hi,

    Have a look at this write-up:

    http://www.radiusdesk.com/developers_corner/api

    If you know a bit of PHP it should get you going, but if you get stuck; let us know where you battle.

    Kind regards

     
    • nikonaum

      nikonaum - 2014-01-27

      Thanks again for your kind reply. Lot's of activity in the forum today, I was losing hope, but we are(the forum) alive :). I can read php code, but I'm not a developoer for sure. I'll look at it, but basicly I want to know the short way -- some SQL command or json import script as in Yfi Manager is the right way to go. I want to import som 10000 users(students) to the system, just username, password and attach to them a plan/profile.

       
    • dny nur

      dny nur - 2017-05-31

      Hi Dirk, I can't open the link. It says "This topic does not exist yet". I need to import around 300 users, your help is appreciated.

       
  • nikonaum

    nikonaum - 2014-01-30

    I need some hint how to use this PHP file/api. Where should I run this php file from? How to serve my usernames to this file? Where to past it, should I run It from bash or invoke It from a browser? Let's hope I'm not too pushy but I need this for my migration from Yfi to RADIUSdesk, if I can't import my users all at once, I'm stuck to the old Yfi Manager. Thanks!

     
  • Dirk van der Walt

    Hi,

    By when is the latest that you want this? I can slap together something that will read username and password combinations from file.

    Regards

     
  • nikonaum

    nikonaum - 2014-01-30

    I'm hoping to format my CentOS server with Yfi and put RADIUSdesk onto it and import all the students and flash all my NanoStation M2 AP (about 15) this weekend and introduce RADIUSdesk on monday. But It's not by no means critical, I have time.
    I tested running the php from a browser with just one user defined to the variables and it is working fine.
    By the way -- Greetings from Bulgaria and want to thank you for the perfect job You have done, both with Yfi and RADIUSdesk.
    Regards
    Nikolay Naumov

     
  • Dirk van der Walt

    Hi Nikolay

    Rather late than never. The latest SVN has a Shell script which you can use. (You will run this from a terminal)

    • By default it will look for a file /tmp/users.csv which should contain comma separated list of username and password combinations.
    • You will then also have to select the owner, realm and profile before it will start adding them.
    • It is important to run this script as user www-data.

      sudo su
      su www-data
      
    • Then also check where the Shell script is situated. If you run Nginx the path has to change (usr/share/nginx/www instead of /var/www).

    • The following is the output from my dev machine running Apache:

      $ /var/www/cake2/rd_cake/Console/cake -app /var/www/cake2/rd_cake bulkPermanentUser
      PHP Deprecated:  Comments starting with '#' are deprecated in /etc/php5/cli/conf.d/mcrypt.ini on line 1 in Unknown on line 0
      
      Welcome to CakePHP v2.2.3 Console
      ---------------------------------------------------------------
      App : rd_cake
      Path: /var/www/cake2/rd_cake/
      ---------------------------------------------------------------
      ======================================
      ===Bulk import of permanent users ====
      ======================================
      Specify the CSV file with list of users  
      [/tmp/users.csv] > 
      Select the creator of the permanent users (root/admin_college/admin_freddy) 
      [root] > 
      Select the profile these users must belong to (Data-Standard-250/Data-Standard-500/Data-Standard-1G/Time-Standard-1Hour) 
      [Time-Standard-1Hour] > 
      Select the realm these users must belong to (Residence Inn/College/realm_freddy) 
      [realm_freddy] >
      

    Let us know if you have problems or if something is unclear to you.

    Cheers

     
    • Victor Ors

      Victor Ors - 2016-11-23

      I received this error:
      Failed to connect to 127.0.0.1 port 80: Connection refused

      Freeradius running and Nginx with Radiusdesk too


      Solve: Sorry , nginx was listening on other port. Works perfectly.
      Thanks.

       

      Last edit: Victor Ors 2016-11-23
  • Dirk van der Walt

    PS here's a snippet of the users.csv file

        john,john
        peter,peter
        paul,paul
    
     
  • nikonaum

    nikonaum - 2014-02-02

    Works like a charm with small number of users. I'll make some modifications to the php script, just to put "name" an "surname" in csv file and change the "cap" to "hard", and on Monday I'll test the script with 14000 users.
    One question I have to ask, I want to do tracking so I want "RADIUS authentication" and "RADIUS accounting" checked in RD. So, What are the permitted values of "*track_acct" variable in the API for adding users (I believe this is for "RADIUS accounting" tracking) and is there a variable for "RADIUS authentication"?

     
  • nikonaum

    nikonaum - 2014-02-02

    Just find out that the creation of the user is ok, but no radius respond for the user. When I test It via RADIUS client in RD I get the following:

    Request Attributes
    User-Name = nikonaum1
    User-Password = parola1

    Reply Attributes is in red and nothing shows under It.

     
  • nikonaum

    nikonaum - 2014-02-02

    After some debugging error tracing, I found out that the "password" is INCORRECT. When I open the "radcheck" table I can see that the column with the value of the password is ill formatted. It's slightly bigger than the other password fields which were created in web interface, I think the script puts some kind of TAB or Newline special character in the column. When I change the password of the user via the web interface tool called "Password Manager" and just type it the same and press SAVE everything is fine and the "select * from radcheck" shows all the password columns with the same (right) width.

     
  • nikonaum

    nikonaum - 2014-02-02

    +------+-----------+--------------------+----+---------+
    | id | username | attribute | op | value |
    +------+-----------+--------------------+----+---------+
    | 8481 | dvdwalt | Cleartext-Password | := | dvdwalt |
    | 8573 | rviljoen | Cleartext-Password | := | koos |
    | 8588 | 000001 | Cleartext-Password | := | bN3 |
    | 8597 | 000002 | Cleartext-Password | := | wxs |
    | 8601 | 000003 | Cleartext-Password | := | GzD |
    | 8605 | 000004 | Cleartext-Password | := | f57 |
    | 8609 | 000005 | Cleartext-Password | := | jf3 |
    | 8613 | 000006 | Cleartext-Password | := | Hp0 |
    | 8617 | 000007 | Cleartext-Password | := | Tx7 |
    | 8621 | 000008 | Cleartext-Password | := | j9T |
    | 8625 | 000009 | Cleartext-Password | := | vJ3 |
    | 8629 | 000010 | Cleartext-Password | := | 16k |
    | 8633 | 000011 | Cleartext-Password | := | PFs |
    | 8637 | 000012 | Cleartext-Password | := | hwP |
    | 8641 | 000013 | Cleartext-Password | := | 61N |
    | 8651 | 000014 | Cleartext-Password | := | gonow |
    | 8652 | koos | Cleartext-Password | := | koos |
    | 8667 | 000015 | Cleartext-Password | := | z3s |
    | 8672 | user1 | Cleartext-Password | := | user1 |
    | 8685 | user2 | Cleartext-Password | := | user2 |
    | 8738 | nikonaum | Cleartext-Password | := | parola |
    | 8784 | nikonaum1 | Cleartext-Password | := | parola1 |
    | 8785 | naum40 | Cleartext-Password | := | naum40
    |
    | 8793 | niko1 | Cleartext-Password | := | niko1
    |
    | 8801 | niko5 | Cleartext-Password | := | niko5
    |
    | 8809 | niko6 | Cleartext-Password | := | niko6
    |

    The last 4 records are those imported by the script and not working due to: [pap] Passwords don't match message in radiusd

     
  • nikonaum

    nikonaum - 2014-02-02

    [FIX]
    I've managed to fix the problem by changing the function on line 76 in the of the file BulkPermanentUserShell.php.
    I replaced the line that says:
    $items = explode(',',$i);
    with this one:
    $items = preg_split ('/[,\s]+/', $i);

    and then from terminal I run the command:

    su -s /bin/sh apache -c "/var/www/html/cake2/rd_cake/Console/cake -app /var/www/html/cake2/rd_cake bulkPermanentUser"

    [Offtopic] P.S. Sorry for my bad text formatting in this forum, but I can't understand how to use Formatting Help button

     
    • dny nur

      dny nur - 2017-05-31

      Hi nikonaum,

      Where can I download this BulkPermanentUserShell.php script? And all script that needed to do bulk import users to Radius Desk?

       
  • nikonaum

    nikonaum - 2017-05-31

    Sorry for late reply, U dont't need to download It, It's in the RADIUSdesk, you just need to edit It to suit your needs. The location of the file is in: /your_web_document_root/cake2/rd_cake/Console/Command/BulkPermanentUserShell.php
    And then from the server cli you shoul run the following command to run tha import:
    su -s /bin/sh apache -c "/var/www/html/cake2/rd_cake/Console/cake -app /var/www/html/cake2/rd_cake bulkPermanentUser"

    Note: I'm on a CentoOS 6.7 and apache web server, and I'm a bit off dated ;-) using cake2. Take a look at your BulkPermanentUserShell.php and edit accordingly.

     
    • dny nur

      dny nur - 2017-06-09

      Hi nikonaum,

      Thanks for the clear explanation. I managed to import some testing users using BulkPermanentUserShell.php, and as you said, I need to edit line 76 to make the authentication works.

      Also we have another requirement, we have around 500 users and each user have different expiration date. How if we want to import all 500 users using csv file that contains also expiration date?

      Your help is highly appreciated.

      Thank You.

       
  • Fabrizio Lazzaretti

    hi dny!
    just add these 2 parameters to the post data:
    from_date, to_date.
    from_date can be a static string. to_date needs to be acquired from csv, so add an item in the parsing section.

    Regards

     
  • Bong Lovert

    Bong Lovert - 2018-02-09

    hi, just wish to know the root password for radiusdesk when in the shell i.e when you need to change from and ordinary user to a root user. thanks in advance

     
  • Md. Abu Noman

    Md. Abu Noman - 2020-01-15

    @dvdwalt, I have deployed radiusdesk in Ubuntu 18.04. I can't import bulk user from CSV, it gives the following error. Can you please give me some hint to solve the issue. Thanks in advance.

    Error: [Cake\Controller\Exception\MissingActionException] Action VouchersController::addCsv() could not be found, or is not accessible.
    Exception Attributes: array (
      'controller' => 'VouchersController',
      'action' => 'addCsv',
      'prefix' => '',
      'plugin' => false,
    )
    
     

    Last edit: Md. Abu Noman 2020-01-18

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.