From: Dobrica Pavlinusic Date: Wed, 25 Mar 2009 23:23:12 +0000 (+0000) Subject: implement simple one argument filter and added objectClass X-Git-Url: http://git.rot13.org/?p=virtual-ldap;a=commitdiff_plain;h=3a301eef1a3b4c05046e73aac3ddb0611ea57590;hp=40a5da8b24fa4f79699fee8d7c10eb5c718ccf73 implement simple one argument filter and added objectClass --- diff --git a/lib/LDAP/Koha.pm b/lib/LDAP/Koha.pm index f3527d7..b88475d 100644 --- a/lib/LDAP/Koha.pm +++ b/lib/LDAP/Koha.pm @@ -22,7 +22,7 @@ our $database = 'koha'; our $user = 'unconfigured-user'; our $passwd = 'unconfigured-password'; -our $max_results = 10; # 100; # FIXME +our $max_results = 3; # 100; # FIXME require 'config.pl' if -e 'config.pl'; @@ -148,19 +148,25 @@ sub search { @limits = (); - foreach my $filter ( @{ $reqData->{'filter'}->{ $join_with } } ) { - warn "### filter ",dump($filter),$/; - foreach my $how ( keys %$filter ) { - if ( $how eq 'or' ) { - __ldap_search_to_sql( %$_ ) foreach ( @{ $filter->{$how} } ); - } else { - __ldap_search_to_sql( $how, $filter->{$how} ); + if ( ref $reqData->{'filter'}->{ $join_with } ) { + + foreach my $filter ( @{ $reqData->{'filter'}->{ $join_with } } ) { + warn "### filter ",dump($filter),$/; + foreach my $how ( keys %$filter ) { + if ( $how eq 'or' ) { + __ldap_search_to_sql( %$_ ) foreach ( @{ $filter->{$how} } ); + } else { + __ldap_search_to_sql( $how, $filter->{$how} ); + } + warn "## limits ",dump(@limits), " values ",dump(@values); } - warn "## limits ",dump(@limits), " values ",dump(@values); } - } - $sql_where .= ' ' . join( " $join_with ", @limits ); + $sql_where .= ' ' . join( " $join_with ", @limits ); + + } else { + __ldap_search_to_sql( $join_with, $reqData->{'filter'}->{$join_with} ); + } } @@ -180,12 +186,21 @@ sub search { my $dn = 'uid=' . $row->{uid} || die "no uid"; $dn =~ s{[@\.]}{,dc=}g; + $dn .= ',' . $base unless $dn =~ m{dc}i; my $entry = Net::LDAP::Entry->new; - $entry->dn( $dn . $base ); + $entry->dn( $dn ); + $entry->add( objectClass => [ + "person", + "organizationalPerson", + "inetOrgPerson", + "hrEduPerson", + ] ); $entry->add( %$row ); - #warn "### entry ",dump( $entry ); + #$entry->changetype( 'modify' ); + + warn "### entry ",$entry->dump( \*STDERR ); push @entries, $entry; }