variable string replace (i presume using UNLANG?)

Arran Cudbard-Bell a.cudbardb at gmail.com
Mon May 16 23:04:11 CEST 2011


You can use regular expression sub-captures.

if (User-Name =~ /^mppp%(.+)$/){
	update request {
		User-Name := "%{1}"
	}
}

Insert it before the call to the SQL module

-Arran


On May 16, 2011, at 1:58 PM, Steve Staples wrote:

> Hi all,
> 
> I am looking to replace a string, before sending the query off to sql...
> 
> right now, it is %{SQL-User-Name} (sql_user_name = "%{User-Name}"
> ), but the value is going to be like:
> mppp%sstaples at domain.com 
> 
> and i want to remove the mppp% (which will always be prefixed, or not
> exist) so that the variable only is
> sstaples at domain.com
> 
> Is that easy to do?  I have searched the docs, but came up empty (sorry
> if it has been discussed already... just didnt find it)
> 
> I could always write it in the query to replace the string:
> SELECT REPLACE('mppps%sstaples at domain.com', 'mppp%', '');
> but not sure if that is the most efficient way to do it?
> 
> Thanks in advance.
> 
> Steve.
> 
> -
> List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html

Arran Cudbard-Bell
RM-RF Limited - Security consultation and contracting
VoIP: +1 916-436-1352 Cell: +44 7854041841








More information about the Freeradius-Users mailing list