[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freeradius-users
Subject:    Re: conditional attribute rewrite.
From:       Alan DeKok <aland () deployingradius ! com>
Date:       2020-12-09 14:18:26
Message-ID: 1C9B132D-FA42-41AD-92E8-E31590945D86 () deployingradius ! com
[Download RAW message or body]

On Dec 9, 2020, at 8:42 AM, Benedikt Sveinsson <benedikts@vodafone.is> 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.


-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic