Stripping User-Names with Regular Expressions
Richard Cotrina
rcc at speedy.net.pe
Mon Aug 7 21:33:28 CEST 2006
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi :
I am trying to strip some sort of prefixes out of the usernames using
regular expressions in the hints file with no success in some cases. I have
two scenarios with prefixes, where usernames can be received in the
following form :
Case 1. KNOWN_PREFIX/user at mydomain.com
Case 2. KNOWN_PREFIX/RANDOM_STRING/user at mydomain.com
In any of those cases, the username must be stripped, and only
user at mydomain.com must be processed for AAA.
I am using the "hints" file with an entry with a regular expression like :
DEFAULT User-Name =~ "^(KNOWN_PREFIX/(.*/)?)+(.*@mydomain\.com)$"
User-Name := "%{3}",
Hint = "Stripped User-Name"
The problem I'm having is that entry only works in case username comes with
a form like case 2, I mean when username comes like
"KNOWN_PREFIX/RANDOM_STRING/user at mydomain.com", the regexp works very well.
But, when usernames comes as shown in Case 1
(KNOWN_PREFIX/user at mydomain.com), it gets a match in the hints, but username
referred as %{3} gets a void value ( shown in the debug as ' ' ).
It seems as if the conditional group "(.*/)?" in the regexp is causing
something wrong in the next group reference but I'm not sure. Is this kind
of regexp (the conditional one) supported in freeradius ?.
Any ideas of what could be wrong ? Thanks in advance for any help.
Best Regards
Richard Cotrina
-----BEGIN PGP SIGNATURE-----
Version: PGP Desktop 9.0.1 (Build 2185)
iQA/AwUBRNeVmSQekFb/3FIhEQKYrACgvwUuyHg8wbacV3WePMMDOiRDdi8AoNyF
JALaPXu58nrqskI/XLV2hp26
=Y3nH
-----END PGP SIGNATURE-----
More information about the Freeradius-Users
mailing list