(RADIATOR) Rewriting Usernames on the Fly

Hugh Irvine hugh at open.com.au
Tue Oct 23 01:31:28 CDT 2001


Hello Martin -

Why don't you just use two AuthBy SQL clauses with different AuthSelect 
statements?

# define AuthBy SQL statements

<AuthBy SQL>
	Identifier CheckNewUserName
	.....
	AuthSelect select password from \
		serviceuser where id_user = '%n'
	AuthColumnDef 0, Password, check
	.....
</AuthBy>

<AuthBy SQL>
	Identifier CheckOldUserName
	.....
	AuthSelect select password from \
		serviceuser where id_alternate = '%n'
	AuthColumnDef 0, Password, check
	.....
</AuthBy>

......

# define Realms or Handlers

<Realm ....>
	AuthByPolicy ContinueUntilAccept
	AuthBy CheckNewUserName
	AuthBy CheckOldUserName
	.....
</Realm>


hth

Hugh


On Tuesday 23 October 2001 11:59, Martin Edge wrote:
> Hey,
>
> I'm having a few issues working with hooks within Radiator.
>
> I'm trying to use a PreProcessing Hook, to modify the username of a user
> as they come in. It appears to grab the right data, but when I change
> the attribute, it doesn't appear to affect the username that is used to
> process.
>
> Is there another attribute or command I have to use to change the
> username of a user?
>
> The basic jist is, we are moving customers from they old usernames, to
> new ones, in a new billing system, and I want to be able to detect that
> they aren't using a normal username, use the one they entered to look
> for a new one, and then set the new one, to it.
>
> Any help would be appreciated, but I feel I'm probably just missing
> something and this is simpler than it looks..
>
> My code is below for the hook:
>
> sub
> {
>         my $p = ${$_[0]};
>         my $rp = ${$_[1]};
>
>         my $username = $p->get_attr('User-Name');
>
>         if ($username) {
>                 if (!grep(/^[a-z][a-z][a-z][0-9][0-9][0-9][0-9][0-9].*/,
> $username)) {
>                         &main::log($main::LOG_DEBUG, "This isn't a
> standard username, grabbing alternate");
>                         my $user = "weee";
>                         my $pwd = "bssss00";
>
>                         my $dbh =
> DBI->connect("dbi:Sybase:server=secure-nike.izone.net.au;database=nb9901
> ", $user, $pwd);
>
>                         my $sth = $dbh->prepare("select id_user from
> serviceuser where id_alternate = '$username'");
>                         my $error = $sth->execute;
>                         my @results = $sth->fetch;
>
>                         #&main::log($main::LOG_DEBUG, "select id_user
> from serviceuser where id_alternate = '$username'");
>                         #&main::log($main::LOG_DEBUG, "my alternative
> username $username translates to $results[0]->[0]");
>
>                         # Find the new username
>                         $p->change_attr('User-Name', $results[0]->[0]);
>
>                 }
>         }
>
>     return;
> }
>
>
> -----------------------------------------
> Martin Edge
> Network Engineer
> Phoneware Online
> eMail: Martin.Edge at phoneware.net.au
> Phone: +613 9640 4140 ext. 193
>
> "Creating the structure necessary for your
> business internet requirements"
> -----------------------------------------
> ===
> 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.

-- 
Radiator: the most portable, flexible and configurable RADIUS server
anywhere. Available on *NIX, *BSD, Windows 95/98/2000, NT, MacOS X.
-
Nets: internetwork inventory and management - graphical, extensible,
flexible with hardware, software, platform and database independence.
===
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