Mikrotik Rate Limit attribute from query.
Hi All. I'm migrating ClearBox Radius Software to freeradius, And I need to pass the attribute Mikrotik-Rate-Limit via query. The Query for ClearBox is: "SELECT 'Mikrotik-Rate-Limit' AS Expr1, \ CASE WHEN sync = 1 THEN \ REPLACE(CAST(idvelocidad as char) + 'K',' ','') \ ELSE \ REPLACE(CAST(idvelocidad /2 as char)+'K/'+ CAST(idvelocidad as char)+'K',' ','') \ END \ AS Expr2 \ FROM SubAccounts with(nolock) \ WHERE Login = '%{SQL-User-Name}'" This query takes the bandwidth of a table in the CRM software. If the client is a business (synchronization), the bandwidth is symmetric, but if the client is an ordinary client, the bandwidth is not symmetric and the upload bandwidth is divided by 2 and the upload bandwidth is divided by 2. download is integer. How can I keep this in freeradius and pass the parameter through a query? Thanks
The simplest method for that would be an SQL xlat. Presuming your SQL module name is sql, something like: update reply { &Mikrotik-Rate-Limit := "%{sql:SELECT CASE WHEN sync = 1 THEN REPLACE(CAST(idvelocidad as char) + 'K', ' ', '') ELSE REPLACE(CAST(idvelocidad /2 as char + 'K/' + CAST(idvelocidad as char)+'K', ' ', '') END FROM SubAccounts WHERE Login = '%{SQL-User-Name}'}" } On 13/10/2022 03:42, Carlos Botejara wrote:
Hi All. I'm migrating ClearBox Radius Software to freeradius, And I need to pass the attribute Mikrotik-Rate-Limit via query.
The Query for ClearBox is: "SELECT 'Mikrotik-Rate-Limit' AS Expr1, \ CASE WHEN sync = 1 THEN \ REPLACE(CAST(idvelocidad as char) + 'K',' ','') \ ELSE \ REPLACE(CAST(idvelocidad /2 as char)+'K/'+ CAST(idvelocidad as char)+'K',' ','') \ END \ AS Expr2 \ FROM SubAccounts with(nolock) \ WHERE Login = '%{SQL-User-Name}'"
This query takes the bandwidth of a table in the CRM software. If the client is a business (synchronization), the bandwidth is symmetric, but if the client is an ordinary client, the bandwidth is not symmetric and the upload bandwidth is divided by 2 and the upload bandwidth is divided by 2. download is integer.
How can I keep this in freeradius and pass the parameter through a query?
Thanks - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
-- Nick Porter
participants (2)
-
Carlos Botejara -
Nick Porter