Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
technical:api-pu-disable [2025/04/13 09:08] systemtechnical:api-pu-disable [2025/04/13 15:13] (current) system
Line 6: Line 6:
 ----- -----
  
-====== Permanent Users ====== +====== Enable and Disable Permanent Users ====== 
-  * A **Permanent User** has to belong to **Profile** and **Realm** in order to be useful to RADIUS+<alert type="warning"> 
-  * In the previous Wiki Pages we already covered adding Profile and a Realm+  * RADIUSdesk includes component called 'ISP-Plumbing' which needs to be configured first
-  * In this page we will show you how to add a Permanent User to a  Cloud in RADIUSdesk using an API call+  * When this component is configured, any active sessions for a user will be terminated upon the completion of the enable or disable action. 
-  * We will use PHP but the principles can be applied using any programming language. +  * This comes in handy to move user into or out of an isolation VLAN or network. 
- +</alert> 
------------------ +  * To enable or disable a Permanent User we have to first determine the id of the Permanent User
- +  * A CRM system typically do not know the id of the Permanent User in RADIUSdesk. 
-====== Add a Permanent User using the API ====== +  * With the sample script we use two APIs 
- +      * The one API is used get list of Permanent Users to collect their ids
-  * Below is a simple as possible script that can be used as reference when adding a Permanent User using the API+      The other API is used to either enable or disable the list of Permanent Users which was obtained.
-  We also show the optional fields that can be included in the API call.+
 <file php permanent_user_disable_enable.php> <file php permanent_user_disable_enable.php>
 <?php <?php
Line 28: Line 27:
          
     $username   = 'testuser@dev';     $username   = 'testuser@dev';
-    $action     = 'enable'; //Options 'enable' or 'disable'+    $action     = 'disable'; //Options 'enable' or 'disable'
          
     // Filter settings     // Filter settings
Line 35: Line 34:
     $value      = $username; //can also be set to boolean e.g. true or false to filter for instance on the 'active' field     $value      = $username; //can also be set to boolean e.g. true or false to filter for instance on the 'active' field
     $limit      = 1000;     $limit      = 1000;
-    +     
-    $find_url   = "$server/cake4/rd_cake/permanent-users/index.json?page=1&start=0&limit=$limit&filter=[{%22operator%22%3A%22$operator%22%2C%22value%22%3A%22".$value."%22%2C%22property%22%3A%22$filter%22}]&token=$token&cloud_id=$cloud_id";+    $filter_array = [ 
 +        [ 
 +            "operator" => $operator, 
 +            "value"    => $value, // this stays a boolean! 
 +            "property" => $filter 
 +        ] 
 +    ]; 
 + 
 +    $encoded_filter = urlencode(json_encode($filter_array)); 
 + 
 +    $find_url = "$server/cake4/rd_cake/permanent-users/index.json?page=1&start=0&limit=$limit&filter=$encoded_filter&token=$token&cloud_id=$cloud_id";
          
    
Line 69: Line 78:
      ]      ]
      ]);      ]);
 +     
 +     print($find_url);
  
      // Get the response      // Get the response
Line 87: Line 98:
                 $listOfIds[$id] = $id;                     $listOfIds[$id] = $id;    
             }             }
-            echo "There $count items!";+            echo "There $count items\n";
             return $listOfIds;             return $listOfIds;
         } else {         } else {
Line 94: Line 105:
      return false;      return false;
     }     }
- +     
 ?> ?>
 </file> </file>
-  * Now that we have created Permanent User, we will cover some common actions that can be done on the Permanent User via the API+  * We are not limited to only one user but we can adjust the filter for instance to disable all the users with specific suffix e.g. @dev. 
- +  * For this we have to make the following adjustments: 
 +<code php> 
 +$username   = '@dev'; 
 +$action     = 'disable'; //Options 'enable' or 'disable' 
 +     
 +// Filter settings 
 +$filter     = 'username'; //field that filter should apply to 
 +$operator   = 'like';  //Options '==','like'  
 +$value      = $username; //can also be set to boolean e.g. true or false to filter for instance on the 'active' field 
 +$limit      = 1000; 
 +</code> 
 +  * By the same token, if we want to enable all disabled users we can adjust the filter as follows: 
 +<code php> 
 +$action     = 'enable'; //Options 'enable' or 'disable' 
 +     
 +// Filter settings 
 +$filter     = 'active'; //field that filter should apply to 
 +$operator   = '==';  //Options '==','like'  
 +$value      = false; //can also be set to boolean e.g. true or false to filter for instance on the 'active' field 
 +$limit      = 1000; 
 +</code>
  • technical/api-pu-disable.1744528139.txt.gz
  • Last modified: 2025/04/13 09:08
  • by system