X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;ds=sidebyside;f=lib%2FLDAP%2FKoha.pm;h=563c9685af5991c2c87c6bf73e19354ff039df5f;hb=8d4f1b042a6168d3423dc2edc7ea79d2cee7d4fb;hp=b0c726c6b815618f99a87d4dc40ce568f42f5bf7;hpb=2976b06f151c8fceb0fe00c1046a287f72998fd9;p=virtual-ldap diff --git a/lib/LDAP/Koha.pm b/lib/LDAP/Koha.pm index b0c726c..563c968 100644 --- a/lib/LDAP/Koha.pm +++ b/lib/LDAP/Koha.pm @@ -39,8 +39,6 @@ $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 = { @@ -48,7 +46,7 @@ my $ldap_sql_mapping = { '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; }