Hello Fabrizio,

On Jul 23, 10:16am, Fabrizio Cuseo wrote:
> Subject: (RADIATOR) Hook question
> I'm trying to customize radiator for my needs, but I need to do some
> complex operations (more than one query during auth process, evaluate a lot
> of conditions during auth, customize Replies with "No more time left" or
> "Account expired" or "Port not allowed" or other messages).
> I've done some of theese things with PostAuthHook, but i neet to know the
> content of my userbase (i'm using mysql).
>
> For example...
>
>
> PostAuthHook sub { my $tipo_richiesto = ${$_[0]}->get_attr('Service-Type'); \
>                    my $tipo_utente = USER-SERVICE-TYPE-ON-DATABASE; \
>                 if ($tipo_utente != $tipo_richiesto) { \
>   ${$_[1]}->add_attr('Reply-Message' , 'Type of service not allowed for
> this user'; }}
>

So you want to be able to issue SQL queries from inside your hook?

The easiest was is to get Radiator to do most of the hard work with talking to
the database. You define a top level AuthBy SQL, and then use its built-in SQL
handling to do the work for you:

Make a top level AuthBy SQL configured to connect to yuor mysql dtabase:

<AuthBy SQL>
        Identifer       fred
        DBSource dbi:mysql:whatever
        ....
</AuthBy>

and in your hook:

my $sql = Radius::AuthGeneric::find('fred'); # get a handle to the AuthBy SQL
my $sth = $sql->prepareAndExecute('select a,b from y where z'); # some SQL
while (($a, $b) = $sth->fetchrow())
{
        # $a and $b are set from the results of your SQL query
}



Hope that helps,.

Cheers.


>
> Regards, Fabrizio Cuseo
>
>         --------------------------------------------------
>         Fabrizio Cuseo - [EMAIL PROTECTED]
>         Respons. commerciale - Panservice InterNetWorking
>         Phone: +39 0773 410020 fax: +39 0773 410020
>         --------------------------------------------------
>
> ===
> Archive at http://www.thesite.com.au/~radiator/
> To unsubscribe, email '[EMAIL PROTECTED]' with
> 'unsubscribe radiator' in the body of the message.
>-- End of excerpt from Fabrizio Cuseo



-- 
Mike McCauley                               [EMAIL PROTECTED]
Open System Consultants Pty. Ltd            Unix, Perl, Motif, C++, WWW
24 Bateman St Hampton, VIC 3188 Australia   http://www.open.com.au
Phone +61 3 9598-0985                       Fax   +61 3 9598-0955

Radiator: the most portable, flexible and configurable RADIUS server 
anywhere. SQL, proxy, DBM, files, LDAP, NIS+, password, NT, Emerald, 
Platypus, Freeside, TACACS+, PAM, external, etc etc on Unix, Win95/8, 
NT, Rhapsody
===
Archive at http://www.thesite.com.au/~radiator/
To unsubscribe, email '[EMAIL PROTECTED]' with
'unsubscribe radiator' in the body of the message.

Reply via email to