help-gnu-radius
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-gnu-radius] problems getting rewrite hook right


From: Sergey Poznyakoff
Subject: Re: [Help-gnu-radius] problems getting rewrite hook right
Date: Thu, 02 Nov 2006 10:36:10 +0200

Charles Sprickman <address@hidden> wrote:

> This gets me what I want in the domain part of the query, but the
> username still comes up as "foo%foo.com".

I didn't know it should:) Than, the domain_split can be rewritten to
modify User-Name, as a side effect, like this:

string
domain_split(string name)
{
         integer a;
         string localpart;
         string domainpart;

         domainpart = "bway.net"; /* provide the default value */
         if (name =~ "\(.*\)@\(.*\)") {
                localpart = \1;
                domainpart = \2;
         } else {
                localpart = name;
         }

         if (localpart =~ "\(.*\)%\(.*\)") {
                localpart = \1;
                domainpart = \2;
         }
         %[User-Name] = localpart;
         return domainpart;
}

The test run gives:

** TEST SHELL **
(radiusd) source /home/gray/1.rw
0
(radiusd) r domain_split("username%domain.com")
domain.com
(radiusd) rp
    User-Name = (STRING) username
(radiusd) r domain_split("address@hidden")
domain.com
(radiusd) rp
    User-Name = (STRING) user
(radiusd) r domain_split("address@hidden")
domain.com
(radiusd) rp
    User-Name = (STRING) username
(radiusd) r domain_split("username")
bway.net
(radiusd) rp
    User-Name = (STRING) username


Regards,
Sergey
    




reply via email to

[Prev in Thread] Current Thread [Next in Thread]