--- bin/ldap.pl 2008/03/13 19:21:21 17 +++ bin/ldap.pl 2008/03/16 21:32:39 22 @@ -8,9 +8,15 @@ use Jifty; use Net::LDAP; use Data::Dump qw/dump/; +use Getopt::Long; BEGIN { Jifty->new; }; +my $limit = 0; +GetOptions( + 'limit=i', => \$limit, +); + my $ldap_config = Jifty->config->app('LDAP'); Jifty->log->debug( "config->app(LDAP) = ",dump( $ldap_config ) ); @@ -18,10 +24,7 @@ # an anonymous bind #my $mesg = $ldap->bind; -my $mesg = $ldap->bind( - DN => $ldap_config->{DN}, - password => $ldap_config->{Password}, -); +my $mesg = $ldap->bind( $ldap_config->{DN}, password => $ldap_config->{Password} ); Jifty->log->info("Connected to ", $ldap_config->{Server}, " with DN ", $ldap_config->{DN}); @@ -30,18 +33,18 @@ base => "dc=skole,dc=hr", # filter => "(&(sn=Barr) (o=Texas Instruments))", filter => "(objectClass=hrEduPerson)", - sizelimit => 100, # 0 = off + sizelimit => $limit, # 0 = off ); if ( $mesg->code ) { - warn $mesg->code, ": ", $mesg->error, "\n"; + Jifty->log->error( $mesg->code, ": ", $mesg->error ); } Jifty->log->info( "found ", $mesg->count, " entries" ); foreach my $entry ( $mesg->entries ) { - $entry->dump; +# $entry->dump; my $data; my $user = A3C::Model::User->new; @@ -61,6 +64,10 @@ my ( $id, $message ) = $user->load_or_create( %$data ); - Jifty->log->error( $message ) if ! $id; + if ( $id ) { + Jifty->log->info("added $id ", $data->{uid}); + } else { + Jifty->log->error( $message ); + } }