(RADIATOR) postauthhook for Block-Meg
Toomas Kärner
tomkar at estpak.ee
Wed May 5 00:00:52 CDT 2004
Hi
Look at the query below, I edited it.
Rgds.
Toomas
----- Original Message -----
From: "Stuart" <elmhurst at spacelink.com.au>
To: <radiator at open.com.au>
Sent: Tuesday, May 04, 2004 8:08 PM
Subject: (RADIATOR) postauthhook for Block-Meg
>
>
> Where can I find a postauthhook example that rejects a user that has has
> used up all their megabytes. I don't necessarily need to drop the users
> session if their meg bank is <= 0 but I need radiator to reject them if
the
> bank is all used up. I tried modifying the time bank instructions to no
> avail.
>
> See Below
>
>
> <AuthBy SQL>
>
> Identifier Block-Meg-SQL
>
> DBSource %{GlobalVar:SQLServer1}
> DBUsername %{GlobalVar:SQLUser1}
> DBAuth %{GlobalVar:SQLAuth1}
>
> AuthSelect MEGLEFT from subscribers \
> where USERNAME='%n' and meg_account > 0
>
> AcctSQLStatement update subscribers set \
> MEGLEFT=MEGLEFT-((0%{Acct-Input-Octets}/1000)/1000) \
> where USERNAME='%n'
>
> </AuthBy>
>
>
> Here is the hook code:
>
> # -*- mode: Perl -*-
> # CheckBlockMegLeft
> #
> # PostAuthHook to check Meg left for a block user
> #
>
> sub
> {
> my $p = ${$_[0]};
> my $rp = ${$_[1]};
> my $result = ${$_[2]};
>
> my $name = $p->get_attr('User-Name');
> my $timeout = $rp->get_attr('???????????????);
>
> if (($result == $main::ACCEPT) && ($megleft <= 0))
> {
> &main::log($main::LOG_DEBUG, "User $name has no megabytes left");
> ${$_[2]} = $main::REJECT;
> }
> return;
> }
>
>
> And here is an example Realm:
>
> # example Realm showing the use of a PostAuthHook
> # the file containing the hook code is installed in DbDir
>
> <Realm .....>
>
> AuthByPolicy ContinueWhileAccept
>
> # your normal AuthBy(s)
> AuthBy ........
> .........
> AuthBy Block-Meg-SQL
>
> PostAuthHook file"%D/CheckBlockMegLeft"
>
> </Realm>
>
>
>
>
>
> Regards
>
> Scott Craig
>
> --
> Archive at http://www.open.com.au/archives/radiator/
> Announcements on radiator-announce at open.com.au
> To unsubscribe, email 'majordomo at open.com.au' with
> 'unsubscribe radiator' in the body of the message.
--
Archive at http://www.open.com.au/archives/radiator/
Announcements on radiator-announce at open.com.au
To unsubscribe, email 'majordomo at open.com.au' with
'unsubscribe radiator' in the body of the message.
More information about the radiator
mailing list