RE: New custom query - MySQL

Rodrigo Prazim <[email protected]>
Newsgroups gmane.comp.freeradius.user
Message-ID <SN7PR12MB68150712BCA2B2D50871D733AB4AA@SN7PR12MB6815.namprd12.prod.outlook.com>
Hi, Alan.

I'm using the radclient for test:
echo "User-Name='teste@allohaligue',User-Password=testeligue,ADSL-Agent-Circuit-Id=HelloWorld" | radclient localhost:1812 auth testing123

And my config "sites-enabled/default":

post-auth {
     ...
     sql

     %{sql:"INSERT INTO radcircuitid (username, circuitid) VALUES ('%{SQL-User-Name}', '%{string:ADSL-Agent-Circuit-Id}') ON DUPLICATE KEY UPDATE circuitid = '%{string:ADSL-Agent-Circuit-Id}'"}
     ...
}

But nothing arrives in the database:

2025-07-12T13:33:13.964462Z   49120 Query SELECT id, username, attribute, value, op FROM radcheck WHERE username = 'teste@allohaligue' ORDER BY id
2025-07-12T13:33:13.964824Z   49120 Query SELECT id, username, attribute, value, op FROM radreply WHERE username = 'teste@allohaligue' ORDER BY id
2025-07-12T13:33:13.965017Z   49120 Query SELECT groupname FROM radusergroup WHERE username = 'teste@allohaligue' ORDER BY priority
2025-07-12T13:33:13.965180Z   49120 Query SELECT id, groupname, attribute, Value, op FROM radgroupcheck WHERE groupname = 'TESTE789' ORDER BY id
2025-07-12T13:33:13.965323Z   49120 Query SELECT id, groupname, attribute, value, op FROM radgroupreply WHERE groupname = 'TESTE789' ORDER BY id
2025-07-12T13:33:13.965609Z   49121 Query INSERT INTO radpostauth (username, pass, reply, authdate ) VALUES ( 'teste@allohaligue', LEFT('testeligue', 64), 'Access-Accept', '2025-07-12 10:33:13.964051' )


FreeRadius v3.2.7

Best Resgard,

Rodrigo Prazim
________________________________
De: Freeradius-Users <freeradius-users-bounces+rodrigoprazim=hotmail.com@lists.freeradius.org> em nome de Alan DeKok via Freeradius-Users <[email protected]>
Enviado: sábado, 12 de julho de 2025 07:01
Para: FreeRadius users mailing list <[email protected]>
Cc: Alan DeKok <[email protected]>
Assunto: Re: New custom query - MySQL

On Jul 12, 2025, at 2:22 AM, Rodrigo Prazim <[email protected]> wrote:
> I am trying to run a custom query in order to generate reports for the company.
> Here's the idea:
> Every time there is an authentication attempt, I would like to save the record in a separate table.

  Just run the query in place, in sites-enabled/default:

post-auth {
        ...

        %{sql:"INSERT INTO ..."}

}

  Alan DeKok.

-
List info/subscribe/unsubscribe? See https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.freeradius.org%2Flist%2Fusers.html&data=05%7C02%7C%7Cd4dd8fdef4994e0bdf5d08ddc12b40fa%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638879113714628530%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=M4r0V%2FPCcT%2FaYIlo8n4yGqQmnypKa7q10AlOJis7Au8%3D&reserved=0<http://www.freeradius.org/list/users.html>
-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.