Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Create users - import file

    Captive Portal
    7
    8
    8.6k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T
      trcorreia
      last edited by

      Hi

      I installed the pfsense in school and use the Cp for users to log into, but I'm having a problem. I have 500 students to enroll  :o . I wonder if there is the possibility of importing a file with the username, password and name to be simpler.

      thanks

      1 Reply Last reply Reply Quote 0
      • B
        blak111
        last edited by

        If you already have all of those accounts entered into another system like active directory, you could just use the radius authentication option and the radius server built into windows server so you don't have to make another set of accounts to manage.

        1 Reply Last reply Reply Quote 0
        • T
          thecrazyspy
          last edited by

          I also seeks I do that but just with a list excel for some users.

          1 Reply Last reply Reply Quote 0
          • GruensFroeschliG
            GruensFroeschli
            last edited by

            Create a test user and download the config.xml.
            Now you should have an example of how a user-entry looks like.

            We do what we must, because we can.

            Asking questions the smart way: http://www.catb.org/esr/faqs/smart-questions.html

            1 Reply Last reply Reply Quote 0
            • R
              rav
              last edited by

              @GruensFroeschli:

              Create a test user and download the config.xml.
              Now you should have an example of how a user-entry looks like.

              I habe de same problem and where can i dowload the fie config.xml
              thank you

              1 Reply Last reply Reply Quote 0
              • GruensFroeschliG
                GruensFroeschli
                last edited by

                Diagnostic –> Backup/Restore

                We do what we must, because we can.

                Asking questions the smart way: http://www.catb.org/esr/faqs/smart-questions.html

                1 Reply Last reply Reply Quote 0
                • E
                  evewes
                  last edited by

                  @rav:

                  @GruensFroeschli:

                  Create a test user and download the config.xml.
                  Now you should have an example of how a user-entry looks like.

                  I habe de same problem and where can i dowload the fie config.xml
                  thank you

                  Did it work for you? I shall test download the config and upload a new one completed with 500 user and password.

                  1 Reply Last reply Reply Quote 0
                  • O
                    OldNick
                    last edited by

                    If you want to import into freeradius from a file you could try something along these lines.

                    `$file_handle = fopen("users.csv", "r");
                    while (!feof($file_handle) ) {
                            $line_of_text = fgets($file_handle);
                            $sStream .= $line_of_text;
                    }

                    fclose($file_handle);
                    $arUsers = explode("\n", $sStream);
                    $sUserCount = count($arUsers)-1 ;

                    for ($i = 0;$i< $sUserCount; $i++){
                         $sTmp = $arUsers[$i];
                         $arAcct = explode(",",$sTmp);
                         if (  AddXML(false,$arAcct) ) AddDbUser ($arAcct);
                         if ( $i > $sUserCount ) break;
                    }

                    function AddDBUser($fDebug,$arAcct){

                    include "opendb.php";
                         $SQL = "INSERT INTO radcheck (UserName, Attribute, op, Value) VALUES ('$arAcct[0]', 'User-Password', ':=', '$arrAcct[0]');";
                         $QResult = mysql_query($SQL);
                         include "closedb.php";
                    }`

                    users.csv is simply a list of username password pairs eg fred, apples\n tom, oranges

                    opendb.php and closedb.php are included pages to handle the connection to the radius db

                    Obviously thats ver simple only using the usename passwrod pair, it would be no hassle at all to extend it to add additional radius attributes

                    Its a bit rough and ready and probably has some errors as I just jotted it down from memory of past stuff I've done. I do hope it helps some one

                    Regards

                    Nick

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post
                    Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.