--- bin/ldap.pl 2008/03/12 23:14:13 5 +++ bin/ldap.pl 2008/03/31 21:50:52 48 @@ -6,28 +6,27 @@ use lib 'lib'; use Jifty; -use Net::LDAP; +use A3C::LDAP; +use Data::Dump qw/dump/; +use Getopt::Long; BEGIN { Jifty->new; }; -my $ldap = Net::LDAP->new( 'ldap1.skole.local' ) or die "$@"; +my $limit = 0; +my @models; +GetOptions( + 'limit=i', => \$limit, + 'model=s', => \@models, +); -# an anonymous bind -my $mesg = $ldap->bind; +@models = ( 'Organization' ) unless @models; -# perform a search -$mesg = $ldap->search( - base => "dc=skole,dc=hr", -# filter => "(&(sn=Barr) (o=Texas Instruments))", - filter => "(objectClass=hrEduPerson)", - sizelimit => 0, # off -); +my $ldap = A3C::LDAP->new; -if ( $mesg->code ) { - warn $mesg->code, ": ", $mesg->error, "\n"; -} +Jifty->log->info( 'syncing: ', join(',', @models) ); -foreach my $entry ( $mesg->entries ) { - $entry->dump; +foreach my $model ( @models ) { + my $collection = $ldap->collection( $model, limit => $limit ); + Jifty->log->info( "found ", $collection->count, " entries for $model" ); }