On Thu, 11 Dec 2003, Graham Barr did scribble:
> Personally I think it is wrong for Net::LDAP to remember that. Also,
> its not very generic to re-use the same credentials, the referral could
> be to a different server that requires different credentials.
Hrmm...good point. I'm not sure that opportunity will present itself in our
systems...but I don't want to shoot myself in the foot by making such an
assumption. :-)
> My original plan to add referral handling into Net::LDAP, that never
> got implemented, was to allow the user to pass a sub ref to ->new that
> would be called to create any connection.
Alternatively, and perhaps a "cooler" way to do it would be to create a new
method that one could override. My particular subclass would have something
like this:
sub referral_connection {
my ($host, $port) = @_;
my $ldap = Net::LDAP->new($host,
port => $port,
chase_referrals => undef); # turn off
my @tls_options = sub_that_makes_tls_options($host, $port);
$ldap->start_tls(@tls_options);
my @bind_options = sub_that_makes_bind_options($host, $port);
$ldap->bind(@bind_options);
return $ldap;
}
Then, as you iterate over your referred urls, you need only do this:
foreach my $url ( @urls ) {
my ($host, $port) = split_up_url($url);
my $ldap = $ldap->referral_connection($host, $port);
# do stuff here...
}
Does that make sense? Sometimes I inadvertently make simple problems more
complex by over-solving them--I won't rule out that possibility here. :-)
__END__
Dan Kreft
Code Monkey <><
Infrastructure Tools & Automation
Amazon.com
One way to keep users off of your machine:
$ /usr/bin/env perl -e 'fork while 1'