Apache2-AuthZSympa

 view release on metacpan or  search on metacpan

lib/Apache2/AuthZSympa.pm  view on Meta::CPAN

    my $uid_filter = $r->dir_config('LDAPEmailFilter');
    my $attribute = $r->dir_config('LDAPEmailAttribute');
    my $scope = $r->dir_config('LDAPScope') || "sub";
    my $location = $r->location;
    my $ldap;
    unless($ldap = Net::LDAP->new($ldap_host)){
	$r->log_error("Apache2::AuthZSympa : $location, unable to create Net::LDAP object with $ldap_host"); 
	return "";
    }
    my $mesg; 
    unless($mesg = $ldap->bind){
	$r->log_error("Apache2::AuthZSympa : $location, unable to bind $ldap_host");
	return "";
    }
    my $filter = $uid_filter;
    $filter =~ s/\[uid\]/$user/;
    $mesg = $ldap->search( # perform a search
			   base   => $ldap_suffix,
			   scope => $scope,
			   attrs => [$attribute],
			   filter => $filter,
			   );
    my $nb_entries = $mesg->count;
    if(($nb_entries == 0) | ($nb_entries>1)){
	$r->log->notice("Apache2::AuthZSympa : $location, $nb_entries entries returned while querying $ldap_host, maybe wrong parameter ?"); 
	$ldap->unbind;
	return "";
    }
    my $entry = $mesg->entry(0);
    my $mail_user = $entry->get_value($attribute);
    $ldap->unbind;
    return $mail_user;
    
}
=head1 AUTHOR

Dominique Launay,Comite Reseau des Universites, C<< <dominique.launay AT cru.fr> >>


=head1 COPYRIGHT & LICENSE



( run in 4.119 seconds using v1.01-cache-2.11-cpan-2398b32b56e )