in reply to Active Directory authentication using login name
sub checkPassword { # no parens () here - why a prototype? my ($user,$password) = @_; my $ldap = Net::LDAP->new( $LDAPServerAddress, port => '636', scheme => 'ldaps' ) or die "Can't connect to $LDAPServerAddress via LDAP"; # not || my $result = $ldap->bind( $user, password => $password ) or die "Can't bind!\n"; # $@ is set by eval if ($result->code) { die $result->error; } 1; }
You should make up your mind whether you want to die() on errors and wrap the call into a block eval, or return strings on error and nothing on error, in wich case the function name is a bit misleading if used in boolean context, e.g.
You coul also avoid the die(), setting $@ and returning nothing on failure, and returning 1 on success - that's what I would do.if ( checkPassword($user,$pass) ) { # success or failure here? } else { ... }
--shmem
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
|
|---|