Re: xlat sql trouble
On Mon, 17 Jan 2005 11:43:51 -0500, Alan DeKok <[EMAIL PROTECTED]> wrote: > Red Cayenne <[EMAIL PROTECTED]> wrote: > I mean that your sql xlat function needs to call radius_xlat, too. > How else will it expand the variables passed to your function? > > Print out the string that gets passed to your sql xlat function. It > will be "%{config:modules.sql.test_query}". > > Please also READ the original sql_xlat function. It explains this > in the comments! > > Alan DeKok. > I messed up sql_xlat and radius_xlat, sorry. Now I understand. Thanks Alan. - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
Re: xlat sql trouble
Red Cayenne <[EMAIL PROTECTED]> wrote: > Thanks, this got me going. I got a clue that radius_xlat should call > itself to do the substitution, however I'm uncertain how to do this. I mean that your sql xlat function needs to call radius_xlat, too. How else will it expand the variables passed to your function? > I'm executing test_query using "%{sql:%{config:modules.sql.test_query}}". Print out the string that gets passed to your sql xlat function. It will be "%{config:modules.sql.test_query}". Please also READ the original sql_xlat function. It explains this in the comments! Alan DeKok. - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
Re: xlat sql trouble
On Sun, 16 Jan 2005 11:46:52 -0500, Alan DeKok <[EMAIL PROTECTED]> wrote: > Read the original sql_xlat function, and see what the differences > are between it and your function. > > Odds are you're not calling radius_xlat. > > Alan DeKok. Thanks, this got me going. I got a clue that radius_xlat should call itself to do the substitution, however I'm uncertain how to do this. I'm executing test_query using "%{sql:%{config:modules.sql.test_query}}". I found a solution that seems to work, by concating variable from the query to the above statement - "%{sql:%{config:modules.sql.test_query} '%User-Name' }", and altering query according to this. Although this seems to work, I'm not quite satisfied with this solution, because a question still bothers me: how to make radius_xlat call itself? Regards, R. - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
Re: xlat sql trouble
Red Cayenne <[EMAIL PROTECTED]> wrote: > I wrote a custom xlat sql function (my setup is with mysql backend), > registered it, and radius_xlat gets the function running. However, > variables in query are not replaced with attribute values... So my > question is: what did I do wrong? :) Read the original sql_xlat function, and see what the differences are between it and your function. Odds are you're not calling radius_xlat. Alan DeKok. - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
xlat sql trouble
Hi, I wrote a custom xlat sql function (my setup is with mysql backend), registered it, and radius_xlat gets the function running. However, variables in query are not replaced with attribute values... So my question is: what did I do wrong? :) sql.conf : test_query = "SELECT id FROM ${authcheck_table} WHERE Username = '%{SQL-User-Name}'" Debug mode output for authorization: modcall[authorize]: module "files" returns ok for request 0 radius_xlat: 'test1' rlm_sql (sql): sql_set_user escaped user --> 'test1' radius_xlat: 'SELECT id,UserName,Attribute,Value,op FROM radcheck WHERE Username = 'test1' ORDER BY id' rlm_sql (sql): Reserving sql socket id: 4 radius_xlat: 'SELECT radgroupcheck.id,radgroupcheck.GroupName,radgroupcheck.Attribute,radgroupcheck.Value,radgroupcheck.op FROM radgroupcheck,usergroup WHERE usergroup.Username = 'test1' AND usergroup.GroupName = radgroupcheck.GroupName ORDER BY radgroupcheck.id' radius_xlat: 'SELECT id,UserName,Attribute,Value,op FROM radreply WHERE Username = 'test1' ORDER BY id' radius_xlat: 'SELECT radgroupreply.id,radgroupreply.GroupName,radgroupreply.Attribute,radgroupreply.Value,radgroupreply.op FROM radgroupreply,usergroup WHERE usergroup.Username = 'test1' AND usergroup.GroupName = radgroupreply.GroupName ORDER BY radgroupreply.id' rlm_sql (sql): Released sql socket id: 4 modcall[authorize]: module "sql" returns ok for request 0 Debug output for my function: radius_xlat: Running registered xlat function of module sql for string '%{config:modules.sql.test_query}' rlm_sql (sql): - sql_xlat radius_xlat: 'test1' rlm_sql (sql): sql_set_user escaped user --> 'test1' radius_xlat: Running registered xlat function of module config for string 'modules.sql.test_query' radius_xlat: 'SELECT id FROM radcheck WHERE Username = '%{SQL-User-Name}'' rlm_sql (sql): Reserving sql socket id: 3 rlm_sql (sql): SQL query did not return any results rlm_sql (sql): Released sql socket id: 3 radius_xlat: '' I'm executing this function from post-auth section, Freeradius v1.0.1. Thanks, R. - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html