X-Git-Url: http://git.rot13.org/?p=virtual-ldap;a=blobdiff_plain;f=lib%2FLDAP%2FKoha.pm;h=563c9685af5991c2c87c6bf73e19354ff039df5f;hp=28d0868a3810f2268d6ce4c382f4edf497e2f1c4;hb=ba8dc579a3496f2785ca5bc12cb291c1d489dc73;hpb=571831397e4527af51bcd971cbdf1e17f9807cb8 diff --git a/lib/LDAP/Koha.pm b/lib/LDAP/Koha.pm index 28d0868..563c968 100644 --- a/lib/LDAP/Koha.pm +++ b/lib/LDAP/Koha.pm @@ -39,16 +39,14 @@ $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 + 'pager' => qq{replace(a.attribute, '\r','')}, # was: rfid_sid }; sub __sql_column { @@ -208,6 +206,7 @@ sub search { ; 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 ); @@ -220,13 +219,13 @@ sub search { my ( $dn, $attributes ) = _dn_attributes( $row, $base ); - warn "# dn $last_dn ... $dn\n"; + warn "## dn $last_dn ... $dn\n" if $debug; if ( $dn ne $last_dn ) { if ( $entry ) { #$entry->changetype( 'modify' ); - warn "### entry ",$entry->dump( \*STDERR ); + warn "### entry ",$entry->dump( \*STDERR ) if $debug; push @entries, $entry; undef $entry; } @@ -241,7 +240,7 @@ sub search { } else { foreach my $n ( keys %$attributes ) { my $v = $attributes->{$n}; - warn "# attr $n = $v\n"; + warn "## attr $n = $v\n" if $debug; $entry->add( $n, $v ) if $entry->get_value( $n ) ne $v; } } @@ -252,7 +251,7 @@ sub search { } if ( $entry ) { - warn "### last entry ",$entry->dump( \*STDERR ); + warn "### last entry ",$entry->dump( \*STDERR ) if $debug; push @entries, $entry; }