RE: Reverse string concatenation for multiple attributes
Hi Arran, Nice one. Looking for sql map stuff i found this thread https://github.com/FreeRADIUS/freeradius-server/issues/984 .. It seems to indicate predefinition in a module, which is ok but your example looks more inline. I am guessing the sql bit matches the module instance name here and the query is loaded in a variable? Would an xlat type section be therefore Map sql_instname &var { Control:Tmp-string-0 += myfieldname } Or am i way out and it needs module definition? Thanks! ________________________________________ From: Freeradius-Users [freeradius-users-bounces+andy.franks=sath.nhs.uk@lists.freeradius.org] on behalf of Arran Cudbard-Bell [a.cudbardb@freeradius.org] Sent: 10 December 2015 18:06 To: FreeRadius users mailing list Subject: Re: Reverse string concatenation for multiple attributes
On 10 Dec 2015, at 12:57, Arran Cudbard-Bell <a.cudbardb@freeradius.org> wrote:
On 10 Dec 2015, at 12:42, Franks Andy (IT Technical Architecture Manager) <Andy.Franks@sath.nhs.uk> wrote:
Hi all, I'm trying to do something a bit fiddly. I'm sure I've asked this before but google doesn't help. Can we pass back multiple attributes from a sql xlat yet on 3.1.0? If not, is there a reverse of %{Attribute-Name[*]} that could translate my value1\nvalue2 from an SQL stored procedure into attribute[1]=value1, attribute[2]=value2 etc? If not, has anyone come up with a clean way to iterate through and do the equivalent via += a number of times? It seems I can use explode to get the number of delimiters (maybe I'm using it wrongly).
Maybe I'm missing something REALLY simple. Wouldn't be the first time. :-~
You can do it with maps IIRC:
map sql <query> { <radius attr> += <sql column> }
And then use the pairs xlat. -Arran Arran Cudbard-Bell <a.cudbardb@freeradius.org> FreeRADIUS development team FD31 3077 42EC 7FCD 32FE 5EE2 56CF 27F9 30A8 CAA2
.. It seems to indicate predefinition in a module, which is ok but your example looks more inline. I am guessing the sql bit matches the module instance name here and the query is loaded in a variable?
Or an xlat. It's a polymorphic template type meaning it can be an attribute reference as you have below, an xlat expansion like "SELECT * FROM BLAH WHERE user = %{user-Name}", an exec `echo 'SELECT * FROM BLAH'`, or just a plain literal like 'SELECT * FROM BLAH WHERE 1'
Would an xlat type section be therefore
Map sql_instname &var { Control:Tmp-string-0 += myfieldname }
Or am i way out and it needs module definition?
Nope that's good. Then update request { Tmp-String-0 := "%{pairs:&control:Tmp-String-0[*]}" } To recombine into a list of comma delimited value pairs. -Arran Arran Cudbard-Bell <a.cudbardb@freeradius.org> FreeRADIUS development team FD31 3077 42EC 7FCD 32FE 5EE2 56CF 27F9 30A8 CAA2
participants (2)
-
Arran Cudbard-Bell -
Franks Andy (IT Technical Architecture Manager)