(RADIATOR) postauthhook for Block-Meg

Hugh Irvine hugh at open.com.au
Tue May 4 17:32:30 CDT 2004


Hello Stuart -

You don't need a hook for this, just extend the AuthSelect:

	AuthSelect select PASSWORD from SUBSCRIBERS \
		where USERNAME = '%n' \
		and MEGLEFT > 0

regards

Hugh


On 5 May 2004, at 03:08, Stuart wrote:

>
>
> 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'
>
>     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.
>
>

NB: have you included a copy of your configuration file (no secrets),
together with a trace 4 debug showing what is happening?

-- 
Radiator: the most portable, flexible and configurable RADIUS server
anywhere. Available on *NIX, *BSD, Windows, MacOS X.
-
Nets: internetwork inventory and management - graphical, extensible,
flexible with hardware, software, platform and database independence.
-
CATool: Private Certificate Authority for Unix and Unix-like systems.

--
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