--- lib/LDAP/Koha.pm 2009/04/29 09:18:11 51 +++ lib/LDAP/Koha.pm 2009/09/15 13:10:13 58 @@ -25,7 +25,7 @@ our $user = 'unconfigured-user'; our $passwd = 'unconfigured-password'; -our $max_results = 3000; # FIXME must be enough for all users +our $max_results = $ENV{MAX_RESULTS} || 3000; # FIXME must be enough for all users our $objectclass_default = 'hrEduPerson'; our $objectclass; @@ -131,12 +131,12 @@ my $dn = delete( $row->{dn} ) || die "no dn in ",dump( $row ); # this does some sanity cleanup for our data - my $base_as_domain = $base; - $base_as_domain =~ s{dn=}{.}; - $base_as_domain =~ s{^\.}{@}; - $dn =~ s{$base_as_domain$}{}; - - $dn .= ',' . $base unless $dn =~ m{,}; # add base if none present +# my $base_as_domain = $base; +# $base_as_domain =~ s{dn=}{.}; +# $base_as_domain =~ s{^\.}{@}; +# $dn =~ s{$base_as_domain$}{}; +# +# $dn .= ',' . $base unless $dn =~ m{,}; # add base if none present return ($dn, $row); } @@ -199,8 +199,14 @@ } - warn "# SQL:\n$sql_select\n", $sql_where ? $sql_where : '-- no where', "\n# DATA: ",dump( @values ); - my $sth = $dbh->prepare( $sql_select . $sql_where . " LIMIT $max_results" ); # XXX remove limit? + my $sql + = $sql_select + . $sql_where + . ( $objectclass =~ m{person}i ? " LIMIT $max_results" : '' ) # add limit just for persons + ; + + warn "# SQL:\n$sql\n# DATA: ",dump( @values ); + my $sth = $dbh->prepare( $sql ); $sth->execute( @values ); warn "# ", $sth->rows, " results for ",dump( $reqData->{'filter'} ); @@ -223,6 +229,8 @@ undef $entry; } + $dn =~ s{@[^,]+}{}; + $entry = Net::LDAP::Entry->new; $entry->dn( $dn ); @@ -241,8 +249,10 @@ } - warn "### last entry ",$entry->dump( \*STDERR ); - push @entries, $entry; + if ( $entry ) { + warn "### last entry ",$entry->dump( \*STDERR ); + push @entries, $entry; + } } else { warn "UNKNOWN request: ",dump( $reqData );