More efficient programming of the unlang language

Marijn van Gool marijn.vangool at
Mon Apr 23 15:56:20 CEST 2018

Hello freeradius users,

I have searched the freeradius unlang documentation, but couldn’t find a way to make the following piece of unlang code more effective:

if ("%{sql:SELECT username FROM radcheck WHERE username LIKE '%{string:&ADSL-Agent-Remote-Id}@%%' LIMIT 1}" != "") {
	update request {
        	User-Name := "%{sql:SELECT username FROM radcheck WHERE username LIKE '%{string:&ADSL-Agent-Remote-Id}@%%' LIMIT 1}"

Basically what I’m trying to do is to check if the query in question returns the username and to use this username in a self created variable later on.
Something like this:

username-var = SELECT query;

if (username-var != “”) {
	update-request {
		User-Name := username-var

How would I achieve this? What is the syntax that can be used here?


Met vriendelijke groet \ With kind regards,

Marijn van Gool
NOC Network Engineer
noc at <mailto:noc at> 

+31 88 999 5555
marijn.vangool at <mailto:marijn.vangool at> <> 

More information about the Freeradius-Users mailing list