Hi list, i have a simple query that doesn't execute properly. In config file: #sql named instance: SqlNamedInstance01 # MAC LIMIT update control { Tmp-Integer-1 = "%{SqlNamedInstance01: SELECT count(*) FROM mac_limit WHERE Username = '%{SQL-User-Name}' and callingstationid='%{Calling-Station-Id}'}" } if ("%{control:Tmp-Integer-1}" == 0) { update control { Tmp-String-1 = " MAC LIMIT: MAC address not authorized! " } reject } while in debug mode: (0) [SqlNamedInstance01] = ok (0) update control { (0) EXPAND %{%{Stripped-User-Name}:-%{%{User-Name}:-DEFAULT}} (0) --> igor.smitran (0) SQL-User-Name set to 'igor.smitran' rlm_sql (SqlNamedInstance01): Reserved connection (2) (0) Executing select query: SELECT count(*) FROM mac_limit WHERE Username = '' and callingstationid='44-d4-e0-a2-f3-48' rlm_sql (SqlBlicnetSsid): Released connection (2) (0) EXPAND %{SqlNamedInstance01: SELECT count(*) FROM mac_limit WHERE Username = '%{SQL-User-Name}' and callingstationid='%{Calling-Station-Id}'} (0) --> 0 (0) Tmp-Integer-1 = 0 (0) } # update control = noop (0) if ("%{control:Tmp-Integer-1}" == 0) { (0) if ("%{control:Tmp-Integer-1}" == 0) -> TRUE (0) if ("%{control:Tmp-Integer-1}" == 0) { So, for some reason, SQL-User-Name is empty. Any help anyone? Thank you, Igor
On Wed, May 24, 2017 at 11:43:27AM +0200, Igor Smitran wrote:
(0) [SqlNamedInstance01] = ok (0) update control { (0) EXPAND %{%{Stripped-User-Name}:-%{%{User-Name}:-DEFAULT}} (0) --> igor.smitran (0) SQL-User-Name set to 'igor.smitran' rlm_sql (SqlNamedInstance01): Reserved connection (2) (0) Executing select query: SELECT count(*) FROM mac_limit WHERE Username = '' and callingstationid='44-d4-e0-a2-f3-48' rlm_sql (SqlBlicnetSsid): Released connection (2) (0) EXPAND %{SqlNamedInstance01: SELECT count(*) FROM mac_limit WHERE Username = '%{SQL-User-Name}' and callingstationid='%{Calling-Station-Id}'} (0) --> 0 (0) Tmp-Integer-1 = 0 (0) } # update control = noop (0) if ("%{control:Tmp-Integer-1}" == 0) { (0) if ("%{control:Tmp-Integer-1}" == 0) -> TRUE (0) if ("%{control:Tmp-Integer-1}" == 0) {
So, for some reason, SQL-User-Name is empty.
I seem to remember there's an issue using SQL-User-Name in xlats where the attribute is added at the wrong time so isn't available for the xlat expansion. The best I can find is this, which has a workaround you can try: https://github.com/FreeRADIUS/freeradius-server/issues/640 Someone else might remember better about it. Matthew -- Matthew Newton, Ph.D. <mcn4@leicester.ac.uk> Systems Specialist, Infrastructure Services, I.T. Services, University of Leicester, Leicester LE1 7RH, United Kingdom For IT help contact helpdesk extn. 2253, <ithelp@le.ac.uk>
On May 24, 2017, at 5:43 AM, Igor Smitran <sigor@blic.net> wrote:
while in debug mode:
(0) [SqlNamedInstance01] = ok (0) update control { (0) EXPAND %{%{Stripped-User-Name}:-%{%{User-Name}:-DEFAULT}}
So use that in the SQL expansion, instead of SQL-User-Name. Why do you need to use SQL-User-Name instead of User-Name or Stripped-User-Name? Alan DeKok.
In the end i did just that. I just wanted to save few cpu cycles and not execute same thing two times (logical OR in this example). Igor On 05/24/2017 02:19 PM, Alan DeKok wrote:
On May 24, 2017, at 5:43 AM, Igor Smitran <sigor@blic.net> wrote:
while in debug mode:
(0) [SqlNamedInstance01] = ok (0) update control { (0) EXPAND %{%{Stripped-User-Name}:-%{%{User-Name}:-DEFAULT}} So use that in the SQL expansion, instead of SQL-User-Name.
Why do you need to use SQL-User-Name instead of User-Name or Stripped-User-Name?
Alan DeKok.
- List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
participants (3)
-
Alan DeKok -
Igor Smitran -
Matthew Newton