Edit User-Name based on regex

Hermann.Lauer at uni-heidelberg.de Hermann.Lauer at uni-heidelberg.de
Tue Mar 28 07:32:39 UTC 2023


On Mon, Mar 27, 2023 at 12:10:26PM +0000, ANGEL LUIS MATEO MARTINEZ wrote:
> I'm stuck trying to remove the ":" chars from the string.

try something like:

if ( &Calling-Station-Id =~ /^([0-9a-f]{2})-([0-9a-f]{2})-([0-9a-f]{2})-([0-9a-f]{2})-([0-9a-f]{2})-([0-9a-f]{2})$/i )

newusername = "%{1}:%{2}:%{3}:%{4}:%{5}:%{6}"

> The example in the docs for regex is a username comparison (first google hit), and there are many examples all over stackexchange of mac address regexes.

And yes, it's often used.

Greetings
  Hermann

> Are you stuck on where to do the username comparison, or how to remove the :'s from
> the string or ?
> 
> > On Mar 27, 2023, at 6:20 AM, ANGEL LUIS MATEO MARTINEZ <amateo at um.es> wrote:
> >
> > Hello,
> >
> > I have a scenario where I need to modify User-Name, before any AAA operation, based on a regex substitution. To be precise, the users are sending a MAC as the username, in the form "00:11:22:33:44:55" and I need to transform this to "001122334455".
> >
> > This may be a silly question, but I haven't found how to do it. Is there any way to do it? Thank you.
> >
> > --
> > Angel L. Mateo Martínez
> > Sección de Telemática
> > Área de Tecnologías de la Información y las Comunicaciones Aplicadas (ATICA)
> > http://www.um.es/atica
> > Tfo: 868889150
> > Fax: 868888337
> > -
> > List info/subscribe/unsubscribe? See https://urldefense.com/v3/__http://www.freeradius.org/list/users.html__;!!D9dNQwwGXtA!Xr5epC919PJ55w6WC1AdBxPDGfz71FqM9WDVi2HBc9YClMYN_QuOL6OoDGefZA_wIX36oahF6Iz5JlNRNg$
> 
> -
> List info/subscribe/unsubscribe? See https://urldefense.com/v3/__http://www.freeradius.org/list/users.html__;!!D9dNQwwGXtA!Xr5epC919PJ55w6WC1AdBxPDGfz71FqM9WDVi2HBc9YClMYN_QuOL6OoDGefZA_wIX36oahF6Iz5JlNRNg$

-- 
Administration/Zentrale Dienste, Interdiziplinaeres 
Zentrum fuer wissenschaftliches Rechnen der Universitaet Heidelberg
IWR; INF 205; 69120 Heidelberg; Tel: (06221)54-14405 Fax: -14427
Email: Hermann.Lauer at iwr.uni-heidelberg.de


More information about the Freeradius-Users mailing list