Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
technical:api-permanent-users [2025/04/12 21:46] – created systemtechnical:api-permanent-users [2025/04/13 05:23] (current) system
Line 6: Line 6:
 ----- -----
  
-====== Realms ====== +====== Permanent Users ====== 
-  * Each **Permanent User**, **Voucher** or **BYOD Device** has to belong to a **Profile** and **Realm** in order to be useful to RADIUS. +  * **Permanent User** has to belong to a **Profile** and **Realm** in order to be useful to RADIUS. 
-  * Before we can bulk import Permanent Users using CSV file, we need to ensure that all the realms that the users belong to in the CSV file already exist+  * In the previous Wiki Pages we already covered adding Profile and a Realm
-  * In this page we will show you how to add a Realm to a  Cloud in RADIUSdesk using an API call.+  * In this page we will show you how to add a Permanent User to a  Cloud in RADIUSdesk using an API call.
   * We will use PHP but the principles can be applied using any programming language.   * We will use PHP but the principles can be applied using any programming language.
  
 ----------------- -----------------
  
-====== Add a Realm using the API ======+====== Add a Permanent User using the API ======
  
-  * Below is a simple as possible script that can be used as reference when adding a Realm using the API.+  * Below is a simple as possible script that can be used as reference when adding a Permanent User using the API.
   * We also show the optional fields that can be included in the API call.   * We also show the optional fields that can be included in the API call.
 <file php add_permanent_users.php> <file php add_permanent_users.php>
Line 22: Line 22:
    
     // Configuration     // Configuration
-    $api_url    = 'http://127.0.0.1/cake4/rd_cake/realms/add.json';+    $api_url    = 'http://127.0.0.1/cake4/rd_cake/permanent-users/add.json';
     $token      = 'b4c6ac81-8c7c-4802-b50a-0a6380555b50';     $token      = 'b4c6ac81-8c7c-4802-b50a-0a6380555b50';
     $cloud_id   = 23; // replace with the Cloud ID that you want to work on.     $cloud_id   = 23; // replace with the Cloud ID that you want to work on.
-    $name       = 'Dev';+    $username   = 'testuser'; 
 +    $password   = 'testing123'; 
 +    $realm      = 'Dev'; 
 +    $profile    = 'MzanziFibre-12/1';
    
     // Set API payload     // Set API payload
Line 31: Line 34:
          
         //Required Fields              //Required Fields     
-        'name     => $name,+        'username => $username, 
 +        'password'  => $password, 
 +        'realm'     => $realm, 
 +        'profile'   => $profile,
         'cloud_id'  => $cloud_id,         'cloud_id'  => $cloud_id,
         'token'     => $token,         'token'     => $token,
-                   +        'active'    => 'active', //active flag must be set for user to authenticate       
 +                 
        /               /       
-       //Optional Fields        +       //Optional Fields   
-        'phone    => '', +        'name         => '', 
-        'fax      => '', +        'surname      => '',      
-        'cell     => '', +        'phone        => '', 
-        'email'     => '', +        'email'         => '', 
-        'url      => '', +        'address      => '', 
-        'street_no' => '', +        'from_date    => '04/12/2025', 
-        'street   => '', +        'to_date      => ''04/12/2026', 
-        'town_suburb  => ''+        'realm_id'     => 19//Alternative to Realm's name 
-        'city     => ''+        'profile_id   => 49//Alternative to Profile's name 
-        'country  => '', +        'static_ip    => '192.168.1.100
-        'lon      => 0, +        'extra_name   => '', 
-        'lat      => 0+        'extra_value  => '', 
-        'suffix   => 'example.com',             +        'site         => '', 
-        //Flags (exclude if it should not be set) +        'ppsk         => '', 
-        'suffix_permanent_users   => 'suffix_permanent_users', +        'auto_add     => 'auto_add//flag to automatically add the MAC Address the user connects with as a Device (BYOD) belonging to him
-        'suffix_vouchers          => 'suffix_vouchers', +
-        'suffix_devices           => 'suffix_devices',+
         */         */
     ];     ];
Line 66: Line 71:
     $response = curl_exec($ch);     $response = curl_exec($ch);
     curl_close($ch);     curl_close($ch);
-    echo "Added $name: $response\n";+    echo "Added $username: $response\n";
    
 ?> ?>
 </file> </file>
-  * Now that we have created Profiles and Realms, we can move on to adding a Permanent User.+  * Now that we have created a Permanent User, we will cover some common actions that can be done on the Permanent User via the API.
  
  
  • technical/api-permanent-users.1744487212.txt.gz
  • Last modified: 2025/04/12 21:46
  • by system