Hello Requiem -
On Wed, 22 Sep 1999, [EMAIL PROTECTED] wrote:
> Hello
>
> In my PostAuthHook function, i need to get the
> framed-ip-address that will be sent to the user.
>
> The first line below works perfectly
> my $username = $p->getAttrByNum($Radius::Radius::USER_NAME);
> but the second doesn't want to works.
> my $ipaddress = $p->getAttrByNum($Radius::Radius::FRAMED_IP_ADDRESS);
>
> Note:
> $p = ${$_[0]}; # At the begining of my PostAuthHook function
>
> When i look the debug file i can see
> ...
> CCode: Access-Accept
> Identifier: 250
> Authentic: 1234567890123456
> Attributes:
> Framed-IP-Address = 10.1.0.16
> Service-Type = Framed-User
>
> So How can i Get the ip address (10.1.0.16) in a PostAuthHook Function ?
>
Please have a look at Sections 6.13.10 and 6.13.11 in the Radiator 2.14.1
reference manual:
6.13.10 PreAuthHook
This optional parameter allows you to define a Perl function that will be called
during
packet processing. PreAuthHook is called for each request after per-Realm
username rewriting and before it is passed to any AuthBy clauses. A reference
to the current request is passed as the first argument, and a reference to the
reply packet currently being constructed is passed as the second argument.
The hook code is compiled by Perl when Radiator starts up. Compilation errors in your
hook
code will be reported to the log file at start-up time. Runtime errors in your
hook will also be reported to the log file when your hook executes. Multiline
hooks (i.e. with trailing backslashes (\)) are parsed by Radiator into one long
line. Therefore you should not use trailing comments in your hook.
PreAuthHook Can be an arbitrarily complicated Perl function, that might run external
processes, consult databases, change the contents of the current request or
many other things.
# Fake a new attribute into the request
PreAuthHook sub { ${$_[0]}->add_attr(`test-attr', \
`test-value');}
6.13.11 PostAuthHook
This optional parameter allows you to define a Perl function that will be called
during
packet processing. PostAuthHook is called for each request after it has been
passed to all the AuthBy clauses. A reference to the current request is passed
as the first argument, and a reference to the reply packet currently being
constructed is passed as the second argument. The third argument is the result
of the authentication ($main::ACCEPT, $main::REJECT etc.).
The hook code is compiled by Perl when Radiator starts up. Compilation errors in
your hook code will be reported to the log file at start-up time. Runtime
errors in your hook will also be reported to the log file when your hook
executes. Multiline hooks (i.e. with trailing backslashes (\)) are parsed by
Radiator into one long line. Therefore you should not use trailing comments in
your hook.
PostAuthHook Can be an arbitrarily complicated Perl function, that might run external
processes, consult databases, change the contents of the current request or
many other things.
# Add some reply attributes to the reply message
# if it is a REJECT and there is 1 or fewer there already
PostAuthHook sub { ${$_[1]}->add_attr(`test-attr', \
`test-value') \
if ${$_[2]} == $main::REJECT \
&& ${$_[1]}->attr_count() <= 1; }
Notice that the information you are looking for is in the reply packet (as seen
from the debug output). Therefore you need to use ${$_[1]} to reference the
second parameter passed to the hook (the reply packet).
hth
Hugh
--
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.