/[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 58 by dpavlin, Tue Sep 15 13:10:13 2009 UTC revision 87 by dpavlin, Mon Apr 19 13:48:35 2010 UTC
# Line 15  use File::Slurp; Line 15  use File::Slurp;
15    
16  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
17    
18    my $debug = 0; # XXX very slow
19    
20  # XXX test with:  # XXX test with:
21  #  #
22  # ldapsearch -h localhost -p 2389 -b dc=ffzg,dc=hr -x 'otherPager=200903160021'  # ldapsearch -h localhost -p 2389 -b dc=ffzg,dc=hr -x 'otherPager=200903160021'
# Line 37  $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'         => 'rfid_sid',          'pager'         => 'a.attribute',       # was: rfid_sid
50  };  };
51    
52  sub __sql_column {  sub __sql_column {
# Line 120  sub __ldap_search_to_sql { Line 120  sub __ldap_search_to_sql {
120  sub _dn_attributes {  sub _dn_attributes {
121          my ($row,$base) = @_;          my ($row,$base) = @_;
122    
123          warn "## row = ",dump( $row );          warn "## row = ",dump( $row ) if $debug;
124    
125          die "no objectClass column in ",dump( $row ) unless defined $row->{objectClass};          die "no objectClass column in ",dump( $row ) unless defined $row->{objectClass};
126    
127          $row->{objectClass} = [ split(/\s+/, $row->{objectClass}) ] if $row->{objectClass} =~ m{\n};          $row->{objectClass} = [ split(/\s+/, $row->{objectClass}) ] if $row->{objectClass} =~ m{\n};
128    
129          warn "## row = ",dump( $row );          warn "## row = ",dump( $row ) if $debug;
130    
131          my $dn = delete( $row->{dn} ) || die "no dn in ",dump( $row );          my $dn = delete( $row->{dn} ) || die "no dn in ",dump( $row );
132    
# Line 202  sub search { Line 202  sub search {
202                  my $sql                  my $sql
203                          = $sql_select                          = $sql_select
204                          . $sql_where                          . $sql_where
205                          . ( $objectclass =~ m{person}i ? " LIMIT $max_results" : '' ) # add limit just for persons  #                       . ( $objectclass =~ m{person}i ? " LIMIT $max_results" : '' ) # add limit just for persons
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    

Legend:
Removed from v.58  
changed lines
  Added in v.87

  ViewVC Help
Powered by ViewVC 1.1.26