Create users - import file



  • 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



  • 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.



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



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



  • @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



  • Diagnostic –> Backup/Restore



  • @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.



  • 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


Log in to reply