X-Git-Url: http://git.rot13.org/?p=virtual-ldap;a=blobdiff_plain;f=lib%2FLDAP%2FKoha.pm;h=540d2783fdef3875e183e4e85cf4a8be1ac888e2;hp=c1acce5d675cb3aa1c7778f8a23d5a39462c8f8b;hb=455a72f2613cd8b182b03972cdd1160a40198dc6;hpb=baa13147ede9edae755288ab1a1f0779366b2dff diff --git a/lib/LDAP/Koha.pm b/lib/LDAP/Koha.pm index c1acce5..540d278 100644 --- a/lib/LDAP/Koha.pm +++ b/lib/LDAP/Koha.pm @@ -15,6 +15,8 @@ use File::Slurp; use Data::Dump qw/dump/; +my $debug = 0; # XXX very slow + # XXX test with: # # ldapsearch -h localhost -p 2389 -b dc=ffzg,dc=hr -x 'otherPager=200903160021' @@ -37,13 +39,11 @@ $SIG{__DIE__} = sub { require 'config.pl' if -e 'config.pl'; -my $dbh = DBI->connect($dsn . $database, $user,$passwd, { RaiseError => 1, AutoCommit => 1 }) || die $DBI::errstr; - # we need reverse LDAP -> SQL mapping for where clause my $ldap_sql_mapping = { 'uid' => 'userid', - 'objectGUID' => 'borrowernumber', + 'objectGUID' => 'b.borrowernumber', 'displayName' => 'surname', 'sn' => 'surname', 'pager' => 'a.attribute', # was: rfid_sid @@ -120,13 +120,13 @@ sub __ldap_search_to_sql { sub _dn_attributes { my ($row,$base) = @_; - warn "## row = ",dump( $row ); + warn "## row = ",dump( $row ) if $debug; die "no objectClass column in ",dump( $row ) unless defined $row->{objectClass}; $row->{objectClass} = [ split(/\s+/, $row->{objectClass}) ] if $row->{objectClass} =~ m{\n}; - warn "## row = ",dump( $row ); + warn "## row = ",dump( $row ) if $debug; my $dn = delete( $row->{dn} ) || die "no dn in ",dump( $row ); @@ -202,10 +202,11 @@ sub search { my $sql = $sql_select . $sql_where - . ( $objectclass =~ m{person}i ? " LIMIT $max_results" : '' ) # add limit just for persons +# . ( $objectclass =~ m{person}i ? " LIMIT $max_results" : '' ) # add limit just for persons ; warn "# SQL:\n$sql\n# DATA: ",dump( @values ); + my $dbh = DBI->connect_cached($dsn . $database, $user,$passwd, { RaiseError => 1, AutoCommit => 1 }) || die $DBI::errstr; my $sth = $dbh->prepare( $sql ); $sth->execute( @values );