/[virtual-ldap]/lib/LDAP/Koha.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /lib/LDAP/Koha.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 62 by dpavlin, Thu Feb 18 16:22:32 2010 UTC revision 88 by dpavlin, Sun May 2 19:29:45 2010 UTC
# Line 39  $SIG{__DIE__} = sub { Line 39  $SIG{__DIE__} = sub {
39    
40  require 'config.pl' if -e 'config.pl';  require 'config.pl' if -e 'config.pl';
41    
 my $dbh = DBI->connect($dsn . $database, $user,$passwd, { RaiseError => 1, AutoCommit => 1 }) || die $DBI::errstr;  
   
42  # we need reverse LDAP -> SQL mapping for where clause  # we need reverse LDAP -> SQL mapping for where clause
43    
44  my $ldap_sql_mapping = {  my $ldap_sql_mapping = {
45          'uid'           => 'userid',          'uid'           => 'userid',
46          'objectGUID'    => 'borrowernumber',          'objectGUID'    => 'b.borrowernumber',
47          'displayName'   => 'surname',          'displayName'   => 'surname',
48          'sn'            => 'surname',          'sn'            => 'surname',
49          'pager'         => 'a.attribute',       # was: rfid_sid          'pager'         => 'a.attribute',       # was: rfid_sid
# Line 208  sub search { Line 206  sub search {
206                          ;                          ;
207    
208                  warn "# SQL:\n$sql\n# DATA: ",dump( @values );                  warn "# SQL:\n$sql\n# DATA: ",dump( @values );
209                    my $dbh = DBI->connect_cached($dsn . $database, $user,$passwd, { RaiseError => 1, AutoCommit => 1 }) || die $DBI::errstr;
210                  my $sth = $dbh->prepare( $sql );                  my $sth = $dbh->prepare( $sql );
211                  $sth->execute( @values );                  $sth->execute( @values );
212    
# Line 220  sub search { Line 219  sub search {
219    
220                          my ( $dn, $attributes ) = _dn_attributes( $row, $base );                          my ( $dn, $attributes ) = _dn_attributes( $row, $base );
221    
222                          warn "# dn $last_dn ... $dn\n";                          warn "## dn $last_dn ... $dn\n" if $debug;
223    
224                          if ( $dn ne $last_dn ) {                          if ( $dn ne $last_dn ) {
225    
226                                  if ( $entry ) {                                  if ( $entry ) {
227                                          #$entry->changetype( 'modify' );                                          #$entry->changetype( 'modify' );
228                                          warn "### entry ",$entry->dump( \*STDERR );                                          warn "### entry ",$entry->dump( \*STDERR ) if $debug;
229                                          push @entries, $entry;                                          push @entries, $entry;
230                                          undef $entry;                                          undef $entry;
231                                  }                                  }
# Line 241  sub search { Line 240  sub search {
240                          } else {                          } else {
241                                  foreach my $n ( keys %$attributes ) {                                  foreach my $n ( keys %$attributes ) {
242                                          my $v = $attributes->{$n};                                          my $v = $attributes->{$n};
243                                          warn "# attr $n = $v\n";                                          warn "## attr $n = $v\n" if $debug;
244                                          $entry->add( $n, $v ) if $entry->get_value( $n ) ne $v;                                          $entry->add( $n, $v ) if $entry->get_value( $n ) ne $v;
245                                  }                                  }
246                          }                          }
# Line 252  sub search { Line 251  sub search {
251                  }                  }
252    
253                  if ( $entry ) {                  if ( $entry ) {
254                          warn "### last entry ",$entry->dump( \*STDERR );                          warn "### last entry ",$entry->dump( \*STDERR ) if $debug;
255                          push @entries, $entry;                          push @entries, $entry;
256                  }                  }
257    

Legend:
Removed from v.62  
changed lines
  Added in v.88

  ViewVC Help
Powered by ViewVC 1.1.26