"switch" statement": would you know a more compact statement?

Alan DeKok aland at deployingradius.com
Wed Apr 26 15:30:36 UTC 2023


On Apr 26, 2023, at 11:03 AM, Alex Zetaeffesse <fzetafs at gmail.com> wrote:
> Is there a more compact way to state what follows?
> 
>        switch {
>                ("%{User-Name}" =~ /@tenant101\.bic\.local/) {update
> control{Proxy-To-Realm := "tenant101"}

  That's not correct configuration syntax, but OK...

  In general things like this are best done with regular expressions.  Especially if the data you're trying to use is part of the input packet.

	if (&User-Name =~ /([^.]+)\.bic\.local) {
		update control {
			&Proxy-To-Realm := "%{1}"
		}
	}

  You also don't have to put quotes around references to User-Name.  Just use &User-Name.  This works, and that's what the documentation says to do.  I have no idea why so many people use constructs like "%{User-Name}".  It's just not necessary.

  Alan DeKok.



More information about the Freeradius-Users mailing list