Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| technical:api-pu-delete [2025/04/13 14:29] – created system | technical:api-pu-delete [2025/04/13 15:01] (current) – [Delete Permanent Users] system | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| <nav type=" | <nav type=" | ||
| * [[: | * [[: | ||
| - | * [[: | + | * [[: |
| </ | </ | ||
| ----- | ----- | ||
| - | ====== Delete Permanent | + | ====== Delete Permanent |
| - | * To terminate | + | * To delete |
| + | * A CRM system typically do not know the id of the Permanent User in RADIUSdesk. | ||
| * With the sample script we use two APIs | * With the sample script we use two APIs | ||
| - | * The one API is used get a list of active sessions for a specified | + | * The one API is used get a list of Permanent |
| - | * The other API is used to terminate each of the sessions | + | * The other API is used to delete |
| - | <file php permanent_user_disable_enable.php> | + | <file php permanent_user_delete.php> |
| <?php | <?php | ||
| Line 21: | Line 22: | ||
| $username | $username | ||
| - | $api_url | ||
| + | $api_url | ||
| + | |||
| + | |||
| // Filter settings | // Filter settings | ||
| $filter | $filter | ||
| Line 36: | Line 39: | ||
| ]]; | ]]; | ||
| $encoded_filter = urlencode(json_encode($filter_array)); | $encoded_filter = urlencode(json_encode($filter_array)); | ||
| - | $find_url = " | + | $find_url = " |
| // Get User IDs | // Get User IDs | ||
| Line 46: | Line 49: | ||
| ' | ' | ||
| ' | ' | ||
| - | | + | |
| ]; | ]; | ||
| - | print_r($payload); | + | |
| - | $response = sendDisconnectRequest($api_url, $payload); | + | $response = sendPostRequest($api_url, $payload); |
| - | echo "Terminated Session | + | echo "Updated |
| } | } | ||
| } | } | ||
| Line 80: | Line 83: | ||
| } | } | ||
| - | function | + | function |
| - | + | $ch = curl_init($url); | |
| - | // Build the query string from $data | + | |
| - | $queryString = http_build_query($data); | + | |
| - | + | ||
| - | // Append it to the URL | + | |
| - | $urlWithParams = $url . '?' | + | |
| - | + | ||
| - | $ch = curl_init($urlWithParams); | + | |
| curl_setopt_array($ch, | curl_setopt_array($ch, | ||
| CURLOPT_RETURNTRANSFER => true, | CURLOPT_RETURNTRANSFER => true, | ||
| - | CURLOPT_HTTPHEADER | + | |
| + | CURLOPT_POSTFIELDS | ||
| + | | ||
| ]); | ]); | ||
| - | |||
| $response = curl_exec($ch); | $response = curl_exec($ch); | ||
| if ($response === false) { | if ($response === false) { | ||
| Line 103: | Line 100: | ||
| ?> | ?> | ||
| </ | </ | ||
| - | * We are not limited to only one user but we can adjust the filter | + | * We are not limited to only one user but we can for instance |
| * For this we have to make the following adjustments: | * For this we have to make the following adjustments: | ||
| <code php> | <code php> | ||
| Line 115: | Line 112: | ||
| </ | </ | ||
| + | * By the same token, if we want to delete all disabled users we can adjust the filter as follows: | ||
| + | |||
| + | <code php> | ||
| + | $action | ||
| + | |||
| + | // Filter settings | ||
| + | $filter | ||
| + | $operator | ||
| + | $value | ||
| + | $limit | ||
| + | </ | ||