MSSQL using unixodbc and truncation of characters

Franks Andy (RLZ) IT Systems Engineer Andy.Franks at
Wed Jun 12 18:42:49 CEST 2013

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
iSQL works fine and I can do a query thus :

Select NetworkCardID from Audit_NetworkCard where
| 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) {...}
        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.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Freeradius-Users mailing list