SQL and Huntgroups

gregoire.leroy at retenodus.net gregoire.leroy at retenodus.net
Mon Apr 29 16:17:36 CEST 2013

>> For the step 4, I have to :
>> 1) Retrieve the huntgroup
>> 2) Compare it with what the user sends
>> 3) If it matches, give him his specific statement.
>> So, if I understand correctly in the authorize section, I have to
>> maintain a radipusers table for my IP/users and do something like :
>> 1)
>> update request {
>> Huntgroup-Name := "%{sql:SELECT groupname FROM radhuntgroup WHERE
>> nasipaddress='%{NAS-IP-Address}'}"
>> }
>> 2)
>> if Huntgroup-Name == 'one_huntgroup_name' {
>> 3)
>> Framed-IP-Address = "%{sql:SELECT ip FROM radipusers WHERE
>> user='%{username}'}"
>> }
>> Is there something wrong in what I just said ?
>   I'm really not sure.
>   All I can say is try it, and see if it works.

I tried it and it worked.
However, it worked only because the specific statement was :
"Framed-IP-Address = IP.ADD.RE.SS"

(Remind : the wanted behaviour is
I want the following behaviour :

1) Set the password for the user
2) Authentication of the user
3) X is always added to the reply if the user is authenticated
4) Moreover, Y is added to the reply for NAS, still if the user is 

What I would like instead of my dumb radipusers table (id | username | 
ip), is a table which looks like radreply (id | username | attribute | 
op | value) I could use with unlang.

The thing I want to be added by radius in the reply :
if (Huntgroup-Name == 'one_huntgroup_name') {
    Attribute1 op1 value1
    Attribute2 op2 value2
    Attributei opi valuei
Given that Attribute,op,value 1...i are in the MySQL table.

Is it possible to get that by unlang / SQL ? I've read the unlang 
manpage, and I don't see any information which would enable me to do 
I've tried something without so much hope, and without success :
"%{sql:SELECT attribute from radreply where 
username='%{request:User-Name}'}" = "%{sql:SELECT value from radreply 
where username='%{User-Name}'}"

Thank you for your help,
Grégoire Leroy

More information about the Freeradius-Users mailing list