FW: MSSQL using unixodbc and truncation of characters

Franks Andy (RLZ) IT Systems Engineer Andy.Franks at sath.nhs.uk
Wed Jun 12 18:47:43 CEST 2013


Sorry, FR version 2.2.1.
Thanks
andy

_____________________________________________
From: Franks Andy (RLZ) IT Systems Engineer 
Sent: 12 June 2013 17:43
To: freeradius-users at lists.freeradius.org
Subject: MSSQL using unixodbc and truncation of characters


Hi all,
  I may again being doing something wrong but I've noticed an odd
problem.  I've connected up using the freetds libraries to an MSSQL
server.
iSQL works fine and I can do a query thus :

Select NetworkCardID from Audit_NetworkCard where
macaddress='00:14:22:53:de:58'
+--------------+
| NetworkCardID|
+--------------+
| 96375        |

So, the query comes back with 96375, which is the correct query
response. However the same query in FR, using the following unlang :

update control {
    SQLNetworkCardID := "%{sql_test_mssql:Select NetworkCardID from
Audit_NetworkCard where macaddress='%{control:DelimitedMac}'}"
        }

Returns 9637

I'm using an external program "MacToDelimitedMac" to delimit the mac
address, but it's coming back with the correct value so I don't think
this is the problem :

Output :

[MacToDelimitedMac]     expand: %{User-Name} -> 00142253de58
Exec output: DelimitedMac := "00:14:22:53:de:58"
[MacToDelimitedMac] Exec output: DelimitedMac := "00:14:22:53:de:58"
[MacToDelimitedMac] Exec: program returned: 0
++[MacToDelimitedMac] returns ok
++? if (control:DelimitedMac)
? Evaluating (control:DelimitedMac) -> TRUE
++? if (control:DelimitedMac) -> TRUE
++- entering if (control:DelimitedMac) {...}
sql_xlat
        expand: %{User-Name} -> 00142253de58
sql_set_user escaped user --> '00142253de58'
        expand: Select NetworkCardID from Audit_NetworkCard where
macaddress='%{control:DelimitedMac}' -> Select NetworkCardID from
Audit_NetworkCard where macaddress='00:14:22:53:de:58'
rlm_sql (sql_test_mssql): Reserving sql socket id: 4
sql_xlat finished
rlm_sql (sql_test_mssql): Released sql socket id: 4
        expand: %{sql_test_mssql:Select NetworkCardID from
Audit_NetworkCard where macaddress='%{control:DelimitedMac}'} -> 9637
+++[control] returns ok

Anyone any ideas why it's returning a truncated value?
I've tried a few SQL queries to return values and it's truncating any
integer values (doesn't seem to happen where sql fields are not integer)
over 4 digits. Any return value of less than digits returns properly!
I guess it's me but I'm stumped.

Thanks
Andy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freeradius.org/pipermail/freeradius-users/attachments/20130612/57b13afd/attachment-0001.html>


More information about the Freeradius-Users mailing list