Revision 40

Date:
2009/03/25 23:23:12
Author:
dpavlin
Revision Log:
implement simple one argument filter and added objectClass
Files:

Legend:

 
Added
 
Removed
 
Modified
  • lib/LDAP/Koha.pm

     
    22 22 our $user = 'unconfigured-user';
    23 23 our $passwd = 'unconfigured-password';
    24 24
    25 our $max_results = 10; # 100; # FIXME
    25 our $max_results = 3; # 100; # FIXME
    26 26
    27 27 require 'config.pl' if -e 'config.pl';
    28 28
     
    148 148
    149 149 @limits = ();
    150 150
    151 foreach my $filter ( @{ $reqData->{'filter'}->{ $join_with } } ) {
    152 warn "### filter ",dump($filter),$/;
    153 foreach my $how ( keys %$filter ) {
    154 if ( $how eq 'or' ) {
    155 __ldap_search_to_sql( %$_ ) foreach ( @{ $filter->{$how} } );
    156 } else {
    157 __ldap_search_to_sql( $how, $filter->{$how} );
    151 if ( ref $reqData->{'filter'}->{ $join_with } ) {
    152
    153 foreach my $filter ( @{ $reqData->{'filter'}->{ $join_with } } ) {
    154 warn "### filter ",dump($filter),$/;
    155 foreach my $how ( keys %$filter ) {
    156 if ( $how eq 'or' ) {
    157 __ldap_search_to_sql( %$_ ) foreach ( @{ $filter->{$how} } );
    158 } else {
    159 __ldap_search_to_sql( $how, $filter->{$how} );
    160 }
    161 warn "## limits ",dump(@limits), " values ",dump(@values);
    158 162 }
    159 warn "## limits ",dump(@limits), " values ",dump(@values);
    160 163 }
    164
    165 $sql_where .= ' ' . join( " $join_with ", @limits );
    166
    167 } else {
    168 __ldap_search_to_sql( $join_with, $reqData->{'filter'}->{$join_with} );
    161 169 }
    162 170
    163 $sql_where .= ' ' . join( " $join_with ", @limits );
    164
    165 171 }
    166 172
    167 173 if ( $sql_where ) {
     
    180 186
    181 187 my $dn = 'uid=' . $row->{uid} || die "no uid";
    182 188 $dn =~ s{[@\.]}{,dc=}g;
    189 $dn .= ',' . $base unless $dn =~ m{dc}i;
    183 190
    184 191 my $entry = Net::LDAP::Entry->new;
    185 $entry->dn( $dn . $base );
    192 $entry->dn( $dn );
    193 $entry->add( objectClass => [
    194 "person",
    195 "organizationalPerson",
    196 "inetOrgPerson",
    197 "hrEduPerson",
    198 ] );
    186 199 $entry->add( %$row );
    187 200
    188 #warn "### entry ",dump( $entry );
    201 #$entry->changetype( 'modify' );
    189 202
    203 warn "### entry ",$entry->dump( \*STDERR );
    204
    190 205 push @entries, $entry;
    191 206 }
    192 207