how to have freeradius/unlang do two or more SQL statements at one time
Hi, When Post-Auth-Type REJECT is executed I need to insert two or more rows into a SQL data base. here is what I have at present sites-enabled/default Post-Auth-Type REJECT { sql } sql.conf -> sql/mysql/dialup.conf postauth_query = "INSERT INTO ${authcheck_table} VALUES (NULL,'%{User-Name}','Password', '==', '%{User-Password:-Chap-Password}');" postauth_query = "INSERT INTO ${usergroup_table} values ('%{User-Name}','Dynamic','');" The FIRST insert runs, but the second one doesn't. mucho thanks in advance
Dave Sinclair wrote:
sql.conf -> sql/mysql/dialup.conf
postauth_query = "INSERT INTO ${authcheck_table} VALUES (NULL,'%{User-Name}','Password', '==', '%{User-Password:-Chap-Password}');" postauth_query = "INSERT INTO ${usergroup_table} values ('%{User-Name}','Dynamic','');"
The FIRST insert runs, but the second one doesn't.
The module runs only one query: the first one. If you need to run more queries, for now, use the Perl module. Arran has a patch pending that will allow inserts directly via unlang. Very nice, and it would make your requirement nearly trivial to meet. Alan DeKok.
Hi, If your sql server allows that you can run a stored procedure here and just pass all the required parameters there. kind regards Pshem
When Post-Auth-Type REJECT is executed I need to insert two or more rows into a SQL data base.
here is what I have at present
sites-enabled/default
Post-Auth-Type REJECT { sql }
sql.conf -> sql/mysql/dialup.conf
postauth_query = "INSERT INTO ${authcheck_table} VALUES (NULL,'%{User-Name}','Password', '==', '%{User-Password:-Chap-Password}');" postauth_query = "INSERT INTO ${usergroup_table} values ('%{User-Name}','Dynamic','');"
The FIRST insert runs, but the second one doesn't.
Yes, only one gets executed. Try this: postauth_query = "INSERT INTO ${authcheck_table} ... ; INSERT INTO ${usergroup_table} ... " If that doesn't work you will have to do inserts with perl. Ivan Kalik Kalik Informatika ISP
also try with UNION ... On Mon, Mar 16, 2009 at 10:39 AM, <tnt@kalik.net> wrote:
When Post-Auth-Type REJECT is executed I need to insert two or more rows into a SQL data base.
here is what I have at present
sites-enabled/default
Post-Auth-Type REJECT { sql }
sql.conf -> sql/mysql/dialup.conf
postauth_query = "INSERT INTO ${authcheck_table} VALUES (NULL,'%{User-Name}','Password', '==', '%{User-Password:-Chap-Password}');" postauth_query = "INSERT INTO ${usergroup_table} values ('%{User-Name}','Dynamic','');"
The FIRST insert runs, but the second one doesn't.
Yes, only one gets executed. Try this:
postauth_query = "INSERT INTO ${authcheck_table} ... ; INSERT INTO ${usergroup_table} ... "
If that doesn't work you will have to do inserts with perl.
Ivan Kalik Kalik Informatika ISP
- List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
Hi All, The old rlm_xlat function only supported SELECT statements, and threw up errors on any others. The patch Alan mentioned makes rlm_sql look for INSERT, DELETE and UPDATE keywords at the beginning of SQL statements. If one of these keywords is found and instead of expanding to the first row of the first column of the result, rlm_sql expands to the number of rows affected by the statement, and no longer throws an error. It is now therefore possible, to replicate most of the functionality of rlm_sql with unlang statements.
Yes, only one gets executed. Try this:
postauth_query = "INSERT INTO ${authcheck_table} ... ; INSERT INTO ${usergroup_table} ... "
If that doesn't work you will have to do inserts with perl.
You'll now be able to do them with unlang to :). Thanks, Arran -- Arran Cudbard-Bell (A.Cudbard-Bell@sussex.ac.uk), Authentication, Authorisation and Accounting Officer, Infrastructure Services (IT Services), E1-1-08, Engineering 1, University Of Sussex, Brighton, BN1 9QT DDI+FAX: +44 1273 873900 | INT: 3900 GPG: 86FF A285 1AA1 EE40 D228 7C2E 71A9 25BB 1E68 54A2
Hi Arran, Where might one find your patch ??? 2009/3/16 Arran Cudbard-Bell <A.Cudbard-Bell@sussex.ac.uk>:
Hi All,
The old rlm_xlat function only supported SELECT statements, and threw up errors on any others.
The patch Alan mentioned makes rlm_sql look for INSERT, DELETE and UPDATE keywords at the beginning of SQL statements. If one of these keywords is found and instead of expanding to the first row of the first column of the result, rlm_sql expands to the number of rows affected by the statement, and no longer throws an error.
It is now therefore possible, to replicate most of the functionality of rlm_sql with unlang statements.
Yes, only one gets executed. Try this:
postauth_query = "INSERT INTO ${authcheck_table} ... ; INSERT INTO ${usergroup_table} ... "
If that doesn't work you will have to do inserts with perl.
You'll now be able to do them with unlang to :).
Thanks, Arran -- Arran Cudbard-Bell (A.Cudbard-Bell@sussex.ac.uk), Authentication, Authorisation and Accounting Officer, Infrastructure Services (IT Services), E1-1-08, Engineering 1, University Of Sussex, Brighton, BN1 9QT DDI+FAX: +44 1273 873900 | INT: 3900 GPG: 86FF A285 1AA1 EE40 D228 7C2E 71A9 25BB 1E68 54A2 - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
On 16/3/09 14:14, Dave Sinclair wrote:
Hi Arran,
Where might one find your patch ???
In the git repository once Alan reads his email and checks it in :) (hopefully soon). -- Arran Cudbard-Bell (A.Cudbard-Bell@sussex.ac.uk), Authentication, Authorisation and Accounting Officer, Infrastructure Services (IT Services), E1-1-08, Engineering 1, University Of Sussex, Brighton, BN1 9QT DDI+FAX: +44 1273 873900 | INT: 3900 GPG: 86FF A285 1AA1 EE40 D228 7C2E 71A9 25BB 1E68 54A2
Hi Tried this, but it tossed out errors at me :( 2009/3/16 <tnt@kalik.net>:
When Post-Auth-Type REJECT is executed I need to insert two or more rows into a SQL data base.
here is what I have at present
sites-enabled/default
Post-Auth-Type REJECT { sql }
sql.conf -> sql/mysql/dialup.conf
postauth_query = "INSERT INTO ${authcheck_table} VALUES (NULL,'%{User-Name}','Password', '==', '%{User-Password:-Chap-Password}');" postauth_query = "INSERT INTO ${usergroup_table} values ('%{User-Name}','Dynamic','');"
The FIRST insert runs, but the second one doesn't.
Yes, only one gets executed. Try this:
postauth_query = "INSERT INTO ${authcheck_table} ... ; INSERT INTO ${usergroup_table} ... "
If that doesn't work you will have to do inserts with perl.
Ivan Kalik Kalik Informatika ISP
- List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
participants (6)
-
Alan DeKok -
Arran Cudbard-Bell -
Dave Sinclair -
Marinko Tarlac -
Pshem Kowalczyk -
tnt@kalik.net