/[A3C]/bin/import-ldap.pl
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 /bin/import-ldap.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 7 by dpavlin, Thu Mar 13 13:12:46 2008 UTC revision 10 by dpavlin, Thu Mar 13 14:08:41 2008 UTC
# Line 11  use Data::Dump qw/dump/; Line 11  use Data::Dump qw/dump/;
11    
12  BEGIN { Jifty->new; };  BEGIN { Jifty->new; };
13    
14  my $ldap = Net::LDAP->new( 'ldap1.skole.local' ) or die "$@";  my $ldap_config = Jifty->config->app('LDAP');
15    Jifty->log->debug( "config->app(LDAP) = ",dump( $ldap_config ) );
16    
17    my $ldap = Net::LDAP->new( Jifty->config->app('LDAP')->{Server} ) or die "$@";
18    
19  # an anonymous bind  # an anonymous bind
20  my $mesg = $ldap->bind;  #my $mesg = $ldap->bind;
21    my $mesg = $ldap->bind(
22            DN       => Jifty->config->app('LDAP')->{DN},
23            password => Jifty->config->app('LDAP')->{Password},
24    );
25    
26  # perform a search  # perform a search
27  $mesg = $ldap->search(  $mesg = $ldap->search(
28          base   => "dc=skole,dc=hr",          base   => "dc=skole,dc=hr",
29  #       filter => "(&(sn=Barr) (o=Texas Instruments))",  #       filter => "(&(sn=Barr) (o=Texas Instruments))",
30          filter => "(objectClass=hrEduPerson)",          filter => "(objectClass=hrEduPerson)",
31          sizelimit => 100, # off          sizelimit => 100, # 0 = off
32  );  );
33    
34  if ( $mesg->code ) {  if ( $mesg->code ) {
35          warn $mesg->code, ": ", $mesg->error, "\n";          warn $mesg->code, ": ", $mesg->error, "\n";
36  }  }
37    
38  warn "# found ", $mesg->count, " entries\n";  Jifty->log->info( "found ", $mesg->count, " entries" );
39    
40  foreach my $entry ( $mesg->entries ) {  foreach my $entry ( $mesg->entries ) {
41    
# Line 48  foreach my $entry ( $mesg->entries ) { Line 55  foreach my $entry ( $mesg->entries ) {
55                  }                  }
56          }          }
57    
58          warn dump( $data );          Jifty->log->debug( dump( $data ) );
59    
60          $user->load_or_create( %$data );          $user->load_or_create( %$data );
61  }  }

Legend:
Removed from v.7  
changed lines
  Added in v.10

  ViewVC Help
Powered by ViewVC 1.1.26