sub authenticate { my ($id, $login, $pw) = @_; # %BIND contains connection info for multiple LDAP servers. return 0 if (! defined($BIND{$id})); my %CONFIG = %{ $BIND{$id} }; my $ldap = Net::LDAP->new($CONFIG{'host'}, port => $CONFIG{'port'}); return 0 if !$ldap; my $dn = sprintf('cn=%s,ou=people,dc=gwu,dc=edu,o=internet',$login); my $results = ($ldap->bind( $dn, password => $pw, version => 3 )); my $code = $results->code(); close_ldap($ldap); # 0 is a success, all others are failure return (! $code ? 1 : 0); }