Variables usage and %explode function
Ted S.
tec_ted88 at outlook.com
Wed Mar 6 10:25:04 UTC 2024
Hello,
im using freeradius 3.2. I want extract from the TLS-Client-Cert-Common-Name only the Hostname and strip off the fqdn part and update
the User-Name for further processings. I found the split string function with %explode in the documentation.
I dont get it working, i tried following 2 variants:
Variant 1 with variables:
i tried using temp variables for conversion and used the "local variables" example from the documentation. I read that there variables only can be used in: "One
of case, else, elsif, foreach, group, if ,limit, or timeout. Local variables are forbidden in all other locations." So i build a dummy "if" for that.
if ("1"=="1") {
string TmpString1
&TmpString1 := "%explode(%{TLS-Client-Cert-Common-Name}, '.')"
&User-Name := "%{TmpString1[0]}$"
}
-> Error Log on Radiusd -X:
/etc/raddb/sites-enabled/check-eap-tls[105]: Expecting section start brace '{' after "string TmpString1"
-> the declaration looks like the example but what im doing wrong?
Variant 2 without helping variables, in one line:
update request {
&User-Name := "%explode(%{TLS-Client-Cert-Common-Name}, '.')[0]"
}
-> Log:
(10) update request {
(10) EXPAND %explode(%{TLS-Client-Cert-Common-Name}, '.')[0]
(10) --> 1xplode(testclient.prod.company.net, '.')[0]
(10) &User-Name := 1xplode(testclient.prod.company.net, '.')[0]
(10) } # update request = noop
Can someone helping me, getting one of both variants working? Im also not sure if i can use [0] in the variant 2.
many thanks and regards,
Ted
More information about the Freeradius-Users
mailing list