Hello Mark -
This was discussed on the list recently - have a look at the archive site and
do a search:
http://www.starport.net/~radiator
The best approach is to define an AuthBy SQL with an Identifer, then look up
that AuthBy in your hook. The added advantage is that the connection is set up
for you and maintained automatically. You also get to use all of the utility
functions like "prepareAndExecute", etc.
Something like this:
<AuthBy SQL>
Identifier SQL_Tag_For_Hook
DBSource ....
DBUsername ....
DBAuth .....
.....
</AuthBy>
hth
Hugh
On Wed, 19 Jul 2000, Orcon Network Coordinator, Mark Mackay wrote:
> I've no doubt been coding messily to date - but am trying to tidy up and
> optimise our Radiator code.
>
> At the moment we (I) use code like: (as an excerpt from a Hook)
> ----------------------------------------------------------------------
> my $dbh = DBI->connect("DBI:mysql:xxxx:xxxxx","radius","xxxxxxx");
>
> my $query = $dbh->prepare("select visp, plannow from users where
> login='$USERNAME' ");
> $query->execute
>
> if (my @q1 = $query->fetchrow_array) {
> my $visp = @q1[0];
> my $plannow = @q1[1];
>
>
> if ( $visp eq "our.virtual.isp" ) {
> $reply->add_attr('PoolHint', "VISPPOOL");
> }
>
> if ( plannow eq "budget" ) {
> $reply->add_attr('PoolHint', "CHEAPPOOL");
> }
>
> }
>
> $query = "";
> $dbh->disconnect || warn $dbh->errstr;
>
> ----------------------------------------------------------------------
>
> This works, but is obviously very inefficient in terms of database connects,
> etc. Is there a way to connect in a Startup Hook and disconnect in a
> Shutdown Hook and then use this database object throughout all our hooks
> (there's about 5 of them which use database lookups) ?
>
> [Forgive the question if it's simple -- i'm not that up to the play with
> perl object handling, and tend to be a code-duplicator and refiner]
>
>
>
> Also -- is there a "programmers" guide (wishlist!) on how to programme
> within Hooks? [or do bits of the "addingcustom AuthBy modules" apply - and
> if so which bits?]
>
>
> .........................................................................
>
> Mark Mackay,
> Network Coordinator,
> Orcon Internet.
>
>
> ===
> Archive at http://www.starport.net/~radiator/
> Announcements on [EMAIL PROTECTED]
> To unsubscribe, email '[EMAIL PROTECTED]' with
> 'unsubscribe radiator' in the body of the message.
--
Radiator: the most portable, flexible and configurable RADIUS server
anywhere. SQL, proxy, DBM, files, LDAP, NIS+, password, NT, Emerald,
Platypus, Freeside, Interbiller, TACACS+, PAM, external, etc, etc.
Available on Unix, Linux, FreeBSD, Windows 95/98/2000, NT, MacOS X.
===
Archive at http://www.starport.net/~radiator/
Announcements on [EMAIL PROTECTED]
To unsubscribe, email '[EMAIL PROTECTED]' with
'unsubscribe radiator' in the body of the message.