conditional attribute rewrite.

Alan DeKok aland at
Wed Dec 9 15:18:26 CET 2020

On Dec 9, 2020, at 8:42 AM, Benedikt Sveinsson <benedikts at> wrote:
> Can I use Conditional Expressions in the attrs file ? I did try but perhaps I gave up to easily.

  You can't.

> Or is there a more modern way of doing this.

  Just use if / then / else

  	if (User-Name == "bob") {
		update reply {
			Reply-Message := "Hello, bob!"

  Look at the debug log to see what the NAS is sending.  Then, write "if" conditions to match that.  And inside of the "if" conditions, put "update" blocks which return the attributes you want.

  It really is that simple.

  The main thing is to write down the if / then / else conditions *before* trying to poke the server config.  That way you know exactly what you want it to do.  All you need then is to get the right syntax in the configuration files.

  People run into issues when they say "I want FreeRADIUS to do stuff", but they don't have a clear picture of what "stuff" means.  "You know, when something happens, I want it to do something!"

  If you write down the rules in plain English, they can be easily transformed into "unlang" statements.  If you have no idea what the rules are in English, it's impossible to write a server configuration which implements those rules.

  Alan DeKok.

More information about the Freeradius-Users mailing list