multiple columns in rlm_sql

petr.linke at seznam.cz petr.linke at seznam.cz
Mon Apr 16 13:45:55 CEST 2018


Hi Alan,
thank you very much for idea, great.

I set all in similar way, but it looks, that with xlat is no possible for 
define first column in update reply section.

for example:

update control {
   Tmp-String-0 := %{sql:SELECT CONCAT(attribute,'#',value) from database_
table where...}
}
if ( control:Tmp-String-0 =~ /^(\S+)#(.*)$/ ) {
   update reply {
        "%{1}" += "%{2}"
        test_attribute += "%{2}"
   }
}

if the sql SELECT CONCAT(attribute,'#',value) ... return in attribute "some_
attribute" and in value "some_value", the answer should be 2 lines:
some_attribute += some_value    --- this is from xlat     "%{1}" += "%{2}"
test_attribute += some_value        --- this is from xlat      test_
attribute += "%{2}"

but in the answer is only one line "test_attribute += some_value"  according
xlat  test_attribute += "%{2}"

In debug I can see, that the expansion of %{1} is correct, and that in 
update reply section is the line "some_attribute += some_value" inserted, 
but in radius response is no line "some_attribute += some_value"

Maybe I do something wrong.

Thank you, Petr Linke

---------- Original-mail ----------
From: Alan Buxey <alan.buxey at gmail.com>
To: FreeRadius users mailing list <freeradius-users at lists.freeradius.org>
Date: 13. 4. 2018 19:19:29
Subject: Re: multiple columns in rlm_sql 
"with later versions of 3.0.x you can do things like

update control {
Tmp-String-0 := %{sql:SELECT
CONCAT(attribute,'#',op,'#',value) from database_table where username
= '%{User-Name}'}"
}
if ("%{explode:&control:Tmp-String-0 #}" > 0) {
foreach &control:Tmp-String-0 {
if ("%{Foreach-Variable-0}" =~
/^([^=]+)=(.*)$/) {
update reply {
"%{1}" "%{2}" "%{3}"
}
}
}
}


edit as required....should do the job.

alan
-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.
html"


More information about the Freeradius-Users mailing list