string formatting unlang

Christian Salway christian.salway at naimuri.com
Wed Nov 14 18:06:15 CET 2018


Worked it out.. I added exec to the variable to send it to a bash file to be rewritten

        foreach &reply:memberOf {
            update reply {
                Class += "%{exec:/etc/raddb/rewrite-dn.sh %{Foreach-Variable-0}}"
            }
	}


and set wait = yes in mods-enabled/exec

Then in rewrite-dn.sh I have

#!/bin/bash
echo "${1}" |sed  's/,/\\/g'


> On 14 Nov 2018, at 16:42, Christian Salway <christian.salway at naimuri.com> wrote:
> 
> I have the following 'update reply'
> 
>         foreach &reply:memberOf {
>             update reply {
>                 Class += "%{Foreach-Variable-0}"
>             }
>         }
> 
> which adds a list of groups from active directory as distinguished names 
> 
> eg. CN=pod-admin,OU=Groups,OU=directory,DC=directory,DC=local
> 
> but I need it to add to Class as 
> 
> CN=pod-admin/OU=Groups/OU=directory/DC=directory/DC=local
> 
> Is there anyway to do this?
> 
> I was thinking of maybe passing it to a module that would rewrite it
> 
> "%{module: Foreach-Variable-0}"
> 
> but no idea how to do that.
> 



More information about the Freeradius-Users mailing list