Hi team, I have some question about unlang. How can I modify attribute? Example: I have attribute (&User-Name = "94de80658a92") its mac address, I will check this mac address in DB, but format must be like (&User-Name = "94:de:80:65:8a:92"), how format existing attribute or create new with needed format? Sincerely, Artem Moskalev.
On 18/02/2022 07:09, Москалев Артем Сергеевич wrote:
I have some question about unlang. How can I modify attribute? Example: I have attribute (&User-Name = "94de80658a92") its mac address, I will check this mac address in DB, but format must be like (&User-Name = "94:de:80:65:8a:92"), how format existing attribute or create new with needed format?
There is a policy "rewrite_calling_station_id" which nearly does that already - see raddb/policies.d/canonicalization Copy that to e.g. rewrite_user_name_mac and change it to use User-Name, and to use ':'s instead of '-'s, then call it from your authorize{} section. If you don't want to change User-Name, add your own attribute to raddb/dictionary and alter the update to use that instead. -- Matthew
Thanks a lot, what i need!
-----Original Message----- From: Freeradius-Users [mailto:freeradius-users- bounces+moskalevas=energomera.ru@lists.freeradius.org] On Behalf Of Matthew Newton Sent: Friday, February 18, 2022 2:03 PM To: freeradius-users@lists.freeradius.org Subject: Re: unlang modify attribute
On 18/02/2022 07:09, Москалев Артем Сергеевич wrote:
I have some question about unlang. How can I modify attribute? Example: I have attribute (&User-Name = "94de80658a92") its mac address, I will check this mac address in DB, but format must be like (&User-Name = "94:de:80:65:8a:92"), how format existing attribute or create new with needed format?
There is a policy "rewrite_calling_station_id" which nearly does that already - see raddb/policies.d/canonicalization
Copy that to e.g. rewrite_user_name_mac and change it to use User-Name, and to use ':'s instead of '-'s, then call it from your authorize{} section.
If you don't want to change User-Name, add your own attribute to raddb/dictionary and alter the update to use that instead.
-- Matthew - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
participants (3)
-
Matthew Newton -
Москалев Артем Сергееви ч -
Москалев Артем Сергеевич