[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freeradius-users
Subject:    Re: More efficient programming of the unlang language
From:       Marijn van Gool <marijn.vangool () comsave ! com>
Date:       2018-04-23 14:38:39
Message-ID: 3F64F495-7226-4EAC-B0FC-652FBC1243C2 () comsave ! com
[Download RAW message or body]

> Pretty much what you've written? This is all in the unlang man page.

I've checked both the Unlang documentation online as well as man unlang page.
Both did not give me the correct information to use, hence I'm asking this question. I was quite stuck.

> Use a temporary attribute, something like
> 
> update control {
> 	&Tmp-String-1 := "%{sql:SELECT username .....}"
> }        
> 
> if (&control:Tmp-String-1) {
> 	update request {
>        	&User-Name := &control:Tmp-String-1
> 	}        
> }
> 
> I'd update the things that use the User-Name attribute, though, rather
> than changing the attribute itself.

Thanks a lot. It's pretty much what I've written, I agree.
I was just missing the right syntax.

Met vriendelijke groet \ With kind regards,

Marijn van Gool
NOC Network Engineer
noc@comsave.com <mailto:noc@comave.com> 

+31 88 999 5555
marijn.vangool@comsave.com <mailto:marijn.vangool@comsave.com> 
www.comsave.nl <http://www.comsave.nl/> 






> On 23 Apr 2018, at 16:13, Matthew Newton <mcn@freeradius.org> wrote:
> 
> On Mon, 2018-04-23 at 15:56 +0200, Marijn van Gool wrote:
>> 
>> 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?
> 
> Pretty much what you've written? This is all in the unlang man page.
> 
> Use a temporary attribute, something like
> 
> update control {
> 	&Tmp-String-1 := "%{sql:SELECT username .....}"
> }        
> 
> if (&control:Tmp-String-1) {
> 	update request {
>        	&User-Name := &control:Tmp-String-1
> 	}        
> }
> 
> I'd update the things that use the User-Name attribute, though, rather
> than changing the attribute itself.
> 
> -- 
> Matthew
> 
> -
> List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html

-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic