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

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

revision 5 by dpavlin, Wed Mar 12 23:14:13 2008 UTC revision 44 by dpavlin, Sun Mar 30 21:59:34 2008 UTC
# Line 6  use strict; Line 6  use strict;
6  use lib 'lib';  use lib 'lib';
7    
8  use Jifty;  use Jifty;
9  use Net::LDAP;  use A3C::LDAP;
10    use Data::Dump qw/dump/;
11    use Getopt::Long;
12    
13  BEGIN { Jifty->new; };  BEGIN { Jifty->new; };
14    
15  my $ldap = Net::LDAP->new( 'ldap1.skole.local' ) or die "$@";  my $limit = 0;
16    my @models;
17    GetOptions(
18            'limit=i', => \$limit,
19            'model=s', => \@models,
20    );
21    
22  # an anonymous bind  @models = ( 'Organization' ) unless @models;
 my $mesg = $ldap->bind;  
23    
24  # perform a search  my $ldap = A3C::LDAP->new;
 $mesg = $ldap->search(  
         base   => "dc=skole,dc=hr",  
 #       filter => "(&(sn=Barr) (o=Texas Instruments))",  
         filter => "(objectClass=hrEduPerson)",  
         sizelimit => 0, # off  
 );  
25    
26  if ( $mesg->code ) {  Jifty->log->info( 'syncing: ', join(',', @models) );
         warn $mesg->code, ": ", $mesg->error, "\n";  
 }  
27    
28  foreach my $entry ( $mesg->entries ) {  foreach my $model ( @models ) {
29          $entry->dump;          my $collection = $ldap->collection( $model, $limit );
30            Jifty->log->info( "found ", $collection->count, " entries for $model" );
31  }  }
32    

Legend:
Removed from v.5  
changed lines
  Added in v.44

  ViewVC Help
Powered by ViewVC 1.1.26