Translate characters
Hello dear Freeradius friends! Im authenticating users by NAS-Port-Id by following format: ”1/1/4:1001.129”. In the scenario im using Service Router --> Freeradius --> Cisco ACS --> Active Directory. The problem is that Active directory cannot use “/” and “:” in the logon filed of the user when im trying to authenticate users. Is there anything I can do in the freeradius to change the characters to different ones? Example: To make “/” as “-“ and “:” as “_”. So the NAS-Port-ID would look like “1-1-4_1001.129” instead. Is it possible to translate characters in Freeradius? If possible, how do i make it? Best regards, Badstuber. -- View this message in context: http://freeradius.1045715.n5.nabble.com/Translate-characters-tp5685645.html Sent from the FreeRadius - User mailing list archive at Nabble.com.
Xbert_badstuber wrote:
Is there anything I can do in the freeradius to change the characters to different ones? Example: To make “/” as “-“ and “:” as “_”. So the NAS-Port-ID would look like “1-1-4_1001.129” instead. Is it possible to translate characters in Freeradius? If possible, how do i make it?
You can't translate the characters, but you can re-write the attribute. I'd use a regex: if (NAS-Port-Id =~ /^(.)/(.)/(.):(.*)$/) { update request { NAS-Port-Id := "%1_%2_%3_%4" } } You may have to play with the regex to get it to match your exact case, but the idea is there. Alan DeKok.
Thanks Alan for the quick and helpful answer. I have just one problem now, in which .conf file should I write/place the regex? I have tried some files, but none of them have change the Nas-port-id value. I have try to place it in modules --> attr_rewrite, proxy.conf, sites-available --> default. -- View this message in context: http://freeradius.1045715.n5.nabble.com/Translate-characters-tp5685645p56906... Sent from the FreeRadius - User mailing list archive at Nabble.com.
On Mon, May 7, 2012 at 4:52 PM, Xbert_badstuber <lijo09jj@gmail.com> wrote:
Thanks Alan for the quick and helpful answer. I have just one problem now, in which .conf file should I write/place the regex? I have tried some files, but none of them have change the Nas-port-id value. I have try to place it in modules --> attr_rewrite, proxy.conf, sites-available --> default.
sites-available/default, and also possibly sites-available/innert-tunnel, authorize section. Also run "man unlang" to get the basic idea of how unlang works, and where you can use it. -- Fajar
I followed your advice by configure both the files, default and inner tunnel. Unfortunally, a fail comes with a restart of the service. This is what the log tells us: Error: Consecutive conditions at (.)/(.):(.*)$/) Error: /etc/freeradius/sites-enabled/inner-tunnel[47]: Errors parsing authorize section. Error: Failed to load virtual server inner-tunnel This it what i put in the availabile-sites/default under the authorize section: preprocess if (NAS-Port-Id =~ /^(.)/(.)/(.):(.*)$/) { update request { NAS-Port-Id := "%1_%2_%3_%4" } } And this is what i put in the availabile-site/inner-tunnel, under the authorize section: if (NAS-Port-Id =~ /^(.)/(.)/(.):(.*)$/) { update request { NAS-Port-Id := "%1_%2_%3_%4" } } Any ideas? Regards, Badstuber. -- View this message in context: http://freeradius.1045715.n5.nabble.com/Translate-characters-tp5685645p56909... Sent from the FreeRadius - User mailing list archive at Nabble.com.
Now it works, I can change the attribute to a static value. Unfortunately now I wasn't all clear in my first topic. My question is if there is any solution for the characters to be changed, just characters, not the nummbers (value). In our senario we have many differents clients and they are accessing our Freeradius server with different NAS-Port-Id. We want the values to be dynamic and the characters to be static. Exampel: We have 3 clients that accessing our Freeradius: Client1: Before Freeradius server NAS-Port-Id = 1/1/4:1001.129 and after Freeradius server NAS-Port-Id = 1_1_4-1001.129. Client2: Before Freeradius server NAS-Port-Id = 1/1/5:1001.130 and after Freeradius server NAS-Port-Id = 1_1_5-1001.130. Client3: Before Freeradius server NAS-Port-Id = 1/1/6:1001.131 and after Freeradius server NAS-Port-Id = 1_1_6-1001.131. I want the value of the NAS-Port-ID to be dynamic and the characters to remain static. Is there any solution for our problem? -- View this message in context: http://freeradius.1045715.n5.nabble.com/Translate-characters-tp5685645p56911... Sent from the FreeRadius - User mailing list archive at Nabble.com.
its REGEX - you can do whatever you want with the right search/replace functions. I would advise that you do some reading up of REGEX - plenty of free resources on the web and a few good books from the usual publishers. alan
Now everything works just fine! I guess i had some missunderstanding with REGEX. After a long time reading it finaly works precisely as i want. Thanks for your answers! Regards your friend, Badstuber Stubblebine. -- View this message in context: http://freeradius.1045715.n5.nabble.com/Translate-characters-tp5685645p56941... Sent from the FreeRadius - User mailing list archive at Nabble.com.
Xbert_badstuber wrote:
Now it works, I can change the attribute to a static value.
Uh... no. The attribute can use the results of the regex. See "man unlang".
Unfortunately now I wasn't all clear in my first topic. My question is if there is any solution for the characters to be changed, just characters, not the nummbers (value).
My answer showed how to do that.
In our senario we have many differents clients and they are accessing our Freeradius server with different NAS-Port-Id. We want the values to be dynamic and the characters to be static.
My example showed how to do that.
Is there any solution for our problem?
Read my messages. Alan DeKok.
participants (4)
-
Alan Buxey -
Alan DeKok -
Fajar A. Nugraha -
Xbert_badstuber